From d4a92f49183b6ed23c31cd870a1c6822cca2d7b8 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 20 Feb 2015 19:07:19 +0100 Subject: [PATCH] Add additional regression test for streams --- .gitignore | 4 + Makefile.am | 13 ++- cmdline/mkstream.c | 213 +++++++++++++++++++++++++++++++++++++++++++++ cmdline/util.c | 2 + cmdline/util.h | 2 +- 5 files changed, 231 insertions(+), 3 deletions(-) create mode 100644 cmdline/mkstream.c diff --git a/.gitignore b/.gitignore index aeb8bd16..8f1d1cfb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,14 @@ # archives *.zip *.tar.gz +*.tgz # backups *~ # logs *.log +stream*.bin # autotools Makefile @@ -29,6 +31,7 @@ stamp-h1 # objects snapraid mktest +mkstream *.o *.gcda *.gcno @@ -46,4 +49,5 @@ paper/ kernel/ obj/ bench/ +support/ diff --git a/Makefile.am b/Makefile.am index 4e9c2095..cf47ccab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ bin_PROGRAMS = snapraid -check_PROGRAMS = mktest +check_PROGRAMS = mktest mkstream snapraid_SOURCES = \ raid/raid.c \ @@ -87,6 +87,13 @@ mktest_SOURCES = \ cmdline/mingw.c \ cmdline/support.c +mkstream_SOURCES = \ + cmdline/mkstream.c \ + cmdline/mingw.c \ + cmdline/support.c \ + cmdline/util.c \ + raid/memory.c + EXTRA_DIST = \ autogen.sh \ README AUTHORS HISTORY INSTALL COPYING TODO CHECK INSTALL.windows \ @@ -114,7 +121,7 @@ man_MANS = snapraid.1 clean-local: rm -f valgrind.log callgrind.log cachegrind.log rm -rf bench - rm -f test*.log output.log + rm -f test*.log output.log stream*.bin rm -f cmdline/*.gcda cmdline/*.gcno cmdline/*.gcov rm -f raid/*.gcda raid/*.gcno raid/*.gcov rm -f tommyds/*.gcda tommyds/*.gcno tommyds/*.gcov @@ -174,6 +181,8 @@ check-local: mkdir bench/disk5 mkdir bench/disk6 mkdir bench/pool + echo --- Stream + $(TESTENV) ./mkstream$(EXEEXT) echo --- Help $(TESTENV) ./snapraid$(EXEEXT) --test-skip-device -H $(TESTENV) ./snapraid$(EXEEXT) --test-skip-device -V diff --git a/cmdline/mkstream.c b/cmdline/mkstream.c new file mode 100644 index 00000000..ee72e79e --- /dev/null +++ b/cmdline/mkstream.c @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2015 Andrea Mazzoleni + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "portable.h" + +#include "support.h" +#include "util.h" + +#define STREAM_MAX 8 +#define BUFFER_MAX 64 +#define STR_MAX 128 + +void test(void) +{ + struct stream* s; + char file[32]; + unsigned char buffer[BUFFER_MAX]; + char str[STR_MAX]; + unsigned i, j; + uint32_t u32 = -1L; + uint64_t u64 = -1LL; + uint32_t crc_stored; + uint32_t crc_computed; + + crc32c_init(); + + s = sopen_multi_write(STREAM_MAX); + for (i = 0;i < STREAM_MAX; ++i) { + snprintf(file, sizeof(file), "stream%u.bin", i); + if (sopen_multi_file(s, i, file) != 0) { + /* LCOV_EXCL_START */ + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + } + + for(j=0;j<256;++j) { + if (sputc(j, s) != 0) { + /* LCOV_EXCL_START */ + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + } + + for(j=0;j<32;++j) { + if (sputb32(u32 >> j, s) != 0) { + /* LCOV_EXCL_START */ + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + } + + for(j=0;j<64;++j) { + if (sputb64(u64 >> j, s) != 0) { + /* LCOV_EXCL_START */ + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + } + + for(j=0;j> j)) { + /* LCOV_EXCL_START */ + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + } + + for(j=0;j<64;++j) { + uint64_t v64; + if (sgetb64(s, &v64) != 0 || v64 != (u64 >> j)) { + /* LCOV_EXCL_START */ + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + } + + for(j=1;j