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_EISDIR.c
1 #include "test_yaffs_open_EISDIR.h"
2
3 /*EISDIR is caused by trying to open a directory */
4
5 static int handle=0;
6 int test_yaffs_open_EISDIR(void){
7         int output=0;
8         int error_code=0;
9         /*printf("path %s\n",path); */
10         handle=yaffs_open(YAFFS_MOUNT_POINT, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
11         if (handle==-1){
12                 error_code=yaffs_get_error();
13                 printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
14                 if (abs(error_code)== EISDIR){
15                         return 1;
16                 }
17                 else {
18                         printf("different error than expected\n");
19                         return -1;
20                 }
21         }
22         else if (output >=0){
23                 printf("non existant directory opened.(which is a bad thing)\n");
24                 return -1;
25         }
26         /* the program should not get here but the compiler is complaining */
27         return -1;
28 }
29 int test_yaffs_open_EISDIR_clean(void){
30         if (handle >=0){
31                 return yaffs_close(handle);
32         }
33         else {
34                 return 1;       /* the file failed to open so there is no need to close it*/
35         }
36 }
37