diff --git a/tests/sftp_stress/main.c b/tests/sftp_stress/main.c new file mode 100644 index 00000000..c9b0ad9f --- /dev/null +++ b/tests/sftp_stress/main.c @@ -0,0 +1,174 @@ +/* + * main.c + * + * Created on: 22 juin 2009 + * Author: aris + */ +#include +#include +#include +#include +#include +#include +#include +#include +#define TEST_READ 1 +#define TEST_WRITE 2 +#define NTHREADS 3 +#define FILESIZE 100000 +unsigned char samplefile[FILESIZE]; +volatile int stop=0; + +const char* hosts[]={"localhost","barebone"}; +void signal_stop(){ + stop=1; + printf("Stopping...\n"); +} + +SSH_SESSION *connect_host(const char *hostname); +int sftp_test(SSH_SESSION *session, int test); + +int docycle(const char *host, int test){ + SSH_SESSION *session=connect_host(host); + int ret=SSH_ERROR; + if(!session){ + printf("connect failed\n"); + } else { + printf("Connected\n"); + ret=sftp_test(session,test); + if(ret != SSH_OK){ + printf("Error in sftp\n"); + } + ssh_disconnect(session); + } + return ret; +} + +int thread(){ + while(docycle(hosts[rand()%2],TEST_WRITE) == SSH_OK) + if(stop) + break; + return 0; +} + +int main(int argc, char **argv){ + int i; + pthread_t threads[NTHREADS]; + ssh_init(); + srand(time(NULL)); + for(i=0;i