Skip to content

Commit

Permalink
Merge pull request #79 from Gottox/fix/tree-add-alternating-test
Browse files Browse the repository at this point in the history
tree: add test for recursively alternating symlinks
  • Loading branch information
Gottox authored Aug 29, 2023
2 parents 92f35c2 + 25552de commit e6ce61b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/tree/walker.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,47 @@ walker_symlink_recursion(void) {
sqsh__archive_cleanup(&archive);
}

static void
walker_symlink_alternating_recursion(void) {
int rv;
struct SqshArchive archive = {0};
uint8_t payload[] = {
/* clang-format off */
SQSH_HEADER,
/* inode */
[INODE_TABLE_OFFSET] = METABLOCK_HEADER(0, 1024),
INODE_HEADER(1, 0, 0, 0, 0, 1),
INODE_BASIC_DIR(0, 1024, 0, 0),
[INODE_TABLE_OFFSET+2+128] =
INODE_HEADER(3, 0, 0, 0, 0, 2),
INODE_BASIC_SYMLINK(4),
's', 'r', 'c', '2',
INODE_HEADER(3, 0, 0, 0, 0, 2),
INODE_BASIC_SYMLINK(4),
's', 'r', 'c', '1',
[DIRECTORY_TABLE_OFFSET] = METABLOCK_HEADER(0, 128),
DIRECTORY_HEADER(2, 0, 0),
DIRECTORY_ENTRY(128, 2, 3, 4),
's', 'r', 'c', '1',
DIRECTORY_ENTRY(128, 2, 3, 4),
's', 'r', 'c', '2',
[FRAGMENT_TABLE_OFFSET] = 0,
/* clang-format on */
};
mk_stub(&archive, payload, sizeof(payload));

struct SqshTreeWalker walker = {0};
rv = sqsh__tree_walker_init(&walker, &archive);
assert(rv == 0);

rv = sqsh_tree_walker_resolve(&walker, "src1", true);
assert(rv == -SQSH_ERROR_TOO_MANY_SYMLINKS_FOLLOWED);

sqsh__tree_walker_cleanup(&walker);
sqsh__archive_cleanup(&archive);

}

static void
walker_symlink_open(void) {
int rv;
Expand Down Expand Up @@ -241,6 +282,7 @@ walker_uninitialized_down(void) {
DECLARE_TESTS
TEST(walker_symlink_open)
TEST(walker_symlink_recursion)
TEST(walker_symlink_alternating_recursion)
TEST(walker_directory_enter)
TEST(walker_uninitialized_down)
TEST(walker_uninitialized_up)
Expand Down

0 comments on commit e6ce61b

Please sign in to comment.