Finished the 32 and 64 bit tests.
[yaffs2.git] / direct / test-framework / unit_tests / 64_and_32_bit_time / 64_bit / time_64_tests.c
1 #include "yaffsfs.h"
2 #include "yaffs_endian.h"
3
4 #define YAFFS_MOUNT_POINT "/yflash2/"
5 #define FILE_PATH "/yflash2/foo.txt"
6
7 int random_seed;
8 int simulate_power_failure = 0;
9
10
11 int main()
12 {
13         yaffs_start_up();
14
15     //test that ytime is 64 bits
16
17     if (sizeof(YTIME_T) != 8) {
18         printf("Error:size of YTIME_T is not 64 bits\n");
19         return 1;
20     }
21
22     struct yaffs_obj obj;
23     if (sizeof(obj.yst_atime) != 8) {
24             printf("Error: size of yaffs_obj.yst_atime is not 64 bits\n");
25             return 1;
26     }
27
28     //create several times and save them
29     //
30     struct yaffs_dev dev;
31
32     //need to set this to get the function to swap 
33     //endianess of the values.
34
35     //remember that the first two bytes are swapped to the 
36     //other end while still retaining their order.
37     // i.e. 0xfa.....  becomes 0x...fa
38     dev.swap_endian = 1; 
39
40     struct yaffs_obj_hdr oh;
41
42     oh.yst_atime = 0xaf1732b0;
43     oh.yst_mtime = 0xaf1732b0;
44     oh.yst_ctime = 0xaf1732b0;
45
46     yaffs_do_endian_oh(&dev,&oh);
47
48     //check that the endianess is correct
49     u32 expected = 0xb03217af;
50     if (oh.yst_atime != expected ) {
51         printf("endian test failed for yst_atime, got %x expected %x\n",oh.yst_atime,expected);
52         return 1;
53     } 
54     if (oh.yst_mtime != expected) {
55         printf("endian test failed for yst_mtime, got %x, expected %x\n",oh.yst_mtime,expected);
56         return 1;
57     }
58     if (oh.yst_ctime != expected) {
59         printf("endian test failed for yst_ctime, got %x, expected %x\n",oh.yst_ctime,expected);
60         return 1;
61     }
62
63     printf("all tests pass\n");
64     return 0;
65 }