Small tweak to self-test routine.

This commit is contained in:
LoRd_MuldeR 2021-04-08 01:58:54 +02:00
parent fde0906f98
commit 3cdfc9d9ab
Signed by: mulder
GPG Key ID: 2B5913365F57E03F

View File

@ -490,7 +490,7 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
}
else if ((file_size % sizeof(uint64_t)) != 0)
{
FPRINTF(stderr, T("Warning: File size is *not* an integer multiple of %u, ignoring excess bytes!\n\n"), (unsigned int)sizeof(uint64_t));
FPRINTF(stderr, T("Warning: File size is *not* an integer multiple of %u, ignoring excess bytes!\n\n"), (unsigned)sizeof(uint64_t));
}
FPUTS(T("Decrypting file contents, please be patient... "), stderr);
@ -761,28 +761,25 @@ clean_up:
static int run_self_test(void)
{
static const size_t total = 32U;
const char* const test_data[] = { TEST_DATA_0, TEST_DATA_1, TEST_DATA_2, TEST_DATA_3, NULL };
const uint64_t test_chck[] = { TEST_CHCK_0, TEST_CHCK_1, TEST_CHCK_2, TEST_CHCK_3, 0x00 };
const char *const TEST_DATA[] = { TEST_DATA_0, TEST_DATA_1, TEST_DATA_2, TEST_DATA_3 };
const uint64_t TEST_CHCK[] = { TEST_CHCK_0, TEST_CHCK_1, TEST_CHCK_2, TEST_CHCK_3 };
size_t completed = 0U;
FPRINTF(stderr, T("Self-test is in progress, please be patient... %2u/%2u "), (unsigned int)completed, (unsigned int)total);
const size_t total = sizeof(TEST_DATA) / sizeof(TEST_DATA[0]);
FPRINTF(stderr, T("Self-test is in progress, please be patient... stage %u/%u "), 0U, (unsigned)total);
fflush(stderr);
for (size_t i = 0U; i < 8U; ++i)
for (size_t i = 0U; i < total; ++i)
{
for (size_t j = 0U; test_data[j]; ++j)
{
FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u "), (unsigned int)++completed, (unsigned int)total);
FPRINTF(stderr, T("\b\b\b\b%u/%u "), (unsigned)(i + 1U), (unsigned)total);
fflush(stderr);
if (run_test_case(test_data[j], test_chck[j]) != EXIT_SUCCESS)
if (run_test_case(TEST_DATA[i], TEST_CHCK[i]) != EXIT_SUCCESS)
{
return EXIT_FAILURE;
}
}
}
FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u\n\nCompleted successfully.\n\n"), (unsigned int)total, (unsigned int)total);
FPRINTF(stderr, T("\b\b\b\b%u/%u\n\nCompleted successfully.\n\n"), (unsigned)total, (unsigned)total);
fflush(stderr);
return EXIT_SUCCESS;