fishlim: Minor test improvements
- Don't have tests repeat themselves, meson has a `--repeat` flag - Fix a minor leak of a GRand - Speed up a test - Increase timeout This still needs a lot of improvements, it runs at lot of loops within loops generating random strings that could be optimized. This means it can take a very long time on some computers. Closes #2629
This commit is contained in:
parent
b54593e752
commit
4f3ef3505a
@ -12,4 +12,5 @@ fishlim_tests = executable('fishlim_tests', fishlim_test_sources,
|
||||
|
||||
test('Fishlim Tests', fishlim_tests,
|
||||
protocol: 'tap',
|
||||
timeout: 600,
|
||||
)
|
||||
|
@ -129,19 +129,19 @@ static void
|
||||
test_base64_len (void)
|
||||
{
|
||||
char *b64 = NULL;
|
||||
int i, message_len = 0;
|
||||
char message[1000];
|
||||
int message_end = sizeof (message) - 1;
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
for (message_len = 1; message_len < 1000; ++message_len) {
|
||||
random_string(message, message_len);
|
||||
b64 = g_base64_encode((const unsigned char *) message, message_len);
|
||||
random_string(message, message_end);
|
||||
|
||||
for (; message_end >= 0; --message_end) {
|
||||
message[message_end] = '\0'; /* Truncate instead of generating new strings */
|
||||
b64 = g_base64_encode((const unsigned char *) message, message_end);
|
||||
g_assert_nonnull(b64);
|
||||
g_assert_cmpuint(strlen(b64), == , base64_len(message_len));
|
||||
g_assert_cmpuint(strlen(b64), == , base64_len(message_end));
|
||||
g_free(b64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the calculation of final length from an encoded string in BlowcryptBase64
|
||||
@ -150,11 +150,9 @@ static void
|
||||
test_base64_fish_len (void)
|
||||
{
|
||||
char *b64 = NULL;
|
||||
int i, message_len = 0;
|
||||
int message_len = 0;
|
||||
char message[1000];
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
|
||||
for (message_len = 1; message_len < 1000; ++message_len) {
|
||||
random_string(message, message_len);
|
||||
b64 = fish_base64_encode(message, message_len);
|
||||
@ -163,7 +161,6 @@ test_base64_fish_len (void)
|
||||
g_free(b64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the calculation of final length from an encrypted string in ECB mode
|
||||
@ -242,14 +239,11 @@ test_foreach_utf8_data_chunks(void)
|
||||
{
|
||||
GRand *rand = NULL;
|
||||
GString *chunks = NULL;
|
||||
int tests, max_chunks_len, chunks_len;
|
||||
int max_chunks_len, chunks_len;
|
||||
char ascii_message[1001];
|
||||
char *data_chunk = NULL;
|
||||
|
||||
rand = g_rand_new();
|
||||
|
||||
for (tests = 0; tests < 1000; ++tests) {
|
||||
|
||||
max_chunks_len = g_rand_int_range(rand, 2, 301);
|
||||
random_string(ascii_message, 1000);
|
||||
|
||||
@ -264,8 +258,9 @@ test_foreach_utf8_data_chunks(void)
|
||||
}
|
||||
/* Check data loss */
|
||||
g_assert_cmpstr(chunks->str, == , ascii_message);
|
||||
|
||||
g_string_free(chunks, TRUE);
|
||||
}
|
||||
g_rand_free (rand);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user