![]() |
BitPunch McEliece
v0.0.4
|
There is implemented simple test enviroment. There are test which requires 'valgrind'.
You can run it using ./runTest TEST_NAME, or use help: ./runTest -h to see all options.
fruh@htfuws:~/projects/BitPunch$ ./runTest -h
Usage: runTest [options]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-a, --all Run all registered tests
-t RUN_TEST, --test=RUN_TEST
Run named tests
-r RUN_LEVEL, --runLevel=RUN_LEVEL
Run all tests <= runLevel
-v VERBOSE_LEVEL, --verbose=VERBOSE_LEVEL
Verbose level, can be ERROR, WARNING, INFO, DEBUG
-l, --list List available tests
This test enviroment creates on every run snapshot of current workspace and copies it into runtest/results/ISO_TIME_FORMAT/ folder.
Test is considered as PASSED when return code is 0 (zero) and 'ERROR' string not occured at the beggining of the line. Otherwise, test is considered as FAILED.
Here is the guide, how to create dummy test using C and bash sources. C source represents test body and bash source represents control section.
We can create new suite called "foosuite" or use existing. "Create" means to make directory "foosuite" in our test root:
Then we have to create our source files:
Now we have to register this test, it means we have to add following record into TESTS python structure defined in:
TESTS = {
"testFooName" : {
"suite" : "foosuite",
"file" : "testFoo.sh",
"args" : "testFoo fooarg2",
"runLevel" : "regular",
},
... heere are other tests ...
}
Now we can set up body of the control bash source. The first lines are required (until cd $1 (included)), first argument is still set to the path of the current workspace snapshot (this is done automatically by test enviroment):
#!/bin/bash
if [ "$1" = "" ]; then
echo "First argument is result folder."
exit 1
fi
TESTFILE_DIR=$(pwd)
echo "INFO: $TESTFILE_DIR"
# now we are in current snapshot
cd "$1"
APP="./dist/test/fooBuild"
# control body
echo "INFO: fooarg1: $2"
echo "INFO: fooarg2: $3"
echo "WARNING: warning message"
echo "INFO: cleaning build..."
make clean
if [ $? != 0 ]; then
echo "ERROR: make clean"
exit 1
fi
echo "INFO: building static-lib..."
make static-lib
if [ $? != 0 ]; then
echo "ERROR: building target static-lib"
exit 2
fi
gcc -Isrc/ $TESTFILE_DIR/testFoo.c ./dist/libbpumecs.a -o $APP || exit 1
# run app
$APP
# return code
exit $?
And now we set test body:
#include <bitpunch/bitpunch.h>
#include <stdio.h>
int main(int argc, char **argv) {
int rc = 0;
// MUST BE NULL
BPU_T_Mecs_Ctx *ctx = NULL;
BPU_T_UN_Mecs_Params params;
/***************************************/
// mce initialisation t = 50, m = 11
if (BPU_mecsInitParamsGoppa(¶ms, 11, 50, 0)) {
return 1;
}
fprintf(stderr, "Basic GOPPA Initialisation...\n");
if (BPU_mecsInitCtx(&ctx, ¶ms, BPU_EN_MECS_BASIC_GOPPA)) {
return 1;
}
BPU_mecsFreeCtx(&ctx);
BPU_mecsFreeParamsGoppa(¶ms);
return rc;
}
We can see our registered test in the list of the tests:
fruh@htfuws:~/projects/BitPunch$ ./runTest -l Test: testMemRun runLevel: regular Test: testFooName runLevel: regular Test: testMemLeakWithH runLevel: regular Test: testBuild runLevel: express Test: testMemLeakWoH runLevel: regular Test: testLibSize runLevel: express
We can run our dummy test using:
fruh@htfuws:~/projects/BitPunch$ ./runTest testFooName Tests to run (1): testFooName ======== BEGIN::testFooName ======== INFO: /media/fruh/data/projects/BitPunch/runtest/tests/foosuite INFO: fooarg1: testFoo INFO: fooarg2: fooarg2 WARNING: warning message INFO: cleaning build... INFO: building static-lib... PASSED -------- END::testFooName -------- ======== RESULTS ======== Result folder: /media/fruh/data/projects/BitPunch/runtest/results/2015-05-17T23:51:36.709632 FAILED: 0 SKIPPED: 0 PASSED: 1 -------------------------