LCOV - code coverage report
Current view: top level - cmdline - selftest.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 114 130 87.7 %
Date: 2015-05-12 Functions: 7 7 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2011 Andrea Mazzoleni
       3             :  *
       4             :  * This program is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 3 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * This program is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "portable.h"
      19             : 
      20             : #include "snapraid.h"
      21             : #include "util.h"
      22             : #include "raid/raid.h"
      23             : #include "raid/cpu.h"
      24             : #include "raid/combo.h"
      25             : #include "raid/internal.h"
      26             : #include "raid/test.h"
      27             : #include "elem.h"
      28             : #include "state.h"
      29             : #include "support.h"
      30             : #include "tommyds/tommyhash.h"
      31             : #include "tommyds/tommyarray.h"
      32             : #include "tommyds/tommyarrayblk.h"
      33             : #include "tommyds/tommyarrayblkof.h"
      34             : #include "tommyds/tommyhashdyn.h"
      35             : 
      36             : struct hash32_test_vector {
      37             :         const char* data;
      38             :         int len;
      39             :         uint32_t digest;
      40             : };
      41             : 
      42             : struct hash64_test_vector {
      43             :         const char* data;
      44             :         int len;
      45             :         uint64_t digest;
      46             : };
      47             : 
      48             : struct hash_test_vector {
      49             :         const char* data;
      50             :         int len;
      51             :         unsigned char digest[HASH_SIZE];
      52             : };
      53             : 
      54             : /**
      55             :  * Test vectors for tommy_hash32
      56             :  */
      57             : static struct hash32_test_vector TEST_HASH32[] = {
      58             :         { "", 0, 0x8614384c },
      59             :         { "a", 1, 0x12c16c36 },
      60             :         { "abc", 3, 0xc58e8af5 },
      61             :         { "message digest", 14, 0x006b32f1 },
      62             :         { "abcdefghijklmnopqrstuvwxyz", 26, 0x7e6fcfe0 },
      63             :         { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x8604adf8 },
      64             :         { "The quick brown fox jumps over the lazy dog", 43, 0xdeba3d3a },
      65             :         { "\x00", 1, 0x4a7d1c33 },
      66             :         { "\x16\x27", 2, 0x8b50899b },
      67             :         { "\xe2\x56\xb4", 3, 0x60406493 },
      68             :         { "\xc9\x4d\x9c\xda", 4, 0xa049144a },
      69             :         { "\x79\xf1\x29\x69\x5d", 5, 0x4da2c2f1 },
      70             :         { "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x59de30cf },
      71             :         { "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x219e149c },
      72             :         { "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x25067520 },
      73             :         { "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0xa1f368d8 },
      74             :         { "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x805fc63d },
      75             :         { "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0x7f75dd0f },
      76             :         { "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0xb9154382 },
      77             :         { 0, 0, 0 }
      78             : };
      79             : 
      80             : /**
      81             :  * Test vectors for tommy_hash64
      82             :  */
      83             : static struct hash64_test_vector TEST_HASH64[] = {
      84             :         { "", 0, 0x8614384cb5165fbfULL },
      85             :         { "a", 1, 0x1a2e0298a8e94a3dULL },
      86             :         { "abc", 3, 0x7555796b7a7d21ebULL },
      87             :         { "message digest", 14, 0x9411a57d04b92fb4ULL },
      88             :         { "abcdefghijklmnopqrstuvwxyz", 26, 0x3ca3f8d2b4e69832ULL },
      89             :         { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x6dae542ba0015a4dULL },
      90             :         { "The quick brown fox jumps over the lazy dog", 43, 0xe06d8cbb3d2ea1a6ULL },
      91             :         { "\x00", 1, 0x201e664fb5f2c021ULL },
      92             :         { "\x16\x27", 2, 0xef42fa8032c4b775ULL },
      93             :         { "\xe2\x56\xb4", 3, 0x6e6c498a6688466cULL },
      94             :         { "\xc9\x4d\x9c\xda", 4, 0x5195005419905423ULL },
      95             :         { "\x79\xf1\x29\x69\x5d", 5, 0x221235b48afee7c1ULL },
      96             :         { "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x1b1f18b9266f095bULL },
      97             :         { "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x2cbafa8e741d49caULL },
      98             :         { "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x4677f04c06e0758dULL },
      99             :         { "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0x5afe09e8214e2163ULL },
     100             :         { "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x115b6276d209fab6ULL },
     101             :         { "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0xd0636d2f01cf3a3eULL },
     102             :         { "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0x6d259f5fef74f93eULL },
     103             :         { 0, 0, 0 }
     104             : };
     105             : 
     106             : /**
     107             :  * Test vectors for MurmorHash3_x86_128
     108             :  */
     109             : static struct hash_test_vector TEST_MURMUR3[] = {
     110             : #include "murmur3test.c"
     111             :         { 0, 0, { 0 } }
     112             : };
     113             : 
     114             : /**
     115             :  * Test vectors for SpookyHash_128
     116             :  */
     117             : static struct hash_test_vector TEST_SPOOKY2[] = {
     118             : #include "spooky2test.c"
     119             :         { 0, 0, { 0 } }
     120             : };
     121             : 
     122             : #define HASH_TEST_MAX 512 /* tests are never longer than 512 bytes */
     123             : 
     124           1 : static void test_hash(void)
     125             : {
     126             :         unsigned i;
     127             :         unsigned char* seed_aligned;
     128             :         void* seed_alloc;
     129             :         unsigned char* buffer_aligned;
     130             :         void* buffer_alloc;
     131             :         uint32_t seed32;
     132             :         uint64_t seed64;
     133             : 
     134           1 :         seed_aligned = malloc_nofail_align(HASH_SIZE, &seed_alloc);
     135           1 :         buffer_aligned = malloc_nofail_align(HASH_TEST_MAX, &buffer_alloc);
     136             : 
     137           1 :         seed32 = 0xa766795d;
     138           1 :         seed64 = 0x2f022773a766795dULL;
     139             : 
     140           1 :         seed_aligned[0] = 0x5d;
     141           1 :         seed_aligned[1] = 0x79;
     142           1 :         seed_aligned[2] = 0x66;
     143           1 :         seed_aligned[3] = 0xa7;
     144           1 :         seed_aligned[4] = 0x73;
     145           1 :         seed_aligned[5] = 0x27;
     146           1 :         seed_aligned[6] = 0x02;
     147           1 :         seed_aligned[7] = 0x2f;
     148           1 :         seed_aligned[8] = 0x6a;
     149           1 :         seed_aligned[9] = 0xa1;
     150           1 :         seed_aligned[10] = 0x9e;
     151           1 :         seed_aligned[11] = 0xc1;
     152           1 :         seed_aligned[12] = 0x14;
     153           1 :         seed_aligned[13] = 0x8c;
     154           1 :         seed_aligned[14] = 0x9e;
     155           1 :         seed_aligned[15] = 0x43;
     156             : 
     157          20 :         for (i = 0; TEST_HASH32[i].data; ++i) {
     158             :                 uint32_t digest;
     159          19 :                 memcpy(buffer_aligned, TEST_HASH32[i].data, TEST_HASH32[i].len);
     160          19 :                 digest = tommy_hash_u32(seed32, buffer_aligned, TEST_MURMUR3[i].len);
     161          19 :                 if (digest != TEST_HASH32[i].digest) {
     162             :                         /* LCOV_EXCL_START */
     163             :                         log_fatal("Failed hash32 test\n");
     164             :                         exit(EXIT_FAILURE);
     165             :                         /* LCOV_EXCL_STOP */
     166             :                 }
     167             :         }
     168             : 
     169          20 :         for (i = 0; TEST_HASH64[i].data; ++i) {
     170             :                 uint64_t digest;
     171          19 :                 memcpy(buffer_aligned, TEST_HASH64[i].data, TEST_HASH64[i].len);
     172          19 :                 digest = tommy_hash_u64(seed64, buffer_aligned, TEST_MURMUR3[i].len);
     173          19 :                 if (digest != TEST_HASH64[i].digest) {
     174             :                         /* LCOV_EXCL_START */
     175             :                         log_fatal("Failed hash64 test\n");
     176             :                         exit(EXIT_FAILURE);
     177             :                         /* LCOV_EXCL_STOP */
     178             :                 }
     179             :         }
     180             : 
     181             : 
     182         264 :         for (i = 0; TEST_MURMUR3[i].data; ++i) {
     183             :                 unsigned char digest[HASH_SIZE];
     184         263 :                 memcpy(buffer_aligned, TEST_MURMUR3[i].data, TEST_MURMUR3[i].len);
     185         263 :                 memhash(HASH_MURMUR3, seed_aligned, digest, buffer_aligned, TEST_MURMUR3[i].len);
     186         263 :                 if (memcmp(digest, TEST_MURMUR3[i].digest, HASH_SIZE) != 0) {
     187             :                         /* LCOV_EXCL_START */
     188             :                         log_fatal("Failed Murmur3 test\n");
     189             :                         exit(EXIT_FAILURE);
     190             :                         /* LCOV_EXCL_STOP */
     191             :                 }
     192             :         }
     193             : 
     194         264 :         for (i = 0; TEST_SPOOKY2[i].data; ++i) {
     195             :                 unsigned char digest[HASH_SIZE];
     196         263 :                 memcpy(buffer_aligned, TEST_SPOOKY2[i].data, TEST_SPOOKY2[i].len);
     197         263 :                 memhash(HASH_SPOOKY2, seed_aligned, digest, buffer_aligned, TEST_SPOOKY2[i].len);
     198         263 :                 if (memcmp(digest, TEST_SPOOKY2[i].digest, HASH_SIZE) != 0) {
     199             :                         /* LCOV_EXCL_START */
     200             :                         log_fatal("Failed Spooky2 test\n");
     201             :                         exit(EXIT_FAILURE);
     202             :                         /* LCOV_EXCL_STOP */
     203             :                 }
     204             :         }
     205             : 
     206           1 :         free(buffer_alloc);
     207           1 :         free(seed_alloc);
     208           1 : }
     209             : 
     210             : struct crc_test_vector {
     211             :         const char* data;
     212             :         int len;
     213             :         uint32_t digest;
     214             : };
     215             : 
     216             : /**
     217             :  * Test vectors for CRC32C (Castagnoli)
     218             :  */
     219             : static struct crc_test_vector TEST_CRC32C[] = {
     220             :         { "", 0, 0 },
     221             :         { "\x61", 1, 0xc1d04330 },
     222             :         { "\x66\x6f\x6f", 3, 0xcfc4ae1d },
     223             :         { "\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64", 11, 0xc99465aa },
     224             :         { "\x68\x65\x6c\x6c\x6f\x20", 6, 0x7e627e58 },
     225             :         { "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 32, 0x8a9136aa },
     226             :         { "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 32, 0x62a8ab43 },
     227             :         { "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08\x07\x06\x05\x04\x03\x02\x01\x00", 32, 0x113fdb5c },
     228             :         { "\x01\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x14\x00\x00\x00\x18\x28\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", 48, 0xd9963a56 },
     229             :         { "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 32, 0x46dd794e },
     230             :         { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28", 40, 0x0e2c157f },
     231             :         { "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50", 40, 0xe980ebf6 },
     232             :         { "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78", 40, 0xde74bded },
     233             :         { "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0", 40, 0xd579c862 },
     234             :         { "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8", 40, 0xba979ad0 },
     235             :         { "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0", 40, 0x2b29d913 },
     236             :         { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0", 240, 0x24c5d375 },
     237             :         { 0, 0, 0 }
     238             : };
     239             : 
     240           1 : static void test_crc32c(void)
     241             : {
     242             :         unsigned i;
     243             : 
     244          18 :         for (i = 0; TEST_CRC32C[i].data; ++i) {
     245             :                 uint32_t digest;
     246          17 :                 digest = crc32c(0, (const unsigned char*)TEST_CRC32C[i].data, TEST_CRC32C[i].len);
     247          17 :                 if (digest != TEST_CRC32C[i].digest) {
     248             :                         /* LCOV_EXCL_START */
     249             :                         log_fatal("Failed CRC32C test\n");
     250             :                         exit(EXIT_FAILURE);
     251             :                         /* LCOV_EXCL_STOP */
     252             :                 }
     253             :         }
     254           1 : }
     255             : 
     256             : /**
     257             :  * Size of tommy data structures.
     258             :  */
     259             : #define TOMMY_SIZE 256
     260             : 
     261         384 : static int tommy_test_search(const void* arg, const void* obj)
     262             : {
     263         384 :         return arg != obj;
     264             : }
     265             : 
     266             : static unsigned tommy_test_foreach_count;
     267             : 
     268         256 : static void tommy_test_foreach(void* obj)
     269             : {
     270             :         (void)obj;
     271             : 
     272         256 :         ++tommy_test_foreach_count;
     273         256 : }
     274             : 
     275         256 : static void tommy_test_foreach_arg(void* void_arg, void* obj)
     276             : {
     277         256 :         unsigned* arg = void_arg;
     278             : 
     279             :         (void)obj;
     280             : 
     281         256 :         ++*arg;
     282         256 : }
     283             : 
     284           1 : static void test_tommy(void)
     285             : {
     286             :         tommy_array array;
     287             :         tommy_arrayblk arrayblk;
     288             :         tommy_arrayblkof arrayblkof;
     289             :         tommy_list list;
     290             :         tommy_hashdyn hashdyn;
     291             :         tommy_hashdyn_node node[TOMMY_SIZE];
     292             :         unsigned i;
     293             : 
     294           1 :         tommy_array_init(&array);
     295           1 :         tommy_arrayblk_init(&arrayblk);
     296           1 :         tommy_arrayblkof_init(&arrayblkof, sizeof(unsigned));
     297             : 
     298         257 :         for (i = 0; i < TOMMY_SIZE; ++i) {
     299         256 :                 tommy_array_insert(&array, &node[i]);
     300         256 :                 tommy_arrayblk_insert(&arrayblk, &node[i]);
     301         256 :                 tommy_arrayblkof_grow(&arrayblkof, i + 1);
     302         256 :                 *(unsigned*)tommy_arrayblkof_ref(&arrayblkof, i) = i;
     303             :         }
     304             : 
     305           1 :         if (tommy_array_memory_usage(&array) < TOMMY_SIZE * sizeof(void*))
     306           0 :                 goto bail;
     307           1 :         if (tommy_arrayblk_memory_usage(&arrayblk) < TOMMY_SIZE * sizeof(void*))
     308           0 :                 goto bail;
     309           1 :         if (tommy_arrayblkof_memory_usage(&arrayblkof) < TOMMY_SIZE * sizeof(unsigned))
     310           0 :                 goto bail;
     311             : 
     312         257 :         for (i = 0; i < TOMMY_SIZE; ++i) {
     313         256 :                 if (tommy_array_get(&array, i) != &node[i])
     314           0 :                         goto bail;
     315         256 :                 if (tommy_arrayblk_get(&arrayblk, i) != &node[i])
     316           0 :                         goto bail;
     317         256 :                 if (*(unsigned*)tommy_arrayblkof_ref(&arrayblkof, i) != i)
     318           0 :                         goto bail;
     319             :         }
     320             : 
     321           1 :         tommy_arrayblkof_done(&arrayblkof);
     322           1 :         tommy_arrayblk_done(&arrayblk);
     323           1 :         tommy_array_done(&array);
     324             : 
     325           1 :         tommy_list_init(&list);
     326             : 
     327           1 :         if (!tommy_list_empty(&list))
     328           0 :                 goto bail;
     329             : 
     330           1 :         if (tommy_list_tail(&list))
     331           0 :                 goto bail;
     332             : 
     333           1 :         if (tommy_list_head(&list))
     334           0 :                 goto bail;
     335             : 
     336           1 :         tommy_hashdyn_init(&hashdyn);
     337             : 
     338         257 :         for (i = 0; i < TOMMY_SIZE; ++i)
     339         256 :                 tommy_hashdyn_insert(&hashdyn, &node[i], &node[i], i % 64);
     340             : 
     341           1 :         if (tommy_hashdyn_count(&hashdyn) != TOMMY_SIZE)
     342           0 :                 goto bail;
     343             : 
     344           1 :         if (tommy_hashdyn_memory_usage(&hashdyn) < TOMMY_SIZE * sizeof(void*))
     345           0 :                 goto bail;
     346             : 
     347           1 :         tommy_test_foreach_count = 0;
     348           1 :         tommy_hashdyn_foreach(&hashdyn, tommy_test_foreach);
     349           1 :         if (tommy_test_foreach_count != TOMMY_SIZE)
     350           0 :                 goto bail;
     351             : 
     352           1 :         tommy_test_foreach_count = 0;
     353           1 :         tommy_hashdyn_foreach_arg(&hashdyn, tommy_test_foreach_arg, &tommy_test_foreach_count);
     354           1 :         if (tommy_test_foreach_count != TOMMY_SIZE)
     355           0 :                 goto bail;
     356             : 
     357         129 :         for (i = 0; i < TOMMY_SIZE / 2; ++i)
     358         128 :                 tommy_hashdyn_remove_existing(&hashdyn, &node[i]);
     359             : 
     360         129 :         for (i = 0; i < TOMMY_SIZE / 2; ++i)
     361         128 :                 if (tommy_hashdyn_remove(&hashdyn, tommy_test_search, &node[i], i % 64) != 0)
     362           0 :                         goto bail;
     363             : 
     364         129 :         for (i = TOMMY_SIZE / 2; i < TOMMY_SIZE; ++i)
     365         128 :                 if (tommy_hashdyn_remove(&hashdyn, tommy_test_search, &node[i], i % 64) == 0)
     366           0 :                         goto bail;
     367             : 
     368           1 :         if (tommy_hashdyn_count(&hashdyn) != 0)
     369           0 :                 goto bail;
     370             : 
     371           1 :         tommy_hashdyn_done(&hashdyn);
     372             : 
     373           1 :         return;
     374             : bail:
     375             :         /* LCOV_EXCL_START */
     376             :         log_fatal("Failed tommy test\n");
     377             :         exit(EXIT_FAILURE);
     378             :         /* LCOV_EXCL_STOP */
     379             : }
     380             : 
     381           1 : void selftest(void)
     382             : {
     383           1 :         log_tag("selftest:\n");
     384           1 :         log_flush();
     385             : 
     386           1 :         msg_progress("Self test...\n");
     387             : 
     388             :         /* large file check */
     389             :         if (sizeof(off_t) < sizeof(uint64_t)) {
     390             :                 /* LCOV_EXCL_START */
     391             :                 log_fatal("Missing support for large files\n");
     392             :                 exit(EXIT_FAILURE);
     393             :                 /* LCOV_EXCL_STOP */
     394             :         }
     395             : 
     396           1 :         test_hash();
     397           1 :         test_crc32c();
     398           1 :         test_tommy();
     399           1 :         if (raid_selftest() != 0) {
     400             :                 /* LCOV_EXCL_START */
     401             :                 log_fatal("Failed SELF test\n");
     402             :                 exit(EXIT_FAILURE);
     403             :                 /* LCOV_EXCL_STOP */
     404             :         }
     405           1 :         if (raid_test_sort() != 0) {
     406             :                 /* LCOV_EXCL_START */
     407             :                 log_fatal("Failed SORT test\n");
     408             :                 exit(EXIT_FAILURE);
     409             :                 /* LCOV_EXCL_STOP */
     410             :         }
     411           1 :         if (raid_test_insert() != 0) {
     412             :                 /* LCOV_EXCL_START */
     413             :                 log_fatal("Failed INSERT test\n");
     414             :                 exit(EXIT_FAILURE);
     415             :                 /* LCOV_EXCL_STOP */
     416             :         }
     417           1 :         if (raid_test_combo() != 0) {
     418             :                 /* LCOV_EXCL_START */
     419             :                 log_fatal("Failed COMBO test\n");
     420             :                 exit(EXIT_FAILURE);
     421             :                 /* LCOV_EXCL_STOP */
     422             :         }
     423           1 :         if (raid_test_par(RAID_MODE_VANDERMONDE, 32, 256) != 0) {
     424             :                 /* LCOV_EXCL_START */
     425             :                 log_fatal("Failed GEN Vandermonde test\n");
     426             :                 exit(EXIT_FAILURE);
     427             :                 /* LCOV_EXCL_STOP */
     428             :         }
     429           1 :         if (raid_test_rec(RAID_MODE_VANDERMONDE, 12, 256) != 0) {
     430             :                 /* LCOV_EXCL_START */
     431             :                 log_fatal("Failed REC Vandermonde test\n");
     432             :                 exit(EXIT_FAILURE);
     433             :                 /* LCOV_EXCL_STOP */
     434             :         }
     435           1 :         if (raid_test_par(RAID_MODE_CAUCHY, 32, 256) != 0) {
     436             :                 /* LCOV_EXCL_START */
     437             :                 log_fatal("Failed GEN Cauchy test\n");
     438             :                 exit(EXIT_FAILURE);
     439             :                 /* LCOV_EXCL_STOP */
     440             :         }
     441           1 :         if (raid_test_rec(RAID_MODE_CAUCHY, 12, 256) != 0) {
     442             :                 /* LCOV_EXCL_START */
     443             :                 log_fatal("Failed REC Cauchy test\n");
     444             :                 exit(EXIT_FAILURE);
     445             :                 /* LCOV_EXCL_STOP */
     446             :         }
     447           1 :         if (raid_test_par(RAID_MODE_CAUCHY, 1, 256) != 0) {
     448             :                 /* LCOV_EXCL_START */
     449             :                 log_fatal("Failed GEN Cauchy test sigle data disk\n");
     450             :                 exit(EXIT_FAILURE);
     451             :                 /* LCOV_EXCL_STOP */
     452             :         }
     453           1 : }
     454             : 

Generated by: LCOV version 1.10