summaryrefslogtreecommitdiff
path: root/src/test/test-mount-util.c
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2021-11-24 12:00:02 +0100
committerJan Janssen <medhefgo@web.de>2021-11-25 15:03:06 +0100
commit4f7452a8eb7a946efea927fae017d4d661097833 (patch)
tree413778cc0fb08fbbed0890130b5ba66c90581e61 /src/test/test-mount-util.c
parent4d5ad9d951299c905453ac8e3769dc82b0a09fb4 (diff)
downloadsystemd-4f7452a8eb7a946efea927fae017d4d661097833.tar.gz
test: Use TEST macro
This converts to TEST macro where it is trivial. Some additional notable changes: - simplify HAVE_LIBIDN #ifdef in test-dns-domain.c - use saved_argc/saved_argv in test-copy.c, test-path-util.c, test-tmpfiles.c and test-unit-file.c
Diffstat (limited to 'src/test/test-mount-util.c')
-rw-r--r--src/test/test-mount-util.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c
index fdf2a249ed..74d352268e 100644
--- a/src/test/test-mount-util.c
+++ b/src/test/test-mount-util.c
@@ -20,12 +20,10 @@
#include "tests.h"
#include "tmpfile-util.h"
-static void test_mount_option_mangle(void) {
+TEST(mount_option_mangle) {
char *opts = NULL;
unsigned long f;
- log_info("/* %s */", __func__);
-
assert_se(mount_option_mangle(NULL, MS_RDONLY|MS_NOSUID, &f, &opts) == 0);
assert_se(f == (MS_RDONLY|MS_NOSUID));
assert_se(opts == NULL);
@@ -91,9 +89,7 @@ static void test_mount_flags_to_string_one(unsigned long flags, const char *expe
assert_se(streq(x, expected));
}
-static void test_mount_flags_to_string(void) {
- log_info("/* %s */", __func__);
-
+TEST(mount_flags_to_string) {
test_mount_flags_to_string_one(0, "0");
test_mount_flags_to_string_one(MS_RDONLY, "MS_RDONLY");
test_mount_flags_to_string_one(MS_NOSUID, "MS_NOSUID");
@@ -129,13 +125,11 @@ static void test_mount_flags_to_string(void) {
"MS_I_VERSION|MS_STRICTATIME|MS_LAZYTIME|fc000200");
}
-static void test_bind_remount_recursive(void) {
+TEST(bind_remount_recursive) {
_cleanup_(rm_rf_physical_and_freep) char *tmp = NULL;
_cleanup_free_ char *subdir = NULL;
const char *p;
- log_info("/* %s */", __func__);
-
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) {
(void) log_tests_skipped("not running privileged");
return;
@@ -186,11 +180,9 @@ static void test_bind_remount_recursive(void) {
}
}
-static void test_bind_remount_one(void) {
+TEST(bind_remount_one) {
pid_t pid;
- log_info("/* %s */", __func__);
-
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) {
(void) log_tests_skipped("not running privileged");
return;
@@ -220,13 +212,11 @@ static void test_bind_remount_one(void) {
assert_se(wait_for_terminate_and_check("test-remount-one", pid, WAIT_LOG) == EXIT_SUCCESS);
}
-static void test_make_mount_point_inode(void) {
+TEST(make_mount_point_inode) {
_cleanup_(rm_rf_physical_and_freep) char *d = NULL;
const char *src_file, *src_dir, *dst_file, *dst_dir;
struct stat st;
- log_info("/* %s */", __func__);
-
assert_se(mkdtemp_malloc(NULL, &d) >= 0);
src_file = strjoina(d, "/src/file");
@@ -266,14 +256,4 @@ static void test_make_mount_point_inode(void) {
assert_se(!(S_IXOTH & st.st_mode));
}
-int main(int argc, char *argv[]) {
- test_setup_logging(LOG_DEBUG);
-
- test_mount_option_mangle();
- test_mount_flags_to_string();
- test_bind_remount_recursive();
- test_bind_remount_one();
- test_make_mount_point_inode();
-
- return 0;
-}
+DEFINE_TEST_MAIN(LOG_DEBUG);