2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2018 Aleph One Ltd.
6 * Created by Timothy Manning <timothy@yaffs.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include "handle_test.h"
16 int simulate_power_failure = 0;
21 int test_batch = 1000000;
23 unsigned int total_number_of_tests_run=0;
25 yaffs_mount("yaffs2");
27 printf("running tests\n");
30 printf("dup test: %d\n ",output);
33 output = open_close_handle_test(test_batch);
35 total_number_of_tests_run ++;
40 printf("total number of tests = %d\n",(total_number_of_tests_run*test_batch));
51 handle =open_handle();
53 printf("error: failed to open handle\n");
56 handle2=yaffs_dup(handle);
58 printf("error: failed to open handle2\n");
62 output=yaffs_lseek(handle,20,SEEK_SET);
64 output = yaffs_lseek(handle,0,SEEK_CUR);
66 printf("dup is working\n");
68 } else if (output <0){
69 printf("failed to lseek the second time\n");
72 printf("lseek position is diffrent than expected\n");
76 printf("failed to lseek the first time\n");
82 int open_close_handle_test(int num_of_tests)
84 int handle_number=open_handle();
88 yaffs_close(handle_number);
89 for (x=0;x<num_of_tests;x++){
91 if (handle != handle_number){
92 printf("handle number changed\n");
93 printf("test number= %d\n",x);
94 printf("expected number = %d\n",handle_number);
95 printf("handle_number = %d\n",handle);
98 output=yaffs_close(handle);
100 printf("failed to close file\n");
110 error_code=yaffs_get_error();
111 printf("yaffs_error code %d\n",error_code);
112 printf("error is : %s\n",yaffs_error_to_str(error_code));
115 int open_handle(void)
117 return yaffs_open(FILE_PATH,O_CREAT | O_RDWR,S_IREAD | S_IWRITE);