]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Make Pakfire operate in the stub root all the time
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Oct 2024 16:17:16 +0000 (16:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Oct 2024 16:17:16 +0000 (16:17 +0000)
This makes it easier than bind-mounting the command.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
tests/libpakfire/main.c
tests/testsuite.c

index 5f31c49fc959478e044c69bbf5e9cc720df9967e..91d82ae75ddc4fcf66b842de15445434e72387ea 100644 (file)
@@ -1082,7 +1082,6 @@ TESTSUITE_CPPFLAGS = \
        -DTEST_CONFIG_FILE=\"$(abs_top_srcdir)/contrib/config/pakfire.conf\" \
        -DTEST_DATA_DIR=\"$(abs_top_srcdir)/tests/data\" \
        -DTEST_ROOTFS=\"$(TEST_ROOTFS)\" \
-       -DTEST_STUB_COMMAND=\"$(abs_top_builddir)/tests/stub/root/command\" \
        -DTEST_STUB_ROOT=\"$(TEST_STUB_ROOT)\" \
        -DPAKFIRE_PRIVATE
 
index af0059bd46046c903a6715e44d4808a3c79aa59b..5ac1a7df36c5506fb90990a48d8083b7d29779ae 100644 (file)
 static int test_init(const struct test* t) {
        LOG("Allocated at %p\n", t->pakfire);
 
-       return EXIT_SUCCESS;
-}
-
-static int test_path(const struct test* t) {
-       const char* path = pakfire_get_path(t->pakfire);
-       ASSERT_STRING_STARTSWITH(path, TEST_ROOTFS);
+       // Check if the path matches
+       ASSERT_STRING_EQUALS(pakfire_get_path(t->pakfire), TEST_STUB_ROOT);
 
        return EXIT_SUCCESS;
 
@@ -40,7 +36,6 @@ FAIL:
 
 int main(int argc, const char* argv[]) {
        testsuite_add_test(test_init, TEST_WANTS_PAKFIRE);
-       testsuite_add_test(test_path, TEST_WANTS_PAKFIRE);
 
        return testsuite_run(argc, argv);
 }
index b6cb90e7716603ad1b4cb7d8f36250b9d9786036..3e3304dab6e1da648edc9f13dd4d37338131f29f 100644 (file)
@@ -64,7 +64,7 @@ static int test_run(int i, struct test* t) {
 
        // Create a pakfire instance (if requested)
        if (t->flags & TEST_WANTS_PAKFIRE) {
-               r = pakfire_create(&t->pakfire, t->ctx, NULL, NULL, c, 0);
+               r = pakfire_create(&t->pakfire, t->ctx, TEST_STUB_ROOT, NULL, c, 0);
                if (r < 0) {
                        LOG("ERROR: Could not initialize pakfire: %s\n", strerror(-r));
                        goto ERROR;
@@ -75,13 +75,6 @@ static int test_run(int i, struct test* t) {
                        LOG("ERROR: Pakfire was not initialized, but no error was raised: %m\n");
                        goto ERROR;
                }
-
-               // Copy command into environment
-               r = pakfire_bind(t->pakfire, TEST_STUB_COMMAND, "/command", 0);
-               if (r) {
-                       LOG("ERROR: Could not copy command: %m\n");
-                       goto ERROR;
-               }
        }
 
        // Create a HTTP client (if requested)