Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved test PASS / FAIL notification
Each test will exit 0 if all is well, or exit 1 if there was an error.

Now 'make test' will report of any of the tests failed or of all tests
passed.  It will exit non-zero of any of the tests failed.
  • Loading branch information
lcn2 committed May 31, 2017
commit ef5ea558b111191fa076ed65fdc1ebbe52b77ba8
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,22 @@ sha256_test.o: sha256_test.c sha256.h
${CC} ${CFLAGS} sha256_test.c -c

test: ${TEST_TARGETS}
@-for i in ${TEST_TARGETS}; do \
@export last_error="0"; \
for i in ${TEST_TARGETS}; do \
echo running '=-=' $$i '=-='; \
./$$i; \
done
status="$$?"; \
if [ "$$status" != 0 ]; then \
echo "WARNING: test $$i failed!!"; \
last_error="$$status"; \
fi; \
done; \
if [ "$$last_error" = 0 ]; then \
echo "=-=-= All tests PASSED =-=-="; \
else \
echo "=-=-= Some tests FAILED =-=-="; \
fi; \
exit "$$last_error"

configure:
@echo nothing to configure
Expand Down
8 changes: 6 additions & 2 deletions aes_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/*************************** HEADER FILES ***************************/
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include "aes.h"

extern int aes_decrypt_cbc(const BYTE in[], size_t in_len, BYTE out[], const WORD key[], int keysize, const BYTE iv[]);
Expand Down Expand Up @@ -281,7 +282,10 @@ int aes_test()

int main(int argc, char *argv[])
{
printf("AES Tests: %s\n", aes_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = aes_test();
printf("AES Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions arcfour_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/*************************** HEADER FILES ***************************/
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include "arcfour.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -41,7 +42,10 @@ int rc4_test()

int main()
{
printf("ARCFOUR tests: %s\n", rc4_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = rc4_test();
printf("ARCFOUR Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions base64_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/*************************** HEADER FILES ***************************/
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include "base64.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -48,7 +49,10 @@ int base64_test()

int main()
{
printf("Base64 tests: %s\n", base64_test() ? "PASSED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return 0;
ret = base64_test();
printf("Base64 Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions blowfish_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/*************************** HEADER FILES ***************************/
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include "blowfish.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -62,7 +63,10 @@ int blowfish_test()

int main()
{
printf("Blowfish tests: %s\n", blowfish_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = blowfish_test();
printf("Blowfish Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions des_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/*************************** HEADER FILES ***************************/
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include "des.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -77,7 +78,10 @@ int des_test()

int main()
{
printf("DES test: %s\n", des_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = des_test();
printf("DES Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 7 additions & 1 deletion md2_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <stdlib.h>
#include "md2.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -54,5 +55,10 @@ int md2_test()

int main()
{
printf("MD2 tests: %s\n", md2_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

ret = md2_test();
printf("MD2 Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions md5_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "md5.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -54,7 +55,10 @@ int md5_test()

int main()
{
printf("MD5 tests: %s\n", md5_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = md5_test();
printf("MD5 Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions rot-13_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/*************************** HEADER FILES ***************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "rot-13.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand All @@ -38,7 +39,10 @@ int rot13_test()

int main()
{
printf("ROT-13 tests: %s\n", rot13_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = rot13_test();
printf("ROT-13 Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions sha1_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "sha1.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -52,7 +53,10 @@ int sha1_test()

int main()
{
printf("SHA1 tests: %s\n", sha1_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = sha1_test();
printf("SHA1 Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}
8 changes: 6 additions & 2 deletions sha256_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "sha256.h"

/*********************** FUNCTION DEFINITIONS ***********************/
Expand Down Expand Up @@ -55,7 +56,10 @@ int sha256_test()

int main()
{
printf("SHA-256 tests: %s\n", sha256_test() ? "SUCCEEDED" : "FAILED");
int ret; // 0 ==> test failed, != 0 ==> test suceeded

return(0);
ret = sha256_test();
printf("SHA-256 Tests: %s\n", ret ? "SUCCEEDED" : "FAILED");

exit(ret == 0 ? 1 : 0);
}