/* * 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 "stream.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