]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-terminal-util.c
test: Use TEST macro
[thirdparty/systemd.git] / src / test / test-terminal-util.c
index e793a74b13045cc62534485e0852e195a0ac3228..292e5348bcca1649b54c2d634f53cab1748cae9b 100644 (file)
@@ -22,9 +22,7 @@
         "in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat " \
         "non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
 
-static void test_default_term_for_tty(void) {
-        log_info("/* %s */", __func__);
-
+TEST(default_term_for_tty) {
         puts(default_term_for_tty("/dev/tty23"));
         puts(default_term_for_tty("/dev/ttyS23"));
         puts(default_term_for_tty("/dev/tty0"));
@@ -39,14 +37,12 @@ static void test_default_term_for_tty(void) {
         puts(default_term_for_tty("console"));
 }
 
-static void test_read_one_char(void) {
+TEST(read_one_char) {
         _cleanup_fclose_ FILE *file = NULL;
         char r;
         bool need_nl;
         char name[] = "/tmp/test-read_one_char.XXXXXX";
 
-        log_info("/* %s */", __func__);
-
         assert_se(fmkostemp_safe(name, "r+", &file) == 0);
 
         assert_se(fputs("c\n", file) >= 0);
@@ -69,12 +65,10 @@ static void test_read_one_char(void) {
         assert_se(unlink(name) >= 0);
 }
 
-static void test_getttyname_malloc(void) {
+TEST(getttyname_malloc) {
         _cleanup_free_ char *ttyname = NULL;
         _cleanup_close_ int master = -1;
 
-        log_info("/* %s */", __func__);
-
         assert_se((master = posix_openpt(O_RDWR|O_NOCTTY)) >= 0);
         assert_se(getttyname_malloc(master, &ttyname) >= 0);
         log_info("ttyname = %s", ttyname);
@@ -130,16 +124,12 @@ static const Color colors[] = {
         { "highlight-grey-underline", ansi_highlight_grey_underline },
 };
 
-static void test_colors(void) {
-        log_info("/* %s */", __func__);
-
+TEST(colors) {
         for (size_t i = 0; i < ELEMENTSOF(colors); i++)
                 printf("<%s%s%s>\n", colors[i].func(), colors[i].name, ansi_normal());
 }
 
-static void test_text(void) {
-        log_info("/* %s */", __func__);
-
+TEST(text) {
         for (size_t i = 0; !streq(colors[i].name, "underline"); i++) {
                 bool blwh = strstr(colors[i].name, "black")
                         || strstr(colors[i].name, "white");
@@ -154,7 +144,7 @@ static void test_text(void) {
         }
 }
 
-static void test_get_ctty(void) {
+TEST(get_ctty) {
         _cleanup_free_ char *ctty = NULL;
         struct stat st;
         dev_t devnr;
@@ -177,15 +167,4 @@ static void test_get_ctty(void) {
                 log_notice("Not invoked with stdin == ctty, cutting get_ctty() test short");
 }
 
-int main(int argc, char *argv[]) {
-        test_setup_logging(LOG_INFO);
-
-        test_default_term_for_tty();
-        test_read_one_char();
-        test_getttyname_malloc();
-        test_colors();
-        test_text();
-        test_get_ctty();
-
-        return 0;
-}
+DEFINE_TEST_MAIN(LOG_INFO);