From ff1f65f8dfe0d57d57dad650c913cdebd275569f Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Thu, 30 May 2024 17:18:48 +0200 Subject: [PATCH 1/3] test: reactivate xattr integration tests --- test/libsqsh/integration.c | 38 +++++++++++++++--------------- test/libsqsh/integration_create.sh | 8 +++---- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/test/libsqsh/integration.c b/test/libsqsh/integration.c index 6f08f8afd..55169686a 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 8924583e3..87fdededc 100755 --- a/test/libsqsh/integration_create.sh +++ b/test/libsqsh/integration_create.sh @@ -13,12 +13,10 @@ 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" \ + -p '"large_dir" x user.force_extended=true' \ + -p '"a" x user.foo=1234567891234567891234567890001234567890' \ + -p '"b" x user.bar=1234567891234567891234567890001234567890' \ -nopad \ -force-uid 2020 \ -force-gid 202020 \ From 4bcc1cf2728c06d89426355714eeeaf97f9ae0a3 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Thu, 30 May 2024 17:28:25 +0200 Subject: [PATCH 2/3] .github: update CodeCov worker to Ubuntu 24.04 --- .github/workflows/codecov.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 07eacef29..9ecfea560 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: From c8a3d46d71b2d4cc46ba086c8b1bb8c764d316af Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Thu, 30 May 2024 18:57:05 +0200 Subject: [PATCH 3/3] test: use mksquashfs -pf feature instead of creating the files on disk --- test/libsqsh/integration_create.sh | 39 ++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/test/libsqsh/integration_create.sh b/test/libsqsh/integration_create.sh index 87fdededc..2ac79ff8b 100755 --- a/test/libsqsh/integration_create.sh +++ b/test/libsqsh/integration_create.sh @@ -4,19 +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" -$MKSQUASHFS "$tmp" "$out.tmp" \ - -p '"large_dir" x user.force_extended=true' \ - -p '"a" x user.foo=1234567891234567891234567890001234567890' \ - -p '"b" x user.bar=1234567891234567891234567890001234567890' \ +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 \ @@ -25,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"