From 02b0ab68dce75505c336039a66dbba6e95305283 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Sat, 24 Jul 2021 16:13:19 +1200 Subject: [PATCH] Finished the 64 bit YTIME_T test. Signed-off-by: Timothy Manning --- .../64_and_32_bit_time/64_bit/time_64_tests.c | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/time_64_tests.c b/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/time_64_tests.c index 8d10d27..44cd7eb 100644 --- a/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/time_64_tests.c +++ b/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/time_64_tests.c @@ -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; } -- 2.30.2