Return non-zero when tests fail
This allows for shell scripts to check for success or failure without parsing the printed output. If the function name is later changed from main() it will also allow other code calling the tests to also easily check the pass or fail status.main
parent
42efb6c384
commit
8d38d5e6fd
5
test.c
5
test.c
|
@ -13,6 +13,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -46,6 +47,7 @@ size_t lengths[4] = {8, 16, 4, 8};
|
||||||
int main() {
|
int main() {
|
||||||
uint8_t in[64], out[16], k[16];
|
uint8_t in[64], out[16], k[16];
|
||||||
int i;
|
int i;
|
||||||
|
bool any_failed;
|
||||||
#ifndef GETVECTORS
|
#ifndef GETVECTORS
|
||||||
int fails = 0;
|
int fails = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -91,6 +93,7 @@ int main() {
|
||||||
if (memcmp(out, v + (i * len), len)) {
|
if (memcmp(out, v + (i * len), len)) {
|
||||||
printf("fail for %d bytes\n", i);
|
printf("fail for %d bytes\n", i);
|
||||||
fails++;
|
fails++;
|
||||||
|
any_failed = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -105,5 +108,5 @@ int main() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return any_failed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue