add compare_testvector()
This commit is contained in:
parent
383f200cb6
commit
60bb5440fb
@ -81,6 +81,7 @@ extern const struct ltc_prng_descriptor no_prng_desc;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void print_hex(const char* what, const void* v, const unsigned long l);
|
void print_hex(const char* what, const void* v, const unsigned long l);
|
||||||
|
int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
|
||||||
int sorter(const void *a, const void *b);
|
int sorter(const void *a, const void *b);
|
||||||
void tally_results(int type);
|
void tally_results(int type);
|
||||||
ulong64 rdtsc (void);
|
ulong64 rdtsc (void);
|
||||||
|
@ -16,6 +16,23 @@ void print_hex(const char* what, const void* v, const unsigned long l)
|
|||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
if(is_len != should_len)
|
||||||
|
res = is_len > should_len ? -1 : 1;
|
||||||
|
else
|
||||||
|
res = XMEMCMP(is, should, MAX(is_len, should_len));
|
||||||
|
|
||||||
|
if (res != 0) {
|
||||||
|
fprintf(stderr, "Testvector #%i of %s failed:\n", which, what);
|
||||||
|
print_hex("SHOULD", should, should_len);
|
||||||
|
print_hex("IS ", is, is_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
struct list results[100];
|
struct list results[100];
|
||||||
int no_results;
|
int no_results;
|
||||||
int sorter(const void *a, const void *b)
|
int sorter(const void *a, const void *b)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user