From 9de407bd16e3a59ab43bced7ebf488b93dda1217 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Tue, 10 Aug 2021 09:01:10 +1200 Subject: [PATCH] Adding more time tests Signed-off-by: Timothy Manning --- .../64_and_32_bit_time/64_bit/Makefile | 9 ++-- .../64_and_32_bit_time/64_bit/create_64_bit.c | 45 +++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/create_64_bit.c diff --git a/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/Makefile b/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/Makefile index a682ed6..6cdcccd 100644 --- a/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/Makefile +++ b/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/Makefile @@ -21,9 +21,9 @@ YDI_FRAMEWORK_DIR = ../../../ CLEAN_OBJS = time_64_tests emfile-2k-0 emfile-nand emfile-nand128MB TESTFILES = time_64_tests.o -all: time_64_tests +all: time_64_tests create_64_bit -YAFFS_TEST_OBJS = $(COMMONTESTOBJS) $(TESTFILES) +YAFFS_TEST_OBJS = $(COMMONTESTOBJS) ALL_UNSORTED_OBJS += $(YAFFS_TEST_OBJS) $(FUZZER_OBJS) @@ -34,5 +34,8 @@ phony. test: time_64_tests ./time_64_tests time_64_tests: $(FRAMEWORK_SOURCES) $(YAFFS_TEST_OBJS) - gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS) -lpthread + gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS) time_64_tests.o -lpthread + +create_64_bit: $(FRAMEWORK_SOURCES) $(YAFFS_TEST_OBJS) + gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS) create_64_bit.o -lpthread diff --git a/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/create_64_bit.c b/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/create_64_bit.c new file mode 100644 index 0000000..1b8f03e --- /dev/null +++ b/direct/test-framework/unit_tests/64_and_32_bit_time/64_bit/create_64_bit.c @@ -0,0 +1,45 @@ +//#include +#include +#include "yaffsfs.h" + +#define TEST_PASS 0 +#define TEST_FAIL 1 + +#define YAFFS_MOUNT_POINT "/yflash2/" +#define FILE_PATH "/yflash2/foo.txt" + +int random_seed; +int simulate_power_failure = 0; + + +int setup_yaffs() { + yaffs_start_up(); + yaffs_set_trace(0); + if (yaffs_mount(YAFFS_MOUNT_POINT) < 0) { + printf("failed to mount %s/n", YAFFS_MOUNT_POINT); + return TEST_FAIL; + } + + return TEST_PASS; +} +int shared_create(int argc, char *argv[]){ + + if (argc != 3) { + printf("wrong number of arguments\n"); + printf("requires $ create file_name time\n"); + return TEST_FAIL; + } + + setup_yaffs(); + uint time = atoi(argv[2]); + char *file_path = argv[1]; + if (yaffs_open(FILE_PATH, O_CREAT | O_RDWR, S_IREAD |S_IWRITE)) { + printf("failed to open the file %s/n", FILE_PATH); + return TEST_FAIL; + } + printf("created file: %s, with time: %d\n", file_path, time); + return TEST_PASS; +} +int main(int argc, char *argv[] ){ + return shared_create(argc, argv); +} -- 2.30.2