yaffs Adding more error code test programs to quick tests. note the bugs are still...
[yaffs2.git] / direct / timothy_tests / quick_tests / test_yaffs_open_EEXIST.c
1 #include "test_yaffs_open_EEXIST.h"
2
3 static int handle=0;
4 int test_yaffs_open_EEXIST(void){
5         int output=0;
6         int error_code=0;
7         /*printf("path %s\n",path); */
8         handle=yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE );
9         if (handle==-1){
10                 error_code=yaffs_get_error();
11                 printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code);
12                 if (abs(error_code)== EEXIST){
13                         return 1;
14                 }
15                 else {
16                         printf("different error than expected\n");
17                         return -1;
18                 }
19         }
20         else if (output >=0){
21                 printf("non existant file opened.(which is a bad thing)\n");
22                 return -1;
23         }
24         /* the program should not get here but the compiler is complaining */
25         return -1;
26 }
27 int test_yaffs_open_EEXIST_clean(void){
28         if (handle >=0){
29                 return yaffs_close(handle);
30         }
31         else {
32                 return 1;       /* the file failed to open so there is no need to close it*/
33         }
34 }
35