X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=direct%2Ftest-framework%2Fstress_tests%2Fhandle_tests%2Fhandle_test.c;fp=direct%2Ftest-framework%2Fstress_tests%2Fhandle_tests%2Fhandle_test.c;h=ed721fbfab628e402fbb37f1755206d0bd9c1007;hb=a51c8b53c1d11f7c4690243c9685a9b337f51127;hp=0000000000000000000000000000000000000000;hpb=566822213e306533d20b3ca38fcadd0d3d8a633f;p=yaffs2.git diff --git a/direct/test-framework/stress_tests/handle_tests/handle_test.c b/direct/test-framework/stress_tests/handle_tests/handle_test.c new file mode 100644 index 0000000..ed721fb --- /dev/null +++ b/direct/test-framework/stress_tests/handle_tests/handle_test.c @@ -0,0 +1,119 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2018 Aleph One Ltd. + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "handle_test.h" + +int random_seed; +int simulate_power_failure = 0; + +int main() +{ + + int test_batch = 1000000; + int output =0; + unsigned int total_number_of_tests_run=0; + yaffs_start_up(); + yaffs_mount(YAFFS_MOUNT_POINT); + + printf("running tests\n"); + + output=dup_test(); + printf("dup test: %d\n ",output); + + while (1){ + output = open_close_handle_test(test_batch); + if (output>=0){ + total_number_of_tests_run ++; + } else { + get_error(); + return -1; + } + printf("total number of tests = %d\n",(total_number_of_tests_run*test_batch)); + } + + + return 0; +} +int dup_test(void){ + int handle = -1; + int handle2 = -1; + int output =-1; + + handle =open_handle(); + if (handle<0){ + printf("error: failed to open handle\n"); + return -1; + } + handle2=yaffs_dup(handle); + if (handle2<0){ + printf("error: failed to open handle2\n"); + return -1; + } + + output=yaffs_lseek(handle,20,SEEK_SET); + if (output >= 0) { + output = yaffs_lseek(handle,0,SEEK_CUR); + if (output == 20){ + printf("dup is working\n"); + return 1; + } else if (output <0){ + printf("failed to lseek the second time\n"); + return -1; + } else { + printf("lseek position is diffrent than expected\n"); + return -1; + } + } else { + printf("failed to lseek the first time\n"); + return -1; + } + +} + +int open_close_handle_test(int num_of_tests) +{ + int handle_number=open_handle(); + int handle=0; + int x =0; + int output=0; + yaffs_close(handle_number); + for (x=0;x