]> git.ipfire.org Git - thirdparty/kmod.git/blobdiff - testsuite/test-testsuite.c
testsuite: port softdep-loop test to module-playground
[thirdparty/kmod.git] / testsuite / test-testsuite.c
index 44495c2cbb40b824097ad7383e493491ce3a0702..e6867b5047d39f1d0f965f17dbf5b2b9ffae8b5e 100644 (file)
@@ -12,8 +12,7 @@
  * 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
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <dirent.h>
@@ -27,7 +26,9 @@
 #include <sys/types.h>
 #include <sys/utsname.h>
 
-#include <libkmod.h>
+#include <shared/util.h>
+
+#include <libkmod/libkmod.h>
 
 #include "testsuite.h"
 
@@ -41,7 +42,7 @@ static noreturn int testsuite_uname(const struct test *t)
        if (err < 0)
                exit(EXIT_FAILURE);
 
-       if (strcmp(u.release, TEST_UNAME) != 0) {
+       if (!streq(u.release, TEST_UNAME)) {
                char *ldpreload = getenv("LD_PRELOAD");
                ERR("u.release=%s should be %s\n", u.release, TEST_UNAME);
                ERR("LD_PRELOAD=%s\n", ldpreload);
@@ -50,7 +51,7 @@ static noreturn int testsuite_uname(const struct test *t)
 
        exit(EXIT_SUCCESS);
 }
-static DEFINE_TEST(testsuite_uname,
+DEFINE_TEST(testsuite_uname,
        .description = "test if trap to uname() works",
        .config = {
                [TC_UNAME_R] = TEST_UNAME,
@@ -71,12 +72,12 @@ static int testsuite_rootfs_fopen(const struct test *t)
        if (n != 1)
                return EXIT_FAILURE;
 
-       if (strcmp(s, "kmod-test-chroot-works") != 0)
+       if (!streq(s, "kmod-test-chroot-works"))
                return EXIT_FAILURE;
 
        return EXIT_SUCCESS;
 }
-static DEFINE_TEST(testsuite_rootfs_fopen,
+DEFINE_TEST(testsuite_rootfs_fopen,
        .description = "test if rootfs works - fopen()",
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
@@ -104,12 +105,12 @@ static int testsuite_rootfs_open(const struct test *t)
 
        buf[done] = '\0';
 
-       if (strcmp(buf, "kmod-test-chroot-works\n") != 0)
+       if (!streq(buf, "kmod-test-chroot-works\n"))
                return EXIT_FAILURE;
 
        return EXIT_SUCCESS;
 }
-static DEFINE_TEST(testsuite_rootfs_open,
+DEFINE_TEST(testsuite_rootfs_open,
        .description = "test if rootfs works - open()",
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
@@ -132,7 +133,7 @@ static int testsuite_rootfs_stat_access(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static DEFINE_TEST(testsuite_rootfs_stat_access,
+DEFINE_TEST(testsuite_rootfs_stat_access,
        .description = "test if rootfs works - stat() and access()",
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
@@ -152,20 +153,11 @@ static int testsuite_rootfs_opendir(const struct test *t)
        closedir(d);
        return EXIT_SUCCESS;
 }
-static DEFINE_TEST(testsuite_rootfs_opendir,
+DEFINE_TEST(testsuite_rootfs_opendir,
        .description = "test if rootfs works - opendir()",
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
        },
        .need_spawn = true);
 
-static const struct test *tests[] = {
-       &stestsuite_uname,
-       &stestsuite_rootfs_fopen,
-       &stestsuite_rootfs_open,
-       &stestsuite_rootfs_stat_access,
-       &stestsuite_rootfs_opendir,
-       NULL,
-};
-
-TESTSUITE_MAIN(tests);
+TESTSUITE_MAIN();