From 061fbc12fe49ff49088a644def3227d3800cd8a7 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 2 Jun 2023 17:42:30 +0200 Subject: 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 --- bin/gensquashfs/test/fstree_from_file.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'bin/gensquashfs/test/fstree_from_file.c') 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; -- cgit v1.2.3