Finished the 64 bit YTIME_T test.
[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
23     //create several times and save them
24     //
25     struct yaffs_dev dev;
26
27     //need to set this to get the function to swap 
28     //endianess of the values.
29
30     //remember that the first two bytes are swapped to the 
31     //other end while still retaining their order.
32     // i.e. 0xfa.....  becomes 0x...fa
33     dev.swap_endian = 1; 
34
35     struct yaffs_obj_hdr oh;
36
37     oh.yst_atime = 0xaf1732b0;
38     oh.yst_mtime = 0xaf1732b0;
39     oh.yst_ctime = 0xaf1732b0;
40
41     yaffs_do_endian_oh(&dev,&oh);
42
43     //check that the endianess is correct
44     u64 expected = 0xb03217af;
45     if (oh.yst_atime != expected || oh.yst_mtime != expected || oh.yst_ctime != expected) {
46         printf("endian test failed, got %x\n",oh.yst_atime);
47         return 1;
48     } 
49
50     printf("all tests pass\n");
51     return 0;
52 }