18081a7428d777b4d72fa77dd67cb180bf301254
[yaffs2.git] / direct / timothy_tests / quick_tests / test_yaffs_open_ENOTDIR.c
1 #include "test_yaffs_open_ENOTDIR.h"
2
3 static int handle=0;
4 int test_yaffs_open_ENOTDIR(void){
5         int output=0;
6         int error_code=0;
7         /*printf("path %s\n",path); */
8         handle=yaffs_open("/nonexisting_dir/foo", O_TRUNC| O_RDWR,FILE_MODE );
9         if (handle==-1){
10                 error_code=yaffs_get_error();
11                 if (abs(error_code)==ENOTDIR){
12                         return 1;
13                 }
14                 else {
15                         printf("different error than expected\n");
16                         return -1;
17                 }
18         }
19         else if (output >=0){
20                 printf("non existant directory opened.(which is a bad thing)\n");
21                 return -1;
22         }
23
24 }
25 int test_yaffs_open_ENOTDIR_clean(void){
26         if (handle >=0){
27                 return yaffs_close(handle);
28         }
29         else {
30                 return 1;       /* the file failed to open so there is no need to close it*/
31         }
32 }
33