diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-08-30 14:08:07 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-08-30 14:08:07 +0200 |
commit | 717eff71dda38a947dc4fd77f51cafd796ce9693 (patch) | |
tree | 7b3af1f4c7fa7d4d064df6f3b14db4bef9a589d1 /tests | |
parent | ad95cbc5423458ec47cfdde74add2b9bf157667a (diff) | |
download | libssh-717eff71dda38a947dc4fd77f51cafd796ce9693.tar.gz libssh-717eff71dda38a947dc4fd77f51cafd796ce9693.tar.xz libssh-717eff71dda38a947dc4fd77f51cafd796ce9693.zip |
Added test for the openssl threading
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/unittests/torture_rand.c | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index 28aa50b..394fab2 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -7,3 +7,4 @@ add_check_test(torture_knownhosts torture_knownhosts.c ${TORTURE_LIBRARY}) add_check_test(torture_list torture_list.c ${TORTURE_LIBRARY}) add_check_test(torture_misc torture_misc.c ${TORTURE_LIBRARY}) add_check_test(torture_options torture_options.c ${TORTURE_LIBRARY}) +add_check_test(torture_rand torture_rand.c ${TORTURE_LIBRARY}) diff --git a/tests/unittests/torture_rand.c b/tests/unittests/torture_rand.c new file mode 100644 index 0000000..12dfab7 --- /dev/null +++ b/tests/unittests/torture_rand.c @@ -0,0 +1,49 @@ +#define LIBSSH_STATIC +#include <libssh/priv.h> +#include <pthread.h> +#include "torture.h" + +#define NUM_LOOPS 50000 +#define NUM_THREADS 200 + +static void setup(){ + ssh_init(); +} + +static void *torture_rand_thread(void *threadid){ + char buffer[12]; + int i; + int r; + (void)threadid; + buffer[0]=buffer[1]=buffer[10]=buffer[11]='X'; + for(i=0;i<NUM_LOOPS;++i){ + r=ssh_get_random(&buffer[2], i%8+1 ,0); + } + pthread_exit(NULL); +} + +START_TEST(torture_rand_threading) +{ + pthread_t threads[NUM_THREADS]; + int i; + int err; + for(i=0;i<NUM_THREADS;++i){ + err=pthread_create(&threads[i],NULL,torture_rand_thread,NULL); + ck_assert_int_eq(err,0); + } + for(i=0;i<NUM_THREADS;++i){ + err=pthread_join(threads[i], NULL); + ck_assert_int_eq(err,0); + } +} +END_TEST + + + +Suite *torture_make_suite(void) { + Suite *s = suite_create("torture_rand"); + + torture_create_case_fixture(s, "torture_rand_threading", torture_rand_threading,setup,NULL); + + return s; +} |