mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 19:54:40 +02:00
added benchmark app for RIOT and updated test error handling
This commit is contained in:
12
RIOT_Make/README
Normal file
12
RIOT_Make/README
Normal file
@@ -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!
|
||||
|
||||
|
49
RIOT_Make/benchmark/README
Normal file
49
RIOT_Make/benchmark/README
Normal file
@@ -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 <path-to>/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:
|
||||
<wolfssl-root>/src
|
||||
<wolfssl-root>/wolfcrypt/src
|
||||
<wolfssl-root>/wolfcrypt/benchmark
|
||||
|
||||
2. Use the provided Makefile to build the example application:
|
||||
"wolfbenchmark.elf"
|
||||
This application will be located here:
|
||||
<path-to>/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:
|
||||
<wolfssl-root>/src
|
||||
<wolfssl-root>/wolfcrypt/src
|
||||
<wolfssl-root>/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 <wolfssl-root>/.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
|
||||
|
55
RIOT_Make/benchmark/wolf-build-and-run-test.sh
Executable file
55
RIOT_Make/benchmark/wolf-build-and-run-test.sh
Executable file
@@ -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:
|
||||
# <wolfssl-root>/src
|
||||
# <wolfssl-root>/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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
<path-to>/RIOT/examples/wolfssl/RIOT_Make/wolfcrypt-test/bin/native/testwolfcrypt.elf
|
||||
<path-to>/RIOT/examples/wolfssl/RIOT_Make/wolfcrypt-test/bin/native/testsuite.elf
|
||||
|
||||
3. Execute that application. You should see a pass or fail.
|
||||
|
||||
|
@@ -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!"
|
||||
|
||||
|
@@ -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!"
|
||||
|
||||
|
@@ -483,7 +483,11 @@ int benchmark_test(void *args)
|
||||
ShowMemoryTracker();
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_RIOT_OS
|
||||
exit (0);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user