From 3087470d0e903f0750424649f0a440dfb1ff48a3 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 21 Sep 2019 17:18:42 +0200 Subject: Remove block processor ordering test Signed-off-by: David Oberhollenzer --- tests/Makemodule.am | 11 +---- tests/blk_proc_order.c | 132 ------------------------------------------------- 2 files changed, 1 insertion(+), 142 deletions(-) delete mode 100644 tests/blk_proc_order.c diff --git a/tests/Makemodule.am b/tests/Makemodule.am index b242bd2..37e5d48 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -73,14 +73,6 @@ test_str_table_SOURCES = tests/str_table.c test_str_table_LDADD = libutil.la test_str_table_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests -test_blk_proc_order_SOURCES = tests/blk_proc_order.c -test_blk_proc_order_CPPFLAGS = $(AM_CPPFLAGS) -test_blk_proc_order_LDADD = libsquashfs.la libutil.la - -if HAVE_PTHREAD -test_blk_proc_order_CPPFLAGS += -DHAVE_PTHREAD -endif - fstree_fuzz_SOURCES = tests/fstree_fuzz.c fstree_fuzz_LDADD = libfstree.a libutil.la @@ -94,7 +86,6 @@ check_PROGRAMS += test_fstree_from_file test_fstree_init test_fstree_xattr check_PROGRAMS += test_tar_ustar test_tar_pax test_tar_gnu test_tar_sparse_gnu check_PROGRAMS += test_tar_sparse_gnu1 test_tar_sparse_gnu2 check_PROGRAMS += test_tar_xattr_bsd test_tar_xattr_schily test_str_table -check_PROGRAMS += test_blk_proc_order noinst_PROGRAMS += fstree_fuzz tar_fuzz @@ -104,6 +95,6 @@ TESTS += test_add_by_path test_get_path test_fstree_sort test_fstree_from_file TESTS += test_fstree_init test_fstree_xattr test_tar_ustar test_tar_pax TESTS += test_tar_gnu test_tar_sparse_gnu test_tar_sparse_gnu1 TESTS += test_tar_sparse_gnu2 test_tar_xattr_bsd test_tar_xattr_schily -TESTS += test_str_table test_blk_proc_order +TESTS += test_str_table EXTRA_DIST += $(top_srcdir)/tests/tar $(top_srcdir)/tests/words.txt diff --git a/tests/blk_proc_order.c b/tests/blk_proc_order.c deleted file mode 100644 index 18ea54d..0000000 --- a/tests/blk_proc_order.c +++ /dev/null @@ -1,132 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * add_by_path.c - * - * Copyright (C) 2019 David Oberhollenzer - */ -#include "config.h" - -#include "sqfs/block_processor.h" -#include "sqfs/compress.h" - -#include -#include -#include -#include - -#ifdef HAVE_PTHREAD -#include -#endif - -static ssize_t dummy_do_block(sqfs_compressor_t *cmp, const uint8_t *in, - size_t size, uint8_t *out, size_t outsize) -{ - int delay, result; - (void)cmp; (void)size; (void)outsize; - - delay = ((int *)in)[0]; - result = ((int *)in)[1]; - - memcpy(out, in, result); - sleep(delay); - return (size_t)result >= size ? 0 : result; -} - -static sqfs_compressor_t *dummy_create_copy(sqfs_compressor_t *cmp) -{ - sqfs_compressor_t *cpy = malloc(sizeof(*cpy)); - assert(cpy != NULL); - *cpy = *cmp; - return cpy; -} - -static void dummy_destroy(sqfs_compressor_t *cmp) -{ - free(cmp); -} - -static sqfs_compressor_t *dummy_create(void) -{ - sqfs_compressor_t *cmp = calloc(1, sizeof(*cmp)); - assert(cmp != NULL); - - cmp->do_block = dummy_do_block; - cmp->create_copy = dummy_create_copy; - cmp->destroy = dummy_destroy; - - return cmp; -} - -static unsigned int blk_index = 0; - -#ifdef HAVE_PTHREAD -static pthread_t main_thread; -#endif - -static int block_callback(void *user, sqfs_block_t *blk) -{ -#ifdef HAVE_PTHREAD - assert(main_thread == pthread_self()); -#endif - assert(blk->index == blk_index++); - - if (blk->index == 4) { - assert(blk->size == 4 * sizeof(int)); - assert(blk->flags & SQFS_BLK_DONT_COMPRESS); - assert(blk->flags & SQFS_BLK_DONT_CHECKSUM); - assert(!(blk->flags & SQFS_BLK_IS_COMPRESSED)); - } else { - if (blk->index & 0x01) { - assert(!(blk->flags & SQFS_BLK_IS_COMPRESSED)); - assert(blk->size == 4 * sizeof(int)); - } else { - assert(blk->flags & SQFS_BLK_IS_COMPRESSED); - assert(blk->size == 2 * sizeof(int)); - } - } - - (void)user; - return 0; -} - -int main(void) -{ - sqfs_compressor_t *cmp = dummy_create(); - sqfs_block_processor_t *proc; - sqfs_block_t *blk; - int i; - -#ifdef HAVE_PTHREAD - main_thread = pthread_self(); -#endif - - proc = sqfs_block_processor_create(4 * sizeof(int), cmp, 4, 10, - NULL, block_callback); - assert(proc != NULL); - - for (i = 0; i < 4; ++i) { - blk = calloc(1, sizeof(*blk) + 4 * sizeof(int)); - assert(blk != NULL); - blk->size = 4 * sizeof(int); - blk->index = i; - ((int *)blk->data)[0] = 4 - i; - ((int *)blk->data)[1] = (i & 0x01 ? 4 : 2) * sizeof(int); - - assert(sqfs_block_processor_enqueue(proc, blk) == 0); - } - - blk = calloc(1, sizeof(*blk) + 4 * sizeof(int)); - assert(blk != NULL); - blk->size = 4 * sizeof(int); - blk->index = i; - blk->flags |= SQFS_BLK_DONT_COMPRESS | SQFS_BLK_DONT_CHECKSUM; - ((int *)blk->data)[0] = 0; - ((int *)blk->data)[1] = (i & 0x01 ? 4 : 2) * sizeof(int); - assert(sqfs_block_processor_enqueue(proc, blk) == 0); - - assert(sqfs_block_processor_finish(proc) == 0); - - sqfs_block_processor_destroy(proc); - cmp->destroy(cmp); - return EXIT_SUCCESS; -} -- cgit v1.2.3