diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 07eacef2..9ecfea56 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -7,7 +7,7 @@ on: jobs: codecov: name: CodeCov - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: diff --git a/test/libsqsh/integration.c b/test/libsqsh/integration.c index 6f08f8af..55169686 100644 --- a/test/libsqsh/integration.c +++ b/test/libsqsh/integration.c @@ -418,8 +418,6 @@ UTEST(integration, sqsh_test_extended_dir) { ASSERT_EQ(0, rv); } -#if 0 - UTEST(integration, sqsh_test_xattr) { const char *expected_value = "1234567891234567891234567890001234567890"; int rv; @@ -429,7 +427,6 @@ UTEST(integration, sqsh_test_xattr) { struct SqshDirectoryIterator *dir_iter = NULL; struct SqshXattrIterator *xattr_iter = NULL; struct SqshArchive sqsh = {0}; - const struct SqshSuperblock *superblock; struct SqshConfig config = { .source_mapper = sqsh_mapper_impl_static, .source_size = TEST_SQUASHFS_IMAGE_LEN, @@ -438,15 +435,15 @@ UTEST(integration, sqsh_test_xattr) { rv = sqsh__archive_init(&sqsh, (char *)TEST_SQUASHFS_IMAGE, &config); ASSERT_EQ(0, rv); - superblock = sqsh_archive_superblock(&sqsh); - file = sqsh_file_new( - &sqsh, sqsh_superblock_inode_root_ref(superblock), &rv); + file = sqsh_open(&sqsh, "/", &rv); ASSERT_EQ(0, rv); + bool has_next; xattr_iter = sqsh_xattr_iterator_new(file, &rv); ASSERT_NE(NULL, xattr_iter); ASSERT_EQ(0, rv); - rv = sqsh_xattr_iterator_next(xattr_iter); + has_next = sqsh_xattr_iterator_next(xattr_iter, &rv); + ASSERT_FALSE(has_next); ASSERT_EQ(0, rv); rv = sqsh_xattr_iterator_free(xattr_iter); ASSERT_EQ(0, rv); @@ -455,8 +452,9 @@ UTEST(integration, sqsh_test_xattr) { ASSERT_NE(NULL, dir_iter); ASSERT_EQ(0, rv); - rv = sqsh_directory_iterator_next(dir_iter); - assert(rv > 0); + has_next = sqsh_directory_iterator_next(dir_iter, &rv); + ASSERT_TRUE(has_next); + ASSERT_EQ(0, rv); name = sqsh_directory_iterator_name_dup(dir_iter); ASSERT_NE(NULL, name); ASSERT_EQ(0, strcmp("a", name)); @@ -466,8 +464,9 @@ UTEST(integration, sqsh_test_xattr) { xattr_iter = sqsh_xattr_iterator_new(entry_file, &rv); ASSERT_NE(NULL, xattr_iter); ASSERT_EQ(0, rv); - rv = sqsh_xattr_iterator_next(xattr_iter); - assert(rv > 0); + has_next = sqsh_xattr_iterator_next(xattr_iter, &rv); + ASSERT_TRUE(has_next); + ASSERT_EQ(0, rv); ASSERT_EQ(false, sqsh_xattr_iterator_is_indirect(xattr_iter)); name = sqsh_xattr_iterator_fullname_dup(xattr_iter); ASSERT_NE(NULL, name); @@ -477,15 +476,17 @@ UTEST(integration, sqsh_test_xattr) { ASSERT_NE(NULL, value); ASSERT_EQ(0, strcmp(expected_value, value)); free(value); - rv = sqsh_xattr_iterator_next(xattr_iter); + has_next = sqsh_xattr_iterator_next(xattr_iter, &rv); + ASSERT_FALSE(has_next); ASSERT_EQ(0, rv); rv = sqsh_xattr_iterator_free(xattr_iter); ASSERT_EQ(0, rv); rv = sqsh_close(entry_file); ASSERT_EQ(0, rv); - rv = sqsh_directory_iterator_next(dir_iter); - assert(rv >= 0); + has_next = sqsh_directory_iterator_next(dir_iter, &rv); + ASSERT_TRUE(has_next); + ASSERT_EQ(0, rv); name = sqsh_directory_iterator_name_dup(dir_iter); ASSERT_NE(NULL, name); ASSERT_EQ(0, strcmp("b", name)); @@ -495,8 +496,8 @@ UTEST(integration, sqsh_test_xattr) { xattr_iter = sqsh_xattr_iterator_new(entry_file, &rv); ASSERT_NE(NULL, xattr_iter); ASSERT_EQ(0, rv); - rv = sqsh_xattr_iterator_next(xattr_iter); - assert(rv > 0); + has_next = sqsh_xattr_iterator_next(xattr_iter, &rv); + ASSERT_EQ(0, rv); ASSERT_EQ(true, sqsh_xattr_iterator_is_indirect(xattr_iter)); name = sqsh_xattr_iterator_fullname_dup(xattr_iter); ASSERT_NE(NULL, name); @@ -506,7 +507,7 @@ UTEST(integration, sqsh_test_xattr) { ASSERT_NE(NULL, value); ASSERT_EQ(0, strcmp(expected_value, value)); free(value); - rv = sqsh_xattr_iterator_next(xattr_iter); + has_next = sqsh_xattr_iterator_next(xattr_iter, &rv); ASSERT_EQ(0, rv); rv = sqsh_xattr_iterator_free(xattr_iter); ASSERT_EQ(0, rv); @@ -516,13 +517,12 @@ UTEST(integration, sqsh_test_xattr) { rv = sqsh_directory_iterator_free(dir_iter); ASSERT_EQ(0, rv); - rv = sqsh_file_cleanup(file); + rv = sqsh_close(file); ASSERT_EQ(0, rv); rv = sqsh__archive_cleanup(&sqsh); ASSERT_EQ(0, rv); } -#endif struct Walker { struct SqshArchive *sqsh; diff --git a/test/libsqsh/integration_create.sh b/test/libsqsh/integration_create.sh index 8924583e..2ac79ff8 100755 --- a/test/libsqsh/integration_create.sh +++ b/test/libsqsh/integration_create.sh @@ -4,21 +4,29 @@ in=$1 out=$2 tmp=$3 -mkdir -p "$tmp" -echo a > "$tmp/a" -# OpenBSD uses floating point for seq, so it may no precise about the number -# of lines. Use head to make sure we have the right number of lines. -seq 1 1050000 | head -1050000 | tr -cd "\n" | tr '\n' b > "$tmp/b" -mkdir -p "$tmp/large_dir" -seq 1 1050 | sed "s#.*#$tmp/large_dir/&#" | xargs touch -ln -s .. "$tmp/large_dir/link" -[ -e "$out" ] && rm "$out" -# xattr integration tests are disabled because they are not supported on all -# platforms, notably OpenBSD which is used as baseline test. -# -p '"large_dir" x user.force_extended=true' \ -# -p '"a" x user.foo=1234567891234567891234567890001234567890' \ -# -p '"b" x user.bar=1234567891234567891234567890001234567890' \ -$MKSQUASHFS "$tmp" "$out.tmp" \ +mkdir -p "$tmp/empty" + +# Check if the directory is actually empty +[ -z "$(find "$tmp/empty" -mindepth 1)" ] + +cat > $tmp/pf <> $tmp/pf +done + +[ -e "$tmp/image" ] && rm "$tmp/image" +$MKSQUASHFS "$tmp/empty" "$tmp/image" \ + -pf "$tmp/pf" \ + -noappend \ -nopad \ -force-uid 2020 \ -force-gid 202020 \ @@ -27,5 +35,4 @@ $MKSQUASHFS "$tmp" "$out.tmp" \ -quiet -no-progress dd if=/dev/zero of="$out" bs=1 count=0 seek=1010 2>/dev/null -cat "$out.tmp" >> "$out" -rm "$out.tmp" +cat "$tmp/image" >> "$out"