From 965552e4465772dd3c12892216412fc01e651f6e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 19 Jul 2022 17:37:36 +0200 Subject: [PATCH] fix: make C tests work again --- src/extra/libs/fsdrv/lv_fs_stdio.c | 13 +----------- src/misc/lv_printf.h | 34 ++---------------------------- tests/src/test_cases/test_arc.c | 2 +- tests/src/test_cases/test_fs.c | 11 +++++++++- 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/src/extra/libs/fsdrv/lv_fs_stdio.c b/src/extra/libs/fsdrv/lv_fs_stdio.c index 4f9fa1670..00acad1fb 100644 --- a/src/extra/libs/fsdrv/lv_fs_stdio.c +++ b/src/extra/libs/fsdrv/lv_fs_stdio.c @@ -14,7 +14,6 @@ #ifndef WIN32 #include #include - #include #else #include #endif @@ -118,17 +117,7 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode) char buf[MAX_PATH_LEN]; lv_snprintf(buf, sizeof(buf), LV_FS_STDIO_PATH "%s", path); - void * a = fopen(buf, flags); - - printf("%s\n", path); - printf("%d\n", errno); - - char buf2[512]; - getcwd(buf2, 512); - printf("%s\n", buf2); - printf("%p\n", a); - - return a; + return fopen(buf, flags); } /** diff --git a/src/misc/lv_printf.h b/src/misc/lv_printf.h index fc9bb0a1f..76fe612f8 100644 --- a/src/misc/lv_printf.h +++ b/src/misc/lv_printf.h @@ -68,38 +68,8 @@ typedef struct { int lv_snprintf_builtin(char * buffer, size_t count, const char * format, ...); int lv_vsnprintf_builtin(char * buffer, size_t count, const char * format, va_list va); -/** - * Tiny snprintf/vsnprintf implementation - * \param buffer A pointer to the buffer where to store the formatted string - * \param count The maximum number of characters to store in the buffer, including a terminating null character - * \param format A string that specifies the format of the output - * \param va A value identifying a variable arguments list - * \return The number of characters that COULD have been written into the buffer, not counting the terminating - * null character. A value equal or larger than count indicates truncation. Only when the returned value - * is non-negative and less than count, the string has been completely written. - */ -LV_FORMAT_ATTRIBUTE(3, 4) static inline int lv_snprintf(char * buffer, size_t count, const char * format, ...) -{ - - /* Declare a va_list type variable */ - va_list args; - - /* Initialise the va_list variable with the ... after fmt */ - va_start(args, format); - - /* Forward the '...' to vprintf */ - int ret = LV_SNPRINTF(buffer, count, format, args); - - /* Clean up the va_list */ - va_end(args); - - return ret; -} - -LV_FORMAT_ATTRIBUTE(3, 0) static inline int lv_vsnprintf(char * buffer, size_t count, const char * format, va_list va) -{ - return LV_VSNPRINTF(buffer, count, format, va); -} +#define lv_snprintf LV_SNPRINTF +#define lv_vsnprintf LV_VSNPRINTF #ifdef __cplusplus diff --git a/tests/src/test_cases/test_arc.c b/tests/src/test_cases/test_arc.c index adb303774..87fb9587f 100644 --- a/tests/src/test_cases/test_arc.c +++ b/tests/src/test_cases/test_arc.c @@ -129,7 +129,7 @@ void test_arc_click_area_with_adv_hittest(void) lv_obj_set_size(arc, 100, 100); lv_obj_set_style_arc_width(arc, 10, 0); lv_obj_add_flag(arc, LV_OBJ_FLAG_ADV_HITTEST); - lv_obj_add_event_cb(arc, dummy_event_cb, LV_EVENT_VALUE_CHANGED, NULL); + lv_obj_add_event_cb(arc, dummy_event_cb, LV_EVENT_PRESSED, NULL); lv_obj_set_ext_click_area(arc, 5); /*No click detected at the middle*/ diff --git a/tests/src/test_cases/test_fs.c b/tests/src/test_cases/test_fs.c index 831a8ec4d..6c6277b0b 100644 --- a/tests/src/test_cases/test_fs.c +++ b/tests/src/test_cases/test_fs.c @@ -17,13 +17,22 @@ void tearDown(void) /* Function run after every test */ } #include +#include +#include void test_read(void) { lv_fs_res_t res; + char cur[512]; + getcwd(cur, 512); + errno = 0; + void * a = fopen("src/test_files/readtest.txt", "rd"); + printf("%s, %d, %p\n", cur, errno, a); + fclose(a); + /*'A' has cache*/ lv_fs_file_t fa; - res = lv_fs_open(&fa, "A:readtest.txt", LV_FS_MODE_RD); + res = lv_fs_open(&fa, "A:src/test_files/readtest.txt", LV_FS_MODE_RD); TEST_ASSERT_EQUAL(LV_FS_RES_OK, res); /*'B' has no cache*/