]> 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 240480eafcd63327e6d8d0aee951bf94cf73555e..866526de68ba9b1a1595b3038d98928c972af9c9 100644 (file)
@@ -1,43 +1,33 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
 /*
  * Copyright (C) 2012-2013  ProFUSION embedded systems
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#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;
@@ -60,23 +50,23 @@ static int from_name(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static DEFINE_TEST(from_name,
+DEFINE_TEST(from_name,
        .description = "check if module names are parsed correctly",
        .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;
 
@@ -105,20 +95,14 @@ static int from_alias(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static DEFINE_TEST(from_alias,
+DEFINE_TEST(from_alias,
        .description = "check if aliases are parsed correctly",
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-new-module/from_alias/",
        },
        .need_spawn = true,
        .output = {
-               .stdout = TESTSUITE_ROOTFS "test-new-module/from_alias/correct.txt",
+               .out = TESTSUITE_ROOTFS "test-new-module/from_alias/correct.txt",
        });
 
-static const struct test *tests[] = {
-       &sfrom_name,
-       &sfrom_alias,
-       NULL,
-};
-
-TESTSUITE_MAIN(tests);
+TESTSUITE_MAIN();