Finished the 64 bit YTIME_T test.
authorTimothy Manning <codedraftsman@gmail.com>
Sat, 24 Jul 2021 04:13:19 +0000 (16:13 +1200)
committerTimothy Manning <codedraftsman@gmail.com>
Sat, 24 Jul 2021 04:13:19 +0000 (16:13 +1200)
Signed-off-by: Timothy Manning <codedraftsman@gmail.com>
direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/time_64_tests.c

index 8d10d27ca7e7455938deb08b9807a16d2bd7b955..44cd7ebe989e3299d4eaf72d3df4f810a9d7224d 100644 (file)
@@ -1,4 +1,6 @@
 #include "yaffsfs.h"
+#include "yaffs_endian.h"
+
 #define YAFFS_MOUNT_POINT "/yflash2/"
 #define FILE_PATH "/yflash2/foo.txt"
 
@@ -20,9 +22,31 @@ int main()
 
     //create several times and save them
     //
+    struct yaffs_dev dev;
+
+    //need to set this to get the function to swap 
+    //endianess of the values.
+
+    //remember that the first two bytes are swapped to the 
+    //other end while still retaining their order.
+    // i.e. 0xfa.....  becomes 0x...fa
+    dev.swap_endian = 1; 
+
+    struct yaffs_obj_hdr oh;
+
+    oh.yst_atime = 0xaf1732b0;
+    oh.yst_mtime = 0xaf1732b0;
+    oh.yst_ctime = 0xaf1732b0;
+
+    yaffs_do_endian_oh(&dev,&oh);
+
+    //check that the endianess is correct
+    u64 expected = 0xb03217af;
+    if (oh.yst_atime != expected || oh.yst_mtime != expected || oh.yst_ctime != expected) {
+        printf("endian test failed, got %x\n",oh.yst_atime);
+        return 1;
+    } 
 
-    //extra tests
-    //save the time and get it to overflow.
     printf("all tests pass\n");
     return 0;
 }