yaffs Are trapping a suspeced bug in quick_tests.
[yaffs2.git] / direct / timothy_tests / quick_tests / test_yaffs_stat.c
1 #include "test_yaffs_stat.h"
2
3 int test_yaffs_stat(void){
4         int mode=0;
5         int size=0;
6         mode =yaffs_test_stat_mode();
7         printf("\nmode %o\n",mode);
8         printf("expected mode %o \n",FILE_MODE);
9         printf("anding together %o\n",FILE_MODE & mode);
10         printf("%d\n",FILE_MODE == (FILE_MODE & mode));
11         if (FILE_MODE == (FILE_MODE & mode)){
12                 mode=1;
13         }
14         else {
15                 printf("mode did not match expected file mode\n");
16                 return -1;
17         }
18         if (yaffs_test_stat_size()==FILE_SIZE){
19                 size=1;
20         }
21         else {
22                 printf("mode did not match expected file mode\n");
23                 return -1;
24         }
25         
26         if (mode && size){
27                 return 1;
28         }
29         else {
30                 /* a test failed*/
31                 return -1;
32         }
33
34 }
35
36 int test_yaffs_stat_clean(void){
37         return test_open_file();
38 }
39
40 int yaffs_test_stat_mode(void){
41         struct yaffs_stat stat;
42         int output=0;
43         output=yaffs_stat(FILE_PATH, &stat);
44         printf("output: %d\n",output);
45         if (output>=0){
46                 return stat.st_mode;    
47         }
48         else {
49                 printf("failed to stat file\n") ;
50                 return -1;
51         }
52 }
53
54 int yaffs_test_stat_size(void){
55         struct yaffs_stat stat;
56         int output=0;
57         output=yaffs_stat(FILE_PATH, &stat); 
58         if (output>=0){
59                 return stat.st_size;    
60         }
61         else {
62                 printf("failed to stat file\n") ;
63                 return -1;
64         }
65 }
66
67