aboutsummaryrefslogtreecommitdiff
path: root/lib/io/test
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-09-23 10:37:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-10-24 15:57:18 +0200
commit6e7b20a41c8a7f10392884e1741b031b579a93fa (patch)
tree1ed2c8c7d8db94da6fc8dbc73ad54d13e535344a /lib/io/test
parentb3c5de63c132f74f4e3592f2ff07e5172c5e295f (diff)
Cleanup: move memory/stdio streams to libcommon
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/test')
-rw-r--r--lib/io/test/istream_mem.c74
-rw-r--r--lib/io/test/xfrm.c2
2 files changed, 1 insertions, 75 deletions
diff --git a/lib/io/test/istream_mem.c b/lib/io/test/istream_mem.c
deleted file mode 100644
index d5e0c2c..0000000
--- a/lib/io/test/istream_mem.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * istream_mem.c
- *
- * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "util/test.h"
-#include "io/mem.h"
-#include "sqfs/io.h"
-
-static const size_t end0 = 449; /* region 1: filled with 'A' */
-static const size_t end1 = 521; /* region 2: filled with 'B' */
-static const size_t end2 = 941; /* region 3: filled with 'C' */
-
-static unsigned char data[941];
-
-static unsigned char byte_at_offset(size_t off)
-{
- if (off < end0)
- return 'A';
- if (off < end1)
- return 'B';
- return 'C';
-}
-
-static void init_buffer(void)
-{
- for (size_t i = 0; i < end2; ++i)
- data[i] = byte_at_offset(i);
-}
-
-int main(int argc, char **argv)
-{
- size_t i, diff, size;
- bool eat_all = true;
- const sqfs_u8 *ptr;
- sqfs_istream_t *in;
- int ret;
- (void)argc; (void)argv;
-
- init_buffer();
-
- in = istream_memory_create("memstream.txt", 61, data, sizeof(data));
- TEST_NOT_NULL(in);
- TEST_EQUAL_UI(((sqfs_object_t *)in)->refcount, 1);
-
- TEST_STR_EQUAL(in->get_filename(in), "memstream.txt");
-
- for (i = 0; i < end2; i += diff) {
- ret = in->get_buffered_data(in, &ptr, &size, 61);
- TEST_EQUAL_I(ret, 0);
-
- if ((end2 - i) >= 61) {
- TEST_NOT_NULL(ptr);
- TEST_EQUAL_UI(size, 61);
- } else {
- TEST_NOT_NULL(ptr);
- TEST_EQUAL_UI(size, (end2 - i));
- }
-
- for (size_t j = 0; j < size; ++j) {
- TEST_EQUAL_UI(ptr[j], byte_at_offset(i + j));
- }
-
- diff = eat_all ? size : (size / 2);
- eat_all = !eat_all;
- in->advance_buffer(in, diff);
- }
-
- sqfs_drop(in);
- return EXIT_SUCCESS;
-}
diff --git a/lib/io/test/xfrm.c b/lib/io/test/xfrm.c
index b871610..26eee87 100644
--- a/lib/io/test/xfrm.c
+++ b/lib/io/test/xfrm.c
@@ -9,7 +9,7 @@
#include "util/test.h"
#include "sqfs/io.h"
#include "io/xfrm.h"
-#include "io/mem.h"
+#include "common.h"
static const sqfs_u8 blob_in[] = {
#if defined(DO_XZ)