]> git.ipfire.org Git - thirdparty/kmod.git/blobdiff - testsuite/test-new-module.c
ci: add clang-format action
[thirdparty/kmod.git] / testsuite / test-new-module.c
index 117d978845fa0778c2b841aa2bb6c9c98e37b386..866526de68ba9b1a1595b3038d98928c972af9c9 100644 (file)
@@ -1,42 +1,33 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
 /*
- * Copyright (C) 2012  ProFUSION embedded systems
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * Copyright (C) 2012-2013  ProFUSION embedded systems
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
 #include <errno.h>
-#include <unistd.h>
 #include <inttypes.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <libkmod.h>
+#include <unistd.h>
+
+#include <libkmod/libkmod.h>
 
 #include "testsuite.h"
 
 static int from_name(const struct test *t)
 {
-       static const char *modnames[] = {
+       static const char *const modnames[] = {
+               // clang-format off
                "ext4",
                "balbalbalbbalbalbalbalbalbalbal",
                "snd-hda-intel",
                "snd-timer",
                "iTCO_wdt",
                NULL,
+               // clang-format on
        };
-       const char **p;
+       const char *const *p;
        struct kmod_ctx *ctx;
        struct kmod_module *mod;
        const char *null_config = NULL;
@@ -59,27 +50,23 @@ static int from_name(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test sfrom_name = {
-       .name = "sfrom_name",
+DEFINE_TEST(from_name,
        .description = "check if module names are parsed correctly",
-       .func = from_name,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-new-module/from_name/",
        },
        .need_spawn = true,
        .output = {
-               .stdout = TESTSUITE_ROOTFS "test-new-module/from_name/correct.txt",
-       },
-};
-
+               .out = TESTSUITE_ROOTFS "test-new-module/from_name/correct.txt",
+       });
 
 static int from_alias(const struct test *t)
 {
-       static const char *modnames[] = {
+       static const char *const modnames[] = {
                "ext4.*",
                NULL,
        };
-       const char **p;
+       const char *const *p;
        struct kmod_ctx *ctx;
        int err;
 
@@ -108,23 +95,14 @@ static int from_alias(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test sfrom_alias = {
-       .name = "sfrom_alias",
+DEFINE_TEST(from_alias,
        .description = "check if aliases are parsed correctly",
-       .func = from_alias,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-new-module/from_alias/",
        },
        .need_spawn = true,
        .output = {
-               .stdout = TESTSUITE_ROOTFS "test-new-module/from_alias/correct.txt",
-       },
-};
-
-static const struct test *tests[] = {
-       &sfrom_name,
-       &sfrom_alias,
-       NULL,
-};
+               .out = TESTSUITE_ROOTFS "test-new-module/from_alias/correct.txt",
+       });
 
-TESTSUITE_MAIN(tests);
+TESTSUITE_MAIN();