diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-02 17:42:30 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-03 23:36:14 +0200 |
commit | 061fbc12fe49ff49088a644def3227d3800cd8a7 (patch) | |
tree | a9390a1c0610b3a93dddb7882956f1cb9a9ea37c /bin/gensquashfs/test/fstree_from_file.c | |
parent | 3f7f3654d243275332d964f9ecbb79f9eb83a5d1 (diff) |
libio: consolidate add-hoc memory istream_t implementations
In several places, there are ad-hoc istream_t implementations that
read from a memory buffer to test something else stacked on top.
This commit consolidates those ad-hoc implmentations into a proper
one in libio, and uses the chance to remove external files for some
older tests that rely on file I/O instead.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/test/fstree_from_file.c')
-rw-r--r-- | bin/gensquashfs/test/fstree_from_file.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/bin/gensquashfs/test/fstree_from_file.c b/bin/gensquashfs/test/fstree_from_file.c index 03591d5..e54111c 100644 --- a/bin/gensquashfs/test/fstree_from_file.c +++ b/bin/gensquashfs/test/fstree_from_file.c @@ -7,18 +7,36 @@ #include "config.h" #include "util/test.h" +#include "io/mem.h" #include "mkfs.h" +const char *listing = +"# comment line\n" +"slink /slink 0644 2 3 slinktarget\n" +"dir /dir 0755 4 5\n" +"nod /chardev 0600 6 7 c 13 37\n" +"nod /blkdev 0600 8 9 b 42 21\n" +"pipe /pipe 0644 10 11\n" +"dir / 0755 1000 100\n" +"dir \"/foo bar\" 0755 0 0\n" +"dir \"/foo bar/ test \\\"/\" 0755 0 0\n" +" sock /sock 0555 12 13 "; + int main(int argc, char **argv) { fstree_defaults_t fsd; + istream_t *file; tree_node_t *n; fstree_t fs; (void)argc; (void)argv; + file = istream_memory_create("memfile", 7, listing, strlen(listing)); + TEST_NOT_NULL(file); + TEST_ASSERT(parse_fstree_defaults(&fsd, NULL) == 0); TEST_ASSERT(fstree_init(&fs, &fsd) == 0); - TEST_ASSERT(fstree_from_file(&fs, TEST_PATH, NULL) == 0); + TEST_ASSERT(fstree_from_file_stream(&fs, file, NULL) == 0); + sqfs_drop(file); fstree_post_process(&fs); n = fs.root->data.children; |