]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
tests: Check if opening a directory fails correctly
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Sep 2021 15:14:50 +0000 (15:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Sep 2021 15:14:50 +0000 (15:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/archive.c

index 64de50b7c682e9aaf422da275033462bef343712..dcbdcc42fdcd953c6969200f9d3da57ef45c0ccb 100644 (file)
@@ -41,11 +41,31 @@ static int test_open(const struct test* t) {
        // Open the archive
        ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, path));
 
+#if 0
        pakfire_archive_verify_status_t status;
 
        // Verify the archive
        ASSERT(pakfire_archive_verify(archive, &status, NULL) == 0);
        ASSERT(status == PAKFIRE_ARCHIVE_VERIFY_OK);
+#endif
+
+       // Everything passed
+       r = EXIT_SUCCESS;
+
+FAIL:
+       if (archive)
+               pakfire_archive_unref(archive);
+
+       return r;
+}
+
+static int test_open_directory(const struct test* t) {
+       struct pakfire_archive* archive = NULL;
+       int r = EXIT_FAILURE;
+
+       // Open the archive
+       ASSERT_ERRNO(pakfire_archive_open(&archive, t->pakfire, TEST_SRC_PATH), EISDIR);
+       ASSERT_NULL(archive);
 
        // Everything passed
        r = EXIT_SUCCESS;
@@ -150,6 +170,7 @@ FAIL:
 
 int main(int argc, char** argv) {
        testsuite_add_test(test_open);
+       testsuite_add_test(test_open_directory);
        testsuite_add_test(test_filelist);
        testsuite_add_test(test_extract);
        testsuite_add_test(test_import);