2026-04-02 16:00:27 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2026-04-02 16:25:49 +02:00
|
|
|
// Copyright (C) 2013 Andrea Mazzoleni
|
2014-01-18 10:37:09 +01:00
|
|
|
|
|
|
|
|
/* Full sanity test for the RAID library */
|
|
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
#include "test.h"
|
|
|
|
|
#include "cpu.h"
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Size of the blocks to test.
|
|
|
|
|
*/
|
|
|
|
|
#define TEST_SIZE 256
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Number of disks in the long parity test.
|
|
|
|
|
*/
|
|
|
|
|
#ifdef COVERAGE
|
|
|
|
|
#define TEST_COUNT 10
|
|
|
|
|
#else
|
|
|
|
|
#define TEST_COUNT 32
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
{
|
|
|
|
|
printf("Full sanity test for the RAID Cauchy library\n\n");
|
|
|
|
|
|
|
|
|
|
raid_init();
|
|
|
|
|
|
2026-06-04 17:53:25 +02:00
|
|
|
#ifdef CONFIG_VEC128
|
|
|
|
|
printf("Including 128-bit vectors\n");
|
|
|
|
|
#endif
|
2014-01-18 10:37:09 +01:00
|
|
|
#ifdef CONFIG_X86
|
|
|
|
|
if (raid_cpu_has_sse2())
|
2026-05-27 11:46:45 +02:00
|
|
|
printf("Including x86 SSE2\n");
|
2014-01-18 10:37:09 +01:00
|
|
|
if (raid_cpu_has_ssse3())
|
2026-05-27 11:46:45 +02:00
|
|
|
printf("Including x86 SSSE3\n");
|
2014-09-16 21:58:29 +02:00
|
|
|
if (raid_cpu_has_avx2())
|
2026-05-27 11:46:45 +02:00
|
|
|
printf("Including x86 AVX2\n");
|
2026-05-28 01:12:17 +02:00
|
|
|
#ifdef CONFIG_X86_64
|
2026-04-24 17:29:42 +02:00
|
|
|
if (raid_cpu_has_avx512bw())
|
2026-05-27 11:46:45 +02:00
|
|
|
printf("Including x86 AVX512BW\n");
|
2026-05-27 20:01:40 +02:00
|
|
|
if (raid_cpu_has_avx2gfni())
|
|
|
|
|
#ifdef USE_RAID_AES
|
|
|
|
|
printf("Including x86 AVX2GFNI\n");
|
|
|
|
|
#else
|
|
|
|
|
printf("Excluding x86 AVX2GFNI due polynomial mismatch\n");
|
|
|
|
|
#endif
|
2026-05-11 11:07:01 +02:00
|
|
|
if (raid_cpu_has_avx512gfni())
|
2026-05-27 11:46:45 +02:00
|
|
|
#ifdef USE_RAID_AES
|
|
|
|
|
printf("Including x86 AVX512GFNI\n");
|
|
|
|
|
#else
|
|
|
|
|
printf("Excluding x86 AVX512GFNI due polynomial mismatch\n");
|
|
|
|
|
#endif
|
2014-01-18 10:37:09 +01:00
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
printf("\nPlease wait about 60 seconds...\n\n");
|
|
|
|
|
|
|
|
|
|
printf("Test sorting...\n");
|
2015-03-18 22:55:17 +01:00
|
|
|
if (raid_test_sort() != 0) {
|
|
|
|
|
/* LCOV_EXCL_START */
|
2014-01-18 10:37:09 +01:00
|
|
|
goto bail;
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-18 10:37:09 +01:00
|
|
|
printf("Test insertion...\n");
|
2015-03-18 22:55:17 +01:00
|
|
|
if (raid_test_insert() != 0) {
|
|
|
|
|
/* LCOV_EXCL_START */
|
2014-01-18 10:37:09 +01:00
|
|
|
goto bail;
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-18 10:37:09 +01:00
|
|
|
printf("Test combinations/permutations...\n");
|
2015-03-18 22:55:17 +01:00
|
|
|
if (raid_test_combo() != 0) {
|
|
|
|
|
/* LCOV_EXCL_START */
|
2014-01-18 10:37:09 +01:00
|
|
|
goto bail;
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-27 20:01:40 +02:00
|
|
|
printf("Test Cauchy 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_CAUCHY, i, TEST_SIZE) != 0) {
|
|
|
|
|
/* LCOV_EXCL_START */
|
|
|
|
|
goto bail;
|
|
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
|
|
}
|
2015-03-18 22:55:17 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-18 10:37:09 +01:00
|
|
|
printf("Test Cauchy recovering with all combinations of %u data and 6 parity blocks...\n", TEST_COUNT);
|
2015-03-18 22:55:17 +01:00
|
|
|
if (raid_test_rec(RAID_MODE_CAUCHY, TEST_COUNT, TEST_SIZE) != 0) {
|
|
|
|
|
/* LCOV_EXCL_START */
|
2014-01-18 10:37:09 +01:00
|
|
|
goto bail;
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-18 10:37:09 +01:00
|
|
|
printf("Test Vandermonde parity generation with %u data disks...\n", RAID_DATA_MAX);
|
2015-03-18 22:55:17 +01:00
|
|
|
if (raid_test_par(RAID_MODE_VANDERMONDE, RAID_DATA_MAX, TEST_SIZE) != 0) {
|
|
|
|
|
/* LCOV_EXCL_START */
|
2014-01-18 10:37:09 +01:00
|
|
|
goto bail;
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-18 10:37:09 +01:00
|
|
|
printf("Test Vandermonde recovering with all combinations of %u data and 3 parity blocks...\n", TEST_COUNT);
|
2015-03-18 22:55:17 +01:00
|
|
|
if (raid_test_rec(RAID_MODE_VANDERMONDE, TEST_COUNT, TEST_SIZE) != 0) {
|
|
|
|
|
/* LCOV_EXCL_START */
|
2014-01-18 10:37:09 +01:00
|
|
|
goto bail;
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-18 10:37:09 +01:00
|
|
|
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
bail:
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_START */
|
2014-01-18 10:37:09 +01:00
|
|
|
printf("FAILED!\n");
|
|
|
|
|
exit(EXIT_FAILURE);
|
2015-03-18 22:55:17 +01:00
|
|
|
/* LCOV_EXCL_STOP */
|
2014-01-18 10:37:09 +01:00
|
|
|
}
|
|
|
|
|
|