diff --git a/RIOT_Make/README b/RIOT_Make/README new file mode 100644 index 000000000..e177b2ba0 --- /dev/null +++ b/RIOT_Make/README @@ -0,0 +1,12 @@ +To test all three applications: + +wolfbenchmark +testsuite +wolfcrypt-test + +run the script in this directory: ./test-all.sh + +See the README in each respecive directory for more information on wolfSSL and +RIOT_OS! + + diff --git a/RIOT_Make/benchmark/README b/RIOT_Make/benchmark/README new file mode 100644 index 000000000..1aa54afa0 --- /dev/null +++ b/RIOT_Make/benchmark/README @@ -0,0 +1,49 @@ +These are the steps to properly setup a test of wolfssl in RIOT OS: + +To test wolfSSL in RIOT build system get the RIOT source code from here: +git clone https://github.com/RIOT-OS/RIOT + +Then cd RIOT/examples + +clone wolfssl in that directory. You should end up with RIOT/examples/wolfssl + +git clone https://github.com/wolfssl/wolfssl + +cd /RIOT/examples/wolfssl/RIOT_Make/benchmark + +run the script ./wolf-build-and-run-test.sh + +That script will perform the following steps: +1. copy the source files from: + /src + /wolfcrypt/src + /wolfcrypt/benchmark + +2. Use the provided Makefile to build the example application: + "wolfbenchmark.elf" + This application will be located here: + /RIOT/examples/wolfssl/RIOT_Make/wolfcrypt-test/bin/native/wolfbenchmark.elf + +3. Execute that application. You should see a pass or fail. + +4. Lastly that script will cleanup the source files it copied in for building. + NOTE: this is HIGHLY RECOMMENDED to prevent making changes on temporary + files. All development changes should be made to the actual source + files located in their respective directories: + /src + /wolfcrypt/src + /wolfcrypt/benchmark + Then the script "wolf-build-and-run-test.sh" should be run again to + test those changes + If you do make changes to the temporary files those changes will be + ignored by /.gitignore + + +NOTE: This test is only for the "native" test. To build for a specific platform + cd to RIOT directory and run "make doc" to generate doxygen docs. + (You will need to install doxygen if you don't have it already) + Then open the file: RIOT/doc/doxygen/html/index.html + + This will provide you with the necessary help to setup and build for a + specific platform + diff --git a/RIOT_Make/benchmark/wolf-build-and-run-test.sh b/RIOT_Make/benchmark/wolf-build-and-run-test.sh new file mode 100755 index 000000000..ffc316d0a --- /dev/null +++ b/RIOT_Make/benchmark/wolf-build-and-run-test.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +wolf_riot_setup () { +#copy the test sources here +cp ../../wolfcrypt/benchmark/benchmark.c ./ + +cp ../../wolfcrypt/src/*.c ./ + +cp ../../src/*.c ./ + +} + +wolf_riot_cleanup () { + rm ./*.c + #leave this line in for testing. Comment it out when you want to build + # a .elf for flashing to a device + make clean &> /dev/null +} +trap wolf_riot_cleanup INT TERM + +BACKUPCFLAGS=${CFLAGS} +export CFLAGS="${CFLAGS} -DWOLFSSL_RIOT_OS" + +# copy the necessary files to this directory +wolf_riot_setup + +# build the test +make &> /dev/null +RESULT=$? + [ $RESULT != 0 ] && echo "Make FAILED: running verbose make" && + make +if [ $RESULT != 0 ]; +then + wolf_riot_cleanup && echo "cleanup done" && exit 2 +fi + +# run the test +./bin/native/wolfbenchmark.elf + +# confirm success or failure +export CFLAGS="${BACKUPCFLAGS}" +RESULT=$? + [ $RESULT != 0 ] && echo "TEST FAILED" && wolf_riot_cleanup && + echo "cleanup done" && exit 2 + +echo "TEST PASSED!" + +# cleanup. All changes made should be to the files in: +# /src +# /wolfcrypt/src +# or other. Never make changes to the files copied here as they are only +# temporary. Once changes are made, to test them just run this script again. +wolf_riot_cleanup 0 + + diff --git a/RIOT_Make/test-all.sh b/RIOT_Make/test-all.sh index c8a0edae1..20d908386 100755 --- a/RIOT_Make/test-all.sh +++ b/RIOT_Make/test-all.sh @@ -1,27 +1,34 @@ #!/bin/sh +check_status () { +if [ $1 != 0 ] +then + echo "$2 failed" + echo "" +fi +} + echo "Running wolfssl testsuite with RIOT" cd testsuite/ ./wolf-build-and-run-test.sh RESULT=$? -if [ $RESULT != 0 ] -then - echo "testsuite failed" - echo "" -fi - +check_status $RESULT "testsuite" cd .. +echo "" echo "Running wolfcrypt tests with RIOT" cd wolfcrypt-test ./wolf-build-and-run-test.sh RESULT=$? -if [ $RESULT != 0 ] -then - echo "wolfcrypt test failed" - echo "" -fi +check_status $RESULT "wolfcrypt test" +cd .. +echo "" +echo "Running wolfcrypt benchmark with RIOT" +cd benchmark +./wolf-build-and-run-test.sh +RESULT=$? +check_status $RESULT "wolfcrypt benchmark" cd .. exit 0 diff --git a/RIOT_Make/testsuite/README b/RIOT_Make/testsuite/README index 08db1ac67..d5e486733 100644 --- a/RIOT_Make/testsuite/README +++ b/RIOT_Make/testsuite/README @@ -24,7 +24,7 @@ That script will perform the following steps: 2. Use the provided Makefile to build the example application: "testwolfcrypt.elf" This application will be located here: - /RIOT/examples/wolfssl/RIOT_Make/wolfcrypt-test/bin/native/testwolfcrypt.elf + /RIOT/examples/wolfssl/RIOT_Make/wolfcrypt-test/bin/native/testsuite.elf 3. Execute that application. You should see a pass or fail. diff --git a/RIOT_Make/testsuite/wolf-build-and-run-test.sh b/RIOT_Make/testsuite/wolf-build-and-run-test.sh index 2434f4c69..f64d3953e 100755 --- a/RIOT_Make/testsuite/wolf-build-and-run-test.sh +++ b/RIOT_Make/testsuite/wolf-build-and-run-test.sh @@ -41,13 +41,18 @@ then fi # run the test -./bin/native/wolftestsuite.elf - +RESULT=`./bin/native/wolftestsuite.elf` # confirm success or failure export CFLAGS="${BACKUPCFLAGS}" -RESULT=$? - [ $RESULT != 0 ] && echo "TEST FAILED" && wolf_riot_cleanup && - echo "cleanup done" && exit 2 +errstring="error" +if test "${RESULT#*$errstring}" != "$RESULT" + then + echo "$RESULT" + echo "TEST FAILED" && wolf_riot_cleanup && echo "cleanup done" && + exit 2 + else + echo "$RESULT" + fi echo "TEST PASSED!" diff --git a/RIOT_Make/wolfcrypt-test/wolf-build-and-run-test.sh b/RIOT_Make/wolfcrypt-test/wolf-build-and-run-test.sh index eaa5a115c..1f8100635 100755 --- a/RIOT_Make/wolfcrypt-test/wolf-build-and-run-test.sh +++ b/RIOT_Make/wolfcrypt-test/wolf-build-and-run-test.sh @@ -38,11 +38,19 @@ then fi # run the test -./bin/native/testwolfcrypt.elf +RESULT=`./bin/native/testwolfcrypt.elf` # confirm success or failure -RESULT=$? - [ $RESULT != 0 ] && echo "TEST FAILED" && wolf_riot_cleanup && exit 5 +export CFLAGS="${BACKUPCFLAGS}" +errstring="error" +if test "${RESULT#*$errstring}" != "$RESULT" + then + echo "$RESULT" + echo "TEST FAILED" && wolf_riot_cleanup && echo "cleanup done" && + exit 2 + else + echo "$RESULT" + fi echo "ALL TEST PASSED!" diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 87f92c720..89e861e44 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -483,7 +483,11 @@ int benchmark_test(void *args) ShowMemoryTracker(); #endif +#ifdef WOLFSSL_RIOT_OS + exit (0); +#else return 0; +#endif } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index bfd9c84ae..5ae622d02 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -262,7 +262,11 @@ static int err_sys(const char* msg, int es) { printf("%s error = %d\n", msg, es); +#ifdef WOLFSSL_RIOT_OS + exit(-1); +#else return -1; /* error state */ +#endif } /* func_args from test.h, so don't have to pull in other junk */