diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/gensquashfs/Makemodule.am | 3 | ||||
-rw-r--r-- | bin/gensquashfs/test/fstree1.txt | 10 | ||||
-rw-r--r-- | bin/gensquashfs/test/fstree_from_file.c | 20 | ||||
-rw-r--r-- | bin/gensquashfs/test/sort_file.c | 63 |
4 files changed, 32 insertions, 64 deletions
diff --git a/bin/gensquashfs/Makemodule.am b/bin/gensquashfs/Makemodule.am index 0bb2122..2e14ff6 100644 --- a/bin/gensquashfs/Makemodule.am +++ b/bin/gensquashfs/Makemodule.am @@ -35,7 +35,6 @@ test_fstree_from_file_SOURCES = bin/gensquashfs/test/fstree_from_file.c \ bin/gensquashfs/src/mkfs.h test_fstree_from_file_CPPFLAGS = $(AM_CPPFLAGS) test_fstree_from_file_CPPFLAGS += -I$(top_srcdir)/bin/gensquashfs/src -test_fstree_from_file_CPPFLAGS += -DTESTPATH=$(GENDATADIR)/fstree1.txt test_fstree_from_file_LDADD = libcommon.a libfstree.a libio.a libutil.a \ libcompat.a @@ -74,6 +73,6 @@ noinst_PROGRAMS += fstree_fuzz check_PROGRAMS += $(GENSQUASHFS_TESTS) TESTS += $(GENSQUASHFS_TESTS) -EXTRA_DIST += $(GENDATADIR)/xattr1.txt $(GENDATADIR)/fstree1.txt +EXTRA_DIST += $(GENDATADIR)/xattr1.txt EXTRA_DIST += $(GENDATADIR)/fstree_glob1.txt $(GENDATADIR)/fstree_glob2.txt EXTRA_DIST += $(GENDATADIR)/fstree_glob3.txt diff --git a/bin/gensquashfs/test/fstree1.txt b/bin/gensquashfs/test/fstree1.txt deleted file mode 100644 index 95ee469..0000000 --- a/bin/gensquashfs/test/fstree1.txt +++ /dev/null @@ -1,10 +0,0 @@ -# comment line -slink /slink 0644 2 3 slinktarget -dir /dir 0755 4 5 -nod /chardev 0600 6 7 c 13 37 -nod /blkdev 0600 8 9 b 42 21 -pipe /pipe 0644 10 11 -dir / 0755 1000 100 -dir "/foo bar" 0755 0 0 -dir "/foo bar/ test \"/" 0755 0 0 - sock /sock 0555 12 13
\ No newline at end of file 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; diff --git a/bin/gensquashfs/test/sort_file.c b/bin/gensquashfs/test/sort_file.c index 8022cff..af50260 100644 --- a/bin/gensquashfs/test/sort_file.c +++ b/bin/gensquashfs/test/sort_file.c @@ -9,6 +9,7 @@ #include "sqfs/block.h" #include "util/test.h" #include "util/util.h" +#include "io/mem.h" #include "mkfs.h" static const char *listing = @@ -108,62 +109,23 @@ static int flags[] = { 0, }; -/*****************************************************************************/ - -static sqfs_u8 temp_buffer[2048]; -static const char *input_file = NULL; - -static void destroy_noop(sqfs_object_t *obj) -{ - (void)obj; -} - -static int memfile_load(istream_t *strm) -{ - strcpy((char *)temp_buffer, input_file); - strm->eof = true; - strm->buffer_used = strlen(input_file); - return 0; -} - -static const char *get_filename(istream_t *strm) -{ - (void)strm; - return "memstream"; -} - -static istream_t memstream = { - .base = { - .destroy = destroy_noop, - }, - - .buffer_used = 0, - .buffer_offset = 0, - .eof = false, - .buffer = temp_buffer, - - .precache = memfile_load, - .get_filename = get_filename, -}; - -/*****************************************************************************/ - int main(int argc, char **argv) { fstree_defaults_t fsd; + istream_t *memstream; tree_node_t *n; fstree_t fs; size_t i; (void)argc; (void)argv; - input_file = listing; - memstream.buffer_used = 0; - memstream.buffer_offset = 0; - memstream.eof = false; + memstream = istream_memory_create("listing.txt", 1024, + listing, strlen(listing)); + TEST_NOT_NULL(memstream); TEST_ASSERT(parse_fstree_defaults(&fsd, NULL) == 0); TEST_ASSERT(fstree_init(&fs, &fsd) == 0); - TEST_ASSERT(fstree_from_file_stream(&fs, &memstream, NULL) == 0); + TEST_ASSERT(fstree_from_file_stream(&fs, memstream, NULL) == 0); + sqfs_drop(memstream); fstree_post_process(&fs); @@ -186,12 +148,11 @@ int main(int argc, char **argv) TEST_EQUAL_UI(i, sizeof(initial_order) / sizeof(initial_order[0])); - input_file = sort_file; - memstream.buffer_used = 0; - memstream.buffer_offset = 0; - memstream.eof = false; - - TEST_ASSERT(fstree_sort_files(&fs, &memstream) == 0); + memstream = istream_memory_create("sortfile.txt", 1024, + sort_file, strlen(sort_file)); + TEST_NOT_NULL(memstream); + TEST_ASSERT(fstree_sort_files(&fs, memstream) == 0); + sqfs_drop(memstream); for (i = 0, n = fs.files; n != NULL; n = n->next_by_type, ++i) { char *path = fstree_get_path(n); |