yaffs Added a README file and some more tests.
[yaffs2.git] / direct / timothy_tests / quick_tests / test_yaffs_stat.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Timothy Manning <timothy@yaffs.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include "test_yaffs_stat.h"
15
16 int test_yaffs_stat(void){
17         int mode=0;
18         int size=0;
19         mode =yaffs_test_stat_mode();
20         printf("\nmode %o\n",mode);
21         printf("expected mode %o \n",FILE_MODE);
22         printf("anding together %o\n",FILE_MODE & mode);
23         printf("%d\n",FILE_MODE == (FILE_MODE & mode));
24         if (FILE_MODE == (FILE_MODE & mode)){
25                 mode=1;
26         }
27         else {
28                 printf("mode did not match expected file mode\n");
29                 return -1;
30         }
31         if (yaffs_test_stat_size()==FILE_SIZE){
32                 size=1;
33         }
34         else {
35                 printf("mode did not match expected file mode\n");
36                 return -1;
37         }
38         
39         if (mode && size){
40                 return 1;
41         }
42         else {
43                 /* a test failed*/
44                 return -1;
45         }
46
47 }
48
49 int test_yaffs_stat_clean(void){
50         return 1;
51 }
52
53 int yaffs_test_stat_mode(void){
54         struct yaffs_stat stat;
55         int output=0;
56         output=yaffs_stat(FILE_PATH, &stat);
57         printf("output: %d\n",output);
58         if (output>=0){
59                 return stat.st_mode;    
60         }
61         else {
62                 printf("failed to stat file\n") ;
63                 return -1;
64         }
65 }
66
67 int yaffs_test_stat_size(void){
68         struct yaffs_stat stat;
69         int output=0;
70         output=yaffs_stat(FILE_PATH, &stat); 
71         if (output>=0){
72                 return stat.st_size;    
73         }
74         else {
75                 printf("failed to stat file\n") ;
76                 return -1;
77         }
78 }
79
80