2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Timothy Manning <timothy@yaffs.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include "handle_test.h"
17 int simulate_power_failure = 0;
22 int test_batch = 1000000;
24 unsigned int total_number_of_tests_run=0;
26 yaffs_mount("yaffs2");
28 printf("running tests\n");
31 printf("dup test: %d\n ",output);
34 output = open_close_handle_test(test_batch);
36 total_number_of_tests_run ++;
41 printf("total number of tests = %d\n",(total_number_of_tests_run*test_batch));
52 handle =open_handle();
54 printf("error: failed to open handle\n");
57 handle2=yaffs_dup(handle);
59 printf("error: failed to open handle2\n");
63 output=yaffs_lseek(handle,20,SEEK_SET);
65 output = yaffs_lseek(handle,0,SEEK_CUR);
67 printf("dup is working\n");
69 } else if (output <0){
70 printf("failed to lseek the second time\n");
73 printf("lseek position is diffrent than expected\n");
77 printf("failed to lseek the first time\n");
83 int open_close_handle_test(int num_of_tests)
85 int handle_number=open_handle();
89 yaffs_close(handle_number);
90 for (x=0;x<num_of_tests;x++){
92 if (handle != handle_number){
93 printf("handle number changed\n");
94 printf("test number= %d\n",x);
95 printf("expected number = %d\n",handle_number);
96 printf("handle_number = %d\n",handle);
99 output=yaffs_close(handle);
101 printf("failed to close file\n");
111 error_code=yaffs_get_error();
112 printf("yaffs_error code %d\n",error_code);
113 printf("error is : %s\n",yaffs_error_to_str(error_code));
116 int open_handle(void)
118 return yaffs_open(FILE_PATH,O_CREAT | O_RDWR,S_IREAD | S_IWRITE);