Skip to content

Commit

Permalink
test: add test trying to set a file as cwd.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed May 28, 2024
1 parent b1c0343 commit cef26e5
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/libsqsh/tree/path_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,45 @@ UTEST(path_resolver, resolver_inconsistent_file_type) {
sqsh__archive_cleanup(&archive);
}

UTEST(path_resolver, resolver_file_enter) {
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(2, 0, 0, 0, 0, 3),
INODE_BASIC_FILE(0, 0xFFFFFFFF, 0, 0),

[DIRECTORY_TABLE_OFFSET] = METABLOCK_HEADER(0, 128),
DIRECTORY_HEADER(1, 0, 0),
DIRECTORY_ENTRY(128, 2, 2, 4),
'f', 'i', 'l', 'e',

[FRAGMENT_TABLE_OFFSET] = 0,
/* clang-format on */
};
mk_stub(&archive, payload, sizeof(payload));

struct SqshPathResolver resolver = {0};
rv = sqsh__path_resolver_init(&resolver, &archive);
ASSERT_EQ(0, rv);

rv = sqsh_path_resolver_to_root(&resolver);
ASSERT_EQ(0, rv);

rv = sqsh_path_resolver_resolve(&resolver, "file/", true);
ASSERT_EQ(-SQSH_ERROR_NOT_A_DIRECTORY, rv);

sqsh__path_resolver_cleanup(&resolver);
sqsh__archive_cleanup(&archive);
}

UTEST(path_resolver, resolver_directory_enter) {
int rv;
struct SqshArchive archive = {0};
Expand Down

0 comments on commit cef26e5

Please sign in to comment.