Skip to content

Commit

Permalink
Merge pull request #241 from Gottox/improve/reactivate-xattr-tests
Browse files Browse the repository at this point in the history
test: reactivate xattr integration tests
  • Loading branch information
Gottox committed May 30, 2024
2 parents 5c14264 + c8a3d46 commit 7d85f0b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
codecov:
name: CodeCov
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand Down
38 changes: 19 additions & 19 deletions test/libsqsh/integration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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);
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down
41 changes: 24 additions & 17 deletions test/libsqsh/integration_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
"a" F 0 777 2020 202020 echo a
"b" F 0 777 2020 202020 seq 1 1050000 | head -1050000 | tr -cd "\n" | tr '\n' b
"large_dir" D 0 777 2020 202020
"large_dir" x user.force_extended=true
"a" x user.foo=1234567891234567891234567890001234567890
"b" x user.bar=1234567891234567891234567890001234567890
"large_dir/link" s 777 2020 202020 ..
EOF

for i in $(seq 1 1000); do
printf '"large_dir/%i" I 0 777 2020 202020 f\n' "$i" >> $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 \
Expand All @@ -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"

0 comments on commit 7d85f0b

Please sign in to comment.