]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Remove all typedefs and use structs instead
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Jan 2021 12:44:46 +0000 (12:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Jan 2021 12:44:46 +0000 (12:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/arch.c
tests/libpakfire/archive.c
tests/libpakfire/execute.c
tests/libpakfire/key.c
tests/libpakfire/main.c
tests/libpakfire/makefile.c
tests/libpakfire/parser.c
tests/libpakfire/util.c
tests/testsuite.c
tests/testsuite.h

index b9f42fc49034fb0dfacaf32146020c26afab91c8..3a7aa6e46d510c4305f13192e4d667ce4414e61b 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "../testsuite.h"
 
-static int test_native(const test_t* t) {
+static int test_native(const struct test* t) {
        // First call
        const char* arch1 = pakfire_arch_native();
        assert_return(arch1, EXIT_FAILURE);
@@ -40,7 +40,7 @@ static int test_native(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_supported(const test_t* t) {
+static int test_supported(const struct test* t) {
        int r;
 
        r = pakfire_arch_supported("x86_64");
@@ -56,7 +56,7 @@ static int test_supported(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_compatible(const test_t* t) {
+static int test_compatible(const struct test* t) {
        int r;
 
        // x86_64 can build i686
@@ -82,7 +82,7 @@ static int test_compatible(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_machine(const test_t* t) {
+static int test_machine(const struct test* t) {
        char* machine;
 
        machine = pakfire_arch_machine("x86_64", "ipfire");
index 537da0608ded87314a6cba0e693cb2f6e864b012..8f910f2bcd16a9f6034c5d09d1cc5a657f93a8ae 100644 (file)
@@ -30,7 +30,7 @@
 static const char* TEST_PKG1_PATH = "data/beep-1.3-2.ip3.x86_64.pfm";
 static const char* TEST_PKG1_FILE = "usr/bin/beep";
 
-static int test_open(const test_t* t) {
+static int test_open(const struct test* t) {
        char* path = pakfire_path_join(TEST_SRC_PATH, TEST_PKG1_PATH);
        LOG("Trying to open %s\n", path);
 
@@ -48,7 +48,7 @@ static int test_open(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_extract(const test_t* t) {
+static int test_extract(const struct test* t) {
        char* path = pakfire_path_join(TEST_SRC_PATH, TEST_PKG1_PATH);
 
        PakfireArchive archive = pakfire_archive_open(t->pakfire, path);
@@ -67,7 +67,7 @@ static int test_extract(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_import(const test_t* t) {
+static int test_import(const struct test* t) {
        char* path = pakfire_path_join(TEST_SRC_PATH, TEST_PKG1_PATH);
 
        PakfireArchive archive = pakfire_archive_open(t->pakfire, path);
index 5398fd58cfbcc70b5e280d89645e7b725df06ae1..e6ae7dcb5d157e88c06d05f37acf0f5907a0647b 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "../testsuite.h"
 
-static int test_does_not_exist(const test_t* t) {
+static int test_does_not_exist(const struct test* t) {
        const char* cmd = "/usr/bin/does-not-exist";
 
        int r = pakfire_execute(t->pakfire, cmd, NULL, NULL, 0);
index 32cecdfbbe598abf5084bfb836ddfa2989be97cc..2da8c7edd0193460524bc6168c5539f0f8e5c891 100644 (file)
@@ -26,7 +26,7 @@
 #include "../testsuite.h"
 #include "key.h"
 
-static int test_init(const test_t* t) {
+static int test_init(const struct test* t) {
        // Try loading any keys & delete them all
        PakfireKey* keys = pakfire_key_list(t->pakfire);
        while (keys && *keys) {
@@ -45,7 +45,7 @@ static int test_init(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_import(const test_t* t) {
+static int test_import(const struct test* t) {
        // Try to delete the key just in case it
        // has been imported before
        PakfireKey key = pakfire_key_get(t->pakfire, TEST_KEY_FINGERPRINT);
@@ -74,7 +74,7 @@ static int test_import(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_export(const test_t* t) {
+static int test_export(const struct test* t) {
        PakfireKey key = pakfire_key_get(t->pakfire, TEST_KEY_FINGERPRINT);
        assert_return(key, EXIT_FAILURE);
 
index 35d506a6921882346e308ae42e1bf04268add77e..315a46578a7d2812a7a731ccf3a8fb6b03942042 100644 (file)
 
 #include "../testsuite.h"
 
-static int test_init(const test_t* t) {
+static int test_init(const struct test* t) {
        LOG("Allocated at %p\n", t->pakfire);
 
        return EXIT_SUCCESS;
 }
 
-static int test_path(const test_t* t) {
+static int test_path(const struct test* t) {
        const char* path = pakfire_get_path(t->pakfire);
        assert_return(strcmp(path, TEST_ROOTFS) == 0, EXIT_FAILURE);
 
index ab275c57883a49b4a74af80c868864b6530b8ba8..5dadedef99089ba9989c47ed930113a3905ac5c8 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "../testsuite.h"
 
-static int test_parse(const test_t* t) {
+static int test_parse(const struct test* t) {
        char* path = pakfire_path_join(TEST_SRC_PATH, "data/kernel.nm");
 
        // Open file
index 80ce55dea3c550f5424824fcececc99af56862bd..32c22629dca5cbce834e2c08bf904df789ac71c9 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "../testsuite.h"
 
-static int test_parser(const test_t* t) {
+static int test_parser(const struct test* t) {
        char* value = NULL;
 
        // Create a new parser
index 97fcf643d1fc8ecc56462951a8eca324b9ca4fb0..32b4fec1ac56d1d75b484f31bc8109379ec883e1 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "../testsuite.h"
 
-static int test_basename(const test_t* t) {
+static int test_basename(const struct test* t) {
        const char* dir = "/a/b/c";
 
        char* output = pakfire_basename(dir);
@@ -35,7 +35,7 @@ static int test_basename(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_dirname(const test_t* t) {
+static int test_dirname(const struct test* t) {
        const char* dir = "/a/b/c";
 
        char* output = pakfire_dirname(dir);
@@ -45,7 +45,7 @@ static int test_dirname(const test_t* t) {
        return EXIT_SUCCESS;
 }
 
-static int test_string_startswith(const test_t* t) {
+static int test_string_startswith(const struct test* t) {
        int r;
 
        r = pakfire_string_startswith("ABC", "A");
index 19056c10c19f62b93a64fa473199979545bcd5b5..72d2e36ab537e85a9148c23b35dbbf7bfe05c0be 100644 (file)
@@ -25,9 +25,9 @@
 
 const char* TEST_SRC_PATH = ABS_TOP_SRCDIR "/tests";
 
-testsuite_t ts;
+struct testsuite ts;
 
-static int test_run(test_t* t) {
+static int test_run(struct test* t) {
        LOG("running %s\n", t->name);
 
        t->pakfire = pakfire_create(TEST_ROOTFS, NULL);
@@ -55,7 +55,7 @@ static int test_run(test_t* t) {
        return r;
 }
 
-int __testsuite_add_test(const char* name, test_function_t func) {
+int __testsuite_add_test(const char* name, int (*func)(const struct test* t)) {
        // Check if any space is left
        if (ts.num >= MAX_TESTS) {
                LOG("ERROR: We are out of space for tests\n");
index 32017655200f0b99f4b917d4b7666c6bf51cdca5..33d4c9a20dae3d66814d329d7946a4e55670afc2 100644 (file)
 
 extern const char* TEST_SRC_PATH;
 
-// Forward declaration
-struct test;
-
-typedef int (*test_function_t)(const struct test* t);
-
-typedef struct test {
+struct test {
        const char* name;
-       test_function_t func;
+       int (*func)(const struct test* t);
        Pakfire pakfire;
-} test_t;
+};
 
-typedef struct testsuite {
-       test_t tests[MAX_TESTS];
+struct testsuite {
+       struct test tests[MAX_TESTS];
        size_t num;
 } testsuite_t;
 
-extern testsuite_t ts;
+extern struct testsuite ts;
 
-int __testsuite_add_test(const char* name, test_function_t func);
+int __testsuite_add_test(const char* name, int (*func)(const struct test* t));
 int testsuite_run();
 
 #define _LOG(prefix, fmt, ...) fprintf(stderr, "TESTS: " prefix fmt, ## __VA_ARGS__);