acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

test_fs.c (1933B)

      1 #if LV_BUILD_TEST
      2 #include "../lvgl.h"
      3 
      4 #include "unity/unity.h"
      5 
      6 
      7 const char * read_exp =
      8     "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sed maximus orci. Morbi massa nisi, varius eu convallis ac, venenatis at metus. In in nibh id urna pretium feugiat vitae eu libero. Ut eget fringilla eros. Nunc ullamcorper lectus mauris, vel rhoncus velit volutpat et. Phasellus sed molestie massa. Maecenas quis dui sollicitudin, vulputate nunc ut, dictum quam. Nam a congue lorem. Nulla non facilisis sapien. Ut luctus nulla nibh, sed finibus urna porta non. Duis aliquet augue id urna euismod auctor. Integer pellentesque vulputate enim non mattis. Donec finibus mattis dolor, et feugiat nisi pharetra porta. Mauris ullamcorper cursus magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.";
      9 
     10 void setUp(void)
     11 {
     12     /* Function run before every test */
     13 }
     14 
     15 void tearDown(void)
     16 {
     17     /* Function run after every test */
     18 }
     19 #include <stdio.h>
     20 void test_read(void)
     21 {
     22     lv_fs_res_t res;
     23 
     24     /*'A' has cache*/
     25     lv_fs_file_t fa;
     26     res = lv_fs_open(&fa, "A:src/test_files/readtest.txt", LV_FS_MODE_RD);
     27     TEST_ASSERT_EQUAL(LV_FS_RES_OK, res);
     28 
     29     /*'B' has no cache*/
     30     lv_fs_file_t fb;
     31     res = lv_fs_open(&fb, "B:src/test_files/readtest.txt", LV_FS_MODE_RD);
     32     TEST_ASSERT_EQUAL(LV_FS_RES_OK, res);
     33 
     34     /*Use an odd size to make sure it's not aligned with the drivier's'cache size*/
     35     uint8_t buf[79];
     36     uint32_t cnt = 0;
     37     uint32_t br = 1;
     38     while(br) {
     39         res = lv_fs_read(&fa, buf, sizeof(buf), &br);
     40         TEST_ASSERT_EQUAL(LV_FS_RES_OK, res);
     41         TEST_ASSERT_TRUE(memcmp(buf, read_exp + cnt, br) == 0);
     42 
     43         res = lv_fs_read(&fb, buf, sizeof(buf), &br);
     44         TEST_ASSERT_EQUAL(LV_FS_RES_OK, res);
     45         TEST_ASSERT_TRUE(memcmp(buf, read_exp + cnt, br) == 0);
     46         cnt += br;
     47     }
     48 
     49     lv_fs_close(&fa);
     50     lv_fs_close(&fb);
     51 }
     52 
     53 #endif