Extend selftest and fulltest with disk edge cases, polynomial checks, and comments

This commit is contained in:
Andrea Mazzoleni 2026-08-25 10:59:33 +02:00
parent f85c014c1c
commit 697ab3056e
2 changed files with 169 additions and 15 deletions

View file

@ -1112,20 +1112,39 @@ void selftest(void)
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* utilities and low-level helpers */
if (util_selftest() != 0) { if (util_selftest() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed UTIL test\n"); log_fatal(EINTERNAL, "Failed UTIL test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* non-cryptographic hash functions (murmur3, spooky2, museair) */
test_hash(); test_hash();
/* hardware and software crc32c */
test_crc32c(); test_crc32c();
/* split parity layout and size calculations */
test_parity(); test_parity();
/* tommyds data structures (hash tables, lists, search, sort) */
test_tommy(); test_tommy();
/* buffered streaming i/o and crc verification */
test_stream(); test_stream();
/* wildcard and path pattern matching */
test_wnmatch(); test_wnmatch();
/* smartctl output parsing */
test_parse_smartctl(); test_parse_smartctl();
/* smart attribute ignore rules */
test_smart_ignore(); test_smart_ignore();
/* cauchy raid module self-test */
raid_mode(RAID_MODE_CAUCHY_RAID); raid_mode(RAID_MODE_CAUCHY_RAID);
if (raid_selftest() != 0) { if (raid_selftest() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -1133,6 +1152,8 @@ void selftest(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy aes module self-test */
raid_mode(RAID_MODE_CAUCHY_AES); raid_mode(RAID_MODE_CAUCHY_AES);
if (raid_selftest() != 0) { if (raid_selftest() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -1140,6 +1161,8 @@ void selftest(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* vandermonde raid module self-test */
raid_mode(RAID_MODE_VANDERMONDE_RAID); raid_mode(RAID_MODE_VANDERMONDE_RAID);
if (raid_selftest() != 0) { if (raid_selftest() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -1147,96 +1170,168 @@ void selftest(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* array sorting helper */
if (raid_test_sort() != 0) { if (raid_test_sort() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed SORT test\n"); log_fatal(EINTERNAL, "Failed SORT test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* sorted array insertion helper */
if (raid_test_insert() != 0) { if (raid_test_insert() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed INSERT test\n"); log_fatal(EINTERNAL, "Failed INSERT test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* permutation and combination generators */
if (raid_test_combo() != 0) { if (raid_test_combo() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed COMBO test\n"); log_fatal(EINTERNAL, "Failed COMBO test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* gfni affine transformation matrices */
if (raid_test_gfaffine() != 0) { if (raid_test_gfaffine() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GFNI AFFINE test\n"); log_fatal(EINTERNAL, "Failed GFNI AFFINE test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* vandermonde raid parity generation with 32 data disks */
if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, 32, 256) != 0) { if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, 32, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Vandermonde RAID test\n"); log_fatal(EINTERNAL, "Failed GEN Vandermonde RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* vandermonde raid parity generation with a single data disk */
if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, 1, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Vandermonde RAID test single data disk\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* vandermonde raid parity generation with maximum data disks */
if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, RAID_DATA_MAX, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Vandermonde RAID test max data disks\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* vandermonde raid recovery with combinations of missing data disks and parities */
if (raid_test_rec(RAID_MODE_VANDERMONDE_RAID, 12, 256) != 0) { if (raid_test_rec(RAID_MODE_VANDERMONDE_RAID, 12, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed REC Vandermonde RAID test\n"); log_fatal(EINTERNAL, "Failed REC Vandermonde RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* vandermonde raid tail recovery across all data disk counts up to maximum */
if (raid_test_tail(RAID_MODE_VANDERMONDE_RAID, RAID_DATA_MAX, 256) != 0) { if (raid_test_tail(RAID_MODE_VANDERMONDE_RAID, RAID_DATA_MAX, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed TAIL Vandermonde RAID test\n"); log_fatal(EINTERNAL, "Failed TAIL Vandermonde RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy raid matrix invertibility and polynomial checks */
if (raid_test_poly(RAID_MODE_CAUCHY_RAID) != 0) { if (raid_test_poly(RAID_MODE_CAUCHY_RAID) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed POLY Cauchy RAID test\n"); log_fatal(EINTERNAL, "Failed POLY Cauchy RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy raid parity generation with 32 data disks */
if (raid_test_par(RAID_MODE_CAUCHY_RAID, 32, 256) != 0) { if (raid_test_par(RAID_MODE_CAUCHY_RAID, 32, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy RAID test\n"); log_fatal(EINTERNAL, "Failed GEN Cauchy RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
if (raid_test_rec(RAID_MODE_CAUCHY_RAID, 12, 256) != 0) {
/* LCOV_EXCL_START */ /* cauchy raid parity generation with a single data disk */
log_fatal(EINTERNAL, "Failed REC Cauchy RAID test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_tail(RAID_MODE_CAUCHY_RAID, RAID_DATA_MAX, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed TAIL Cauchy RAID test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_par(RAID_MODE_CAUCHY_RAID, 1, 256) != 0) { if (raid_test_par(RAID_MODE_CAUCHY_RAID, 1, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy RAID test single data disk\n"); log_fatal(EINTERNAL, "Failed GEN Cauchy RAID test single data disk\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy raid parity generation with maximum data disks */
if (raid_test_par(RAID_MODE_CAUCHY_RAID, RAID_DATA_MAX, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy RAID test max data disks\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* cauchy raid recovery with combinations of missing data disks and parities */
if (raid_test_rec(RAID_MODE_CAUCHY_RAID, 12, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed REC Cauchy RAID test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* cauchy raid tail recovery across all data disk counts up to maximum */
if (raid_test_tail(RAID_MODE_CAUCHY_RAID, RAID_DATA_MAX, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed TAIL Cauchy RAID test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* cauchy aes matrix invertibility and polynomial checks */
if (raid_test_poly(RAID_MODE_CAUCHY_AES) != 0) { if (raid_test_poly(RAID_MODE_CAUCHY_AES) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed POLY Cauchy AES test\n"); log_fatal(EINTERNAL, "Failed POLY Cauchy AES test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy aes parity generation with 32 data disks */
if (raid_test_par(RAID_MODE_CAUCHY_AES, 32, 256) != 0) { if (raid_test_par(RAID_MODE_CAUCHY_AES, 32, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy AES test\n"); log_fatal(EINTERNAL, "Failed GEN Cauchy AES test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy aes parity generation with a single data disk */
if (raid_test_par(RAID_MODE_CAUCHY_AES, 1, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy AES test single data disk\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* cauchy aes parity generation with maximum data disks */
if (raid_test_par(RAID_MODE_CAUCHY_AES, RAID_DATA_MAX, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy AES test max data disks\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* cauchy aes recovery with combinations of missing data disks and parities */
if (raid_test_rec(RAID_MODE_CAUCHY_AES, 12, 256) != 0) { if (raid_test_rec(RAID_MODE_CAUCHY_AES, 12, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed REC Cauchy AES test\n"); log_fatal(EINTERNAL, "Failed REC Cauchy AES test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy aes tail recovery across all data disk counts up to maximum */
if (raid_test_tail(RAID_MODE_CAUCHY_AES, RAID_DATA_MAX, 256) != 0) { if (raid_test_tail(RAID_MODE_CAUCHY_AES, RAID_DATA_MAX, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed TAIL Cauchy AES test\n"); log_fatal(EINTERNAL, "Failed TAIL Cauchy AES test\n");

View file

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
} }
} }
printf("Full sanity test for the RAID Cauchy library\n\n"); printf("Full sanity test for the RAID library\n\n");
raid_init(); raid_init();
@ -79,6 +79,7 @@ int main(int argc, char *argv[])
else else
printf("\nPlease wait...\n\n"); printf("\nPlease wait...\n\n");
/* array sorting helper */
printf("Test sorting...\n"); printf("Test sorting...\n");
if (raid_test_sort() != 0) { if (raid_test_sort() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -86,6 +87,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* sorted array insertion helper */
printf("Test insertion...\n"); printf("Test insertion...\n");
if (raid_test_insert() != 0) { if (raid_test_insert() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -93,6 +95,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* permutation and combination generators */
printf("Test combinations/permutations...\n"); printf("Test combinations/permutations...\n");
if (raid_test_combo() != 0) { if (raid_test_combo() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -100,6 +103,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* gfni affine transformation matrices */
printf("Test GFNI affine matrices...\n"); printf("Test GFNI affine matrices...\n");
if (raid_test_gfaffine() != 0) { if (raid_test_gfaffine() != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -107,13 +111,60 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
printf("Test Vandermonde RAID parity generation with %u data disks...\n", RAID_DATA_MAX); /* cauchy raid polynomial checks */
if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, RAID_DATA_MAX, test_size) != 0) { printf("Test Cauchy RAID polynomials...\n");
if (raid_test_poly(RAID_MODE_CAUCHY_RAID) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
goto bail; goto bail;
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy aes polynomial checks */
printf("Test Cauchy AES polynomials...\n");
if (raid_test_poly(RAID_MODE_CAUCHY_AES) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
/* cauchy raid module self-test */
printf("Test Cauchy RAID self-test...\n");
raid_mode(RAID_MODE_CAUCHY_RAID);
if (raid_selftest() != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
/* cauchy aes module self-test */
printf("Test Cauchy AES self-test...\n");
raid_mode(RAID_MODE_CAUCHY_AES);
if (raid_selftest() != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
/* vandermonde raid module self-test */
printf("Test Vandermonde RAID self-test...\n");
raid_mode(RAID_MODE_VANDERMONDE_RAID);
if (raid_selftest() != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
/* vandermonde raid parity generation across all disk counts from 1 to maximum */
printf("Test Vandermonde RAID parity generation with 1-%u data disks...\n", RAID_DATA_MAX);
for (int i = 1; i <= RAID_DATA_MAX; ++i) {
if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, i, test_size) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
}
/* cauchy raid parity generation across all disk counts from 1 to maximum */
printf("Test Cauchy RAID parity generation with 1-%u data disks...\n", RAID_DATA_MAX); printf("Test Cauchy RAID parity generation with 1-%u data disks...\n", RAID_DATA_MAX);
for (int i = 1; i <= RAID_DATA_MAX; ++i) { for (int i = 1; i <= RAID_DATA_MAX; ++i) {
if (raid_test_par(RAID_MODE_CAUCHY_RAID, i, test_size) != 0) { if (raid_test_par(RAID_MODE_CAUCHY_RAID, i, test_size) != 0) {
@ -122,6 +173,8 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
} }
/* cauchy aes parity generation across all disk counts from 1 to maximum */
printf("Test Cauchy AES parity generation with 1-%u data disks...\n", RAID_DATA_MAX); printf("Test Cauchy AES parity generation with 1-%u data disks...\n", RAID_DATA_MAX);
for (int i = 1; i <= RAID_DATA_MAX; ++i) { for (int i = 1; i <= RAID_DATA_MAX; ++i) {
if (raid_test_par(RAID_MODE_CAUCHY_AES, i, test_size) != 0) { if (raid_test_par(RAID_MODE_CAUCHY_AES, i, test_size) != 0) {
@ -131,6 +184,7 @@ int main(int argc, char *argv[])
} }
} }
/* vandermonde raid tail recovery across all data disk counts from 1 to maximum */
printf("Test Vandermonde RAID tail recovering with 1-%u data disks...\n", RAID_DATA_MAX); printf("Test Vandermonde RAID tail recovering with 1-%u data disks...\n", RAID_DATA_MAX);
if (raid_test_tail(RAID_MODE_VANDERMONDE_RAID, RAID_DATA_MAX, test_size) != 0) { if (raid_test_tail(RAID_MODE_VANDERMONDE_RAID, RAID_DATA_MAX, test_size) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -138,6 +192,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy raid tail recovery across all data disk counts from 1 to maximum */
printf("Test Cauchy RAID tail recovering with 1-%u data disks...\n", RAID_DATA_MAX); printf("Test Cauchy RAID tail recovering with 1-%u data disks...\n", RAID_DATA_MAX);
if (raid_test_tail(RAID_MODE_CAUCHY_RAID, RAID_DATA_MAX, test_size) != 0) { if (raid_test_tail(RAID_MODE_CAUCHY_RAID, RAID_DATA_MAX, test_size) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -145,6 +200,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy aes tail recovery across all data disk counts from 1 to maximum */
printf("Test Cauchy AES tail recovering with 1-%u data disks...\n", RAID_DATA_MAX); printf("Test Cauchy AES tail recovering with 1-%u data disks...\n", RAID_DATA_MAX);
if (raid_test_tail(RAID_MODE_CAUCHY_AES, RAID_DATA_MAX, test_size) != 0) { if (raid_test_tail(RAID_MODE_CAUCHY_AES, RAID_DATA_MAX, test_size) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -152,6 +208,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* vandermonde raid recovery with all combinations of data disks and 3 parity blocks */
printf("Test Vandermonde RAID recovering with all combinations of %u data and 3 parity blocks...\n", test_count); printf("Test Vandermonde RAID recovering with all combinations of %u data and 3 parity blocks...\n", test_count);
if (raid_test_rec(RAID_MODE_VANDERMONDE_RAID, test_count, test_size) != 0) { if (raid_test_rec(RAID_MODE_VANDERMONDE_RAID, test_count, test_size) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -159,6 +216,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy raid recovery with all combinations of data disks and 6 parity blocks */
printf("Test Cauchy RAID recovering with all combinations of %u data and 6 parity blocks...\n", test_count); printf("Test Cauchy RAID recovering with all combinations of %u data and 6 parity blocks...\n", test_count);
if (raid_test_rec(RAID_MODE_CAUCHY_RAID, test_count, test_size) != 0) { if (raid_test_rec(RAID_MODE_CAUCHY_RAID, test_count, test_size) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -166,6 +224,7 @@ int main(int argc, char *argv[])
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* cauchy aes recovery with all combinations of data disks and 6 parity blocks */
printf("Test Cauchy AES recovering with all combinations of %u data and 6 parity blocks...\n", test_count); printf("Test Cauchy AES recovering with all combinations of %u data and 6 parity blocks...\n", test_count);
if (raid_test_rec(RAID_MODE_CAUCHY_AES, test_count, test_size) != 0) { if (raid_test_rec(RAID_MODE_CAUCHY_AES, test_count, test_size) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */