diff --git a/test.sh b/test.sh index 45f43446a..cdaa49fb5 100644 --- a/test.sh +++ b/test.sh @@ -3,7 +3,7 @@ # do not use this script # it is written only for internal tests via Travis CI -FILES="usr/tests/hello usr/tests/hellof usr/tests/hello++ usr/tests/thr_hello usr/tests/pi usr/benchmarks/stream usr/benchmarks/basic usr/tests/signals" +FILES="usr/tests/hello usr/tests/hellof usr/tests/hello++ usr/tests/thr_hello usr/tests/pi usr/benchmarks/stream usr/benchmarks/basic usr/tests/signals usr/tests/test-malloc usr/tests/test-malloc-mt" PROXY=/opt/hermit/bin/proxy for f in $FILES; do echo "check $f..."; timeout --kill-after=5m 5m $PROXY $f || exit 1; done diff --git a/usr/tests/CMakeLists.txt b/usr/tests/CMakeLists.txt index a54926f79..40fbe4464 100644 --- a/usr/tests/CMakeLists.txt +++ b/usr/tests/CMakeLists.txt @@ -9,6 +9,10 @@ add_executable(hello++ hello++.cpp) add_executable(hellof hellof.f90) add_executable(pi pi.go) +add_executable(test-malloc test-malloc.c) +add_executable(test-malloc-mt test-malloc-mt.c) +target_link_libraries(test-malloc-mt pthread) + add_executable(server server.go) target_link_libraries(server netgo) diff --git a/usr/tests/test-malloc-mt.c b/usr/tests/test-malloc-mt.c new file mode 100644 index 000000000..186fe50a0 --- /dev/null +++ b/usr/tests/test-malloc-mt.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +#ifndef NUM_THREADS +#define NUM_THREADS 3 +#endif + +#ifndef NUM_ITER +#define NUM_ITER 10000 +#endif + +#ifndef SIZE +#define SIZE 16384 +#endif + +void* perform_work( void* argument ) +{ + int passed_in_value; + + passed_in_value = *( ( int* )argument ); + printf( "Hello World! It's me, thread with argument %d!\n", passed_in_value ); + + /* optionally: insert more useful stuff here */ + int i; + void* buf; + for(i=0; i +#include +#include + +#ifndef NUM_ITER +#define NUM_ITER 100000 +#endif + +#ifndef SIZE +#define SIZE 16*1024 +#endif + +int main(int argc, char** argv) +{ + /* optionally: insert more useful stuff here */ + void* buf; + + for(int i=0; i