From 783779c870bd02a8eaf7d5bf5f694906b7454d67 Mon Sep 17 00:00:00 2001 From: morris Date: Fri, 3 Apr 2020 16:53:11 +0800 Subject: [PATCH] esp_rom: move rom api test into esp_rom component --- components/esp32/test/CMakeLists.txt | 12 +- components/esp32/test/component.mk | 8 - components/esp32/test/test_miniz.c | 77 -------- components/esp32s2/test/CMakeLists.txt | 13 +- components/esp32s2/test/logo.jpg | Bin 7561 -> 0 bytes components/esp32s2/test/test_libgcc.c | 185 ------------------ components/esp_rom/test/CMakeLists.txt | 12 ++ components/esp_rom/test/component.mk | 15 ++ components/{esp32 => esp_rom}/test/logo.jpg | Bin .../{esp32 => esp_rom}/test/test_libgcc.c | 9 +- components/esp_rom/test/test_miniz.c | 105 ++++++++++ .../{esp32 => esp_rom}/test/test_tjpgd.c | 16 +- 12 files changed, 147 insertions(+), 305 deletions(-) delete mode 100644 components/esp32/test/test_miniz.c delete mode 100644 components/esp32s2/test/logo.jpg delete mode 100644 components/esp32s2/test/test_libgcc.c create mode 100644 components/esp_rom/test/CMakeLists.txt create mode 100644 components/esp_rom/test/component.mk rename components/{esp32 => esp_rom}/test/logo.jpg (100%) rename components/{esp32 => esp_rom}/test/test_libgcc.c (97%) create mode 100644 components/esp_rom/test/test_miniz.c rename components/{esp32 => esp_rom}/test/test_tjpgd.c (90%) diff --git a/components/esp32/test/CMakeLists.txt b/components/esp32/test/CMakeLists.txt index a0940e047..297fa6370 100644 --- a/components/esp32/test/CMakeLists.txt +++ b/components/esp32/test/CMakeLists.txt @@ -1,18 +1,8 @@ if(IDF_TARGET STREQUAL "esp32") idf_component_register(SRC_DIRS . - PRIV_INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR} + PRIV_INCLUDE_DIRS . PRIV_REQUIRES unity test_utils nvs_flash ulp esp_common ) - - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h" - COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h" - WORKING_DIRECTORY ${COMPONENT_DIR} - DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg") - - add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h") - - add_dependencies(${COMPONENT_LIB} esp32_test_logo) - target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ld_include_test_dport_xt_highint5") endif() diff --git a/components/esp32/test/component.mk b/components/esp32/test/component.mk index d4b5a9012..b68857397 100644 --- a/components/esp32/test/component.mk +++ b/components/esp32/test/component.mk @@ -2,15 +2,7 @@ #Component Makefile # -COMPONENT_EXTRA_CLEAN := test_tjpgd_logo.h - COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive \ -u ld_include_test_dport_xt_highint5 \ COMPONENT_SRCDIRS := . - -test_tjpgd.o: test_tjpgd_logo.h - -test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg - $(summary) XXD logo.jpg - cd $(COMPONENT_PATH); xxd -i logo.jpg $(COMPONENT_BUILD_DIR)/test_tjpgd_logo.h diff --git a/components/esp32/test/test_miniz.c b/components/esp32/test/test_miniz.c deleted file mode 100644 index e4a6c9944..000000000 --- a/components/esp32/test/test_miniz.c +++ /dev/null @@ -1,77 +0,0 @@ - - -#include -#include "esp32/rom/miniz.h" -#include "unity.h" - - -#define DATASIZE (1024*64) - -TEST_CASE("Test miniz compression/decompression", "[miniz][ignore]") -{ - int x; - char b; - char *inbuf, *outbuf; - tdefl_compressor *comp; - tinfl_decompressor *decomp; - tdefl_status status; - size_t inbytes = 0, outbytes = 0, inpos = 0, outpos = 0, compsz; - printf("Allocating data buffer and filling it with semi-random data\n"); - inbuf = malloc(DATASIZE); - TEST_ASSERT(inbuf != NULL); - srand(0); - for (x = 0; x < DATASIZE; x++) { - inbuf[x] = (x & 1) ? rand() & 0xff : 0; - } - printf("Allocating compressor & outbuf (%d bytes)\n", sizeof(tdefl_compressor)); - comp = malloc(sizeof(tdefl_compressor)); - TEST_ASSERT(comp != NULL); - outbuf = malloc(DATASIZE); - TEST_ASSERT(outbuf != NULL); - printf("Compressing...\n"); - status = tdefl_init(comp, NULL, NULL, TDEFL_WRITE_ZLIB_HEADER | 1500); - TEST_ASSERT(status == TDEFL_STATUS_OKAY); - while (inbytes != DATASIZE) { - outbytes = DATASIZE - outpos; - inbytes = DATASIZE - inpos; - tdefl_compress(comp, &inbuf[inpos], &inbytes, &outbuf[outpos], &outbytes, TDEFL_FINISH); - printf("...Compressed %d into %d bytes\n", inbytes, outbytes); - inpos += inbytes; outpos += outbytes; - } - compsz = outpos; - free(comp); - //Kill inbuffer - for (x = 0; x < DATASIZE; x++) { - inbuf[x] = 0; - } - free(inbuf); - - inbuf = outbuf; - outbuf = malloc(DATASIZE); - TEST_ASSERT(outbuf != NULL); - printf("Reinflating...\n"); - decomp = malloc(sizeof(tinfl_decompressor)); - TEST_ASSERT(decomp != NULL); - tinfl_init(decomp); - inpos = 0; outpos = 0; - while (inbytes != compsz) { - outbytes = DATASIZE - outpos; - inbytes = compsz - inpos; - tinfl_decompress(decomp, (const mz_uint8 *)&inbuf[inpos], &inbytes, (uint8_t *)outbuf, (mz_uint8 *)&outbuf[outpos], &outbytes, TINFL_FLAG_PARSE_ZLIB_HEADER); - printf("...Decompressed %d into %d bytes\n", inbytes, outbytes); - inpos += inbytes; outpos += outbytes; - } - printf("Checking if same...\n"); - srand(0); - for (x = 0; x < DATASIZE; x++) { - b = (x & 1) ? rand() & 0xff : 0; - if (outbuf[x] != b) { - printf("Pos %x: %hhx!=%hhx\n", x, outbuf[x], b); - TEST_ASSERT(0); - } - } - printf("Great Success!\n"); - free(inbuf); - free(outbuf); - free(decomp); -} diff --git a/components/esp32s2/test/CMakeLists.txt b/components/esp32s2/test/CMakeLists.txt index 155d8969f..7d5e8e395 100644 --- a/components/esp32s2/test/CMakeLists.txt +++ b/components/esp32s2/test/CMakeLists.txt @@ -1,18 +1,7 @@ if(IDF_TARGET STREQUAL "esp32s2") idf_component_register(SRC_DIRS . - PRIV_INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR} + PRIV_INCLUDE_DIRS . PRIV_REQUIRES unity test_utils nvs_flash ulp esp_common ) - - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h" - COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h" - WORKING_DIRECTORY ${COMPONENT_DIR} - DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg") - - add_custom_target(esp32s2_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h") - - add_dependencies(${COMPONENT_LIB} esp32s2_test_logo) - - target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ld_include_test_dport_xt_highint5") endif() diff --git a/components/esp32s2/test/logo.jpg b/components/esp32s2/test/logo.jpg deleted file mode 100644 index 2bd9e775eac4d4195d9d7465239fa007715ff428..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7561 zcmbW42UHYExTt$F8HO2 z-#8He2Qg0o(75Is>hIy^9*E&{;m3%{$;o1{_z-V=V4$#xvx}FrKMtdD&Bxc75DEZ) zzw>z%Kzm+W46(@4Vsg^b!r~&t^8X|Mt??hP{~pfg_HU1Grhm;Dh<@Z>-M_K_>aLXo zfb0RWHtGNBuI2$i$87*$nEzMDRSE#qF#ym$_S^f=pRX79z(8O5OP4}ILPR|9E+Xdz z{YU<<4*z)m*YMkTBIo1%Q#*_%-qktCI}meTRF`Ys*Mj^p0lv;Ic#QD>xrqPAfxo5o zTOLAYcvrkXo zGlm8r+amxJMGio&6ca6=f9B1A)CxG?dDd)ef3JHY6YYPs|EU3|5g)+;9&VU(wT77m z#wEx<_?(G*;=F+YWB@gQ1{i^h04Kl)2m|7P44?q00$P9`U<_CQHh=@*0=NS{fIkod zgac7PERY1G19yRZpaiG{YJo=J0nhK|`P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LO@STyq*(4w~H>vl*F2bF6$4q$+C8t9@-ISXZnS zoq^rv*)->4s1iu7v}4&|9<17*79d9}W?nMyb}_Tuuv-c7G+_X1RQNyO1UIHu$6A@G zA--h9_EBhb-gwd+Vy$kuZipRYLB+U#ivQ?o8y_DQ*2zF)b(sqkOY-jCvI==|!!xh< z->+?#h}ljk1wU{V3Sf;Z{;&X*4{$eLY|}z)<+ujR=w;#+E81T%32e>}w+d_(RgK5m z_ujM_owxF;xwqYr)qOFlt~Oa1`Mpm`*4HAz1@j07YafbEMjt1WU_J-G+NkRcYmWZ% znbZ7*cehet(1c3+g!wyLIeIm2n1`StI&-*&rz&eeQJDR5`L!6qsRc)=&4{+cxcD5O z;=S#?aOXttHzM`b(+&P@ORE>8&Z8 zb>5>VuY(ZD6l=0;wO>r0l6dMVY>4f~y*mf=HLJf~Cxto&9{d^>#_BTUN((af zOeFKVCdWV5=|#@~vk^UoDU^N0t_3j6Y|>e9>FC4LSiYMfumWaMk( z$T6j)k=r=}@r4u^+^aD&tE8g&KHCm*Ee$R4?|5!w*};8#i=(|QZ~rv5srG#0Dqh5;u|w3RBs;H%|yB7UEues z4?8u=6w~;jlow-@(<%CugQHx<4|yE_Rqb@Y@h+!Ky$_wm{g*GfKsc8pVbUa(#;uaM zQcZ_K$(a<|oc5oOOkcZ?JA1hAqzH3RxB6OfYxgKpHZ7;NiTuLAle* z_f^9D8PFs|GaQk)f}R$z@^Df1PyZet$w-^7f5eydUdi-P_4P;yuB@Uw9Y>0Zyk1~D zA~UojJCpf(4Ol?aXlH0Jon%T9f4i1>U($wd z&ORag#YMeAu2Jx&B;7Qi%0Y4RR}|vp8EfE_>gkuhG{n!;&c)5z7ozVUF~>zxkDpdF HoxS-F9Fyzg diff --git a/components/esp32s2/test/test_libgcc.c b/components/esp32s2/test/test_libgcc.c deleted file mode 100644 index 7fca990d4..000000000 --- a/components/esp32s2/test/test_libgcc.c +++ /dev/null @@ -1,185 +0,0 @@ -#include -#include "unity.h" - -TEST_CASE("libgcc math functions", "[rom]") -{ - extern int64_t __absvdi2(int64_t x); - TEST_ASSERT(__absvdi2(-1L) == 1); - extern int __absvsi2(int x); - TEST_ASSERT(__absvsi2(-1) == 1); - extern double __adddf3(double x, double y); - TEST_ASSERT(__adddf3(1.0, 4.0) == 5.0); - extern float __addsf3(float x, float y); - TEST_ASSERT(__addsf3(1.0f, 4.0f) == 5.0f); - extern int64_t __addvdi3(int64_t x, int64_t y); - TEST_ASSERT(__addvdi3(1L, 4L) == 5L); - extern int __addvsi3(int x, int y); - TEST_ASSERT(__addvsi3(1, 4) == 5); - extern int64_t __ashldi3(int64_t x, int y); - TEST_ASSERT(__ashldi3(1, 4) == 16); - extern int64_t __ashrdi3(int64_t x, int y); - TEST_ASSERT(__ashrdi3(4, 1) == 2); - extern int64_t __bswapdi2(int64_t x); - TEST_ASSERT(__bswapdi2(0xaabbccddeeff0011ULL) == 0x1100ffeeddccbbaaULL); - extern int32_t __bswapsi2(int32_t x); - TEST_ASSERT(__bswapsi2(0xaabbccdd) == 0xddccbbaa); - extern int64_t __clrsbdi2(int64_t x); - TEST_ASSERT(__clrsbdi2(-1) == 63); - extern int __clrsbsi2(int x); - TEST_ASSERT(__clrsbsi2(-1) == 31); - extern int __clzdi2(int64_t x); - TEST_ASSERT(__clzdi2(1) == 63); - extern int __clzsi2(int x); - TEST_ASSERT(__clzsi2(1) == 31); - extern int __cmpdi2(int64_t x, int64_t y); - TEST_ASSERT(__cmpdi2(10, 10) == 1); - extern int __ctzdi2(uint64_t x); - TEST_ASSERT(__ctzdi2(0x8000000000000000ULL) == 63); - extern int __ctzsi2(unsigned x); - TEST_ASSERT(__ctzsi2(0x80000000U) == 31); - extern complex double __divdc3(double a, double b, double c, double d); - TEST_ASSERT(__divdc3(0, 1, 1, 0) == I); - extern double __divdf3(double x, double y); - TEST_ASSERT(__divdf3(16.0, 2.0) == 8.0); - extern int64_t __divdi3(int64_t x, int64_t y); - TEST_ASSERT(__divdi3(16, 2) == 8); - extern complex float __divsc3(float a, float b, float c, float d); - TEST_ASSERT(__divsc3(0, 1, 1, 0) == I); - extern float __divsf3(float x, float y); - TEST_ASSERT(__divsf3(16.0f, 2.0f) == 8.0f); - extern int __divsi3(int x, int y); - TEST_ASSERT(__divsi3(16, 2) == 8); - extern int __eqdf2(double x, double y); - TEST_ASSERT(__eqdf2(4.0, 4.0) == 0); - extern int __eqsf2(float x, float y); - TEST_ASSERT(__eqsf2(4.0f, 4.0f) == 0); - extern double __extendsfdf2(float x); - TEST_ASSERT(__extendsfdf2(4.0f) == 4.0); - extern int __ffsdi2(uint64_t x); - TEST_ASSERT(__ffsdi2(0x8000000000000000ULL) == 64); - extern int __ffssi2(unsigned x); - TEST_ASSERT(__ffssi2(0x80000000) == 32); - extern int64_t __fixdfdi(double x); - TEST_ASSERT(__fixdfdi(4.0) == 4LL); - extern int __fixdfsi(double x); - TEST_ASSERT(__fixdfsi(4.0) == 4); - extern int64_t __fixsfdi(float x); - TEST_ASSERT(__fixsfdi(4.0f) == 4LL); - extern int __fixsfsi(float x); - TEST_ASSERT(__fixsfsi(4.0f) == 4); - extern unsigned __fixunsdfsi(double x); - TEST_ASSERT(__fixunsdfsi(16.0) == 16); - extern uint64_t __fixunssfdi(float x); - TEST_ASSERT(__fixunssfdi(16.0f) == 16); - extern unsigned __fixunssfsi(float x); - TEST_ASSERT(__fixunssfsi(16.0f) == 16); - extern double __floatdidf(int64_t); - TEST_ASSERT(__floatdidf(-1LL) == -1.0f); - extern float __floatdisf(int64_t); - TEST_ASSERT(__floatdisf(-1LL) == -1.0f); - extern double __floatsidf(int x); - TEST_ASSERT(__floatsidf(-1) == -1.0); - extern float __floatsisf(int x); - TEST_ASSERT(__floatsisf(-1) == -1.0f); - extern double __floatundidf(uint64_t x); - TEST_ASSERT(__floatundidf(16) == 16.0); - extern float __floatundisf(uint64_t x); - TEST_ASSERT(__floatundisf(16) == 16.0f); - extern double __floatunsidf(unsigned x); - TEST_ASSERT(__floatunsidf(16) == 16.0); - extern float __floatunsisf(unsigned x); - TEST_ASSERT(__floatunsisf(16) == 16.0f); - extern int __gedf2(double x, double y); - TEST_ASSERT(__gedf2(2.0, 0.0) >= 0); - extern int __gesf2(float x, float y); - TEST_ASSERT(__gesf2(2.0f, 0.0f) >= 0); - extern int __gtdf2(double x, double y); - TEST_ASSERT(__gtdf2(2.0, 0.0) >= 0); - extern int __gtsf2(float x, float y); - TEST_ASSERT(__gtsf2(2.0f, 0.0f) >= 0); - extern int __ledf2(double x, double y); - TEST_ASSERT(__ledf2(0.0, 2.0) <= 0); - extern int __lesf2(float x, float y); - TEST_ASSERT(__lesf2(0.0f, 2.0f) <= 0); - extern int64_t __lshrdi3(int64_t x, int y); - TEST_ASSERT(__lshrdi3(0x8000000000000000LL, 1) == 0x4000000000000000LL); - extern int __ltdf2(double x, double y); - TEST_ASSERT(__ltdf2(0.0, 2.0) < 0); - extern int __ltsf2(float x, float y); - TEST_ASSERT(__ltsf2(0.0f, 2.0f) < 0); - extern int64_t __moddi3(int64_t x, int64_t y); - TEST_ASSERT(__moddi3(15, 2) == 1); - extern int __modsi3(int x, int y); - TEST_ASSERT(__modsi3(15, 2) == 1); - extern complex double __muldc3(double a, double b, double c, double d); - TEST_ASSERT(__muldc3(1.0, 0.0, 0.0, 1.0) == I); - extern double __muldf3(double x, double y); - TEST_ASSERT(__muldf3(2.0, 8.0) == 16.0); - extern int64_t __muldi3(int64_t x, int64_t y); - TEST_ASSERT(__muldi3(2, 8) == 16); - extern complex float __mulsc3 (float a, float b, float c, float d); - TEST_ASSERT(__mulsc3(1.0f, 0.0f, 0.0f, -1.0f) == -I); - extern float __mulsf3 (float a, float b); - TEST_ASSERT(__mulsf3(2.0f, 8.0f) == 16.0f); - extern int __mulsi3(int x, int y); - TEST_ASSERT(__mulsi3(2, 8) == 16); - extern int __mulvdi3(int64_t x, int64_t y); - TEST_ASSERT(__mulvdi3(2, 8) == 16); - extern int __mulvsi3(int x, int y); - TEST_ASSERT(__mulvsi3(2, 8) == 16); - extern int __nedf2(double x, double y); - TEST_ASSERT(__nedf2(2.0, 2.0) == 0); - extern double __negdf2(double x); - TEST_ASSERT(__negdf2(1.0) == -1.0); - extern int64_t __negdi2(int64_t x); - TEST_ASSERT(__negdi2(-1LL) == 1); - extern float __negsf2(float x); - TEST_ASSERT(__negsf2(-1.0f) == 1.0f); - extern int64_t __negvdi2(int64_t x); - TEST_ASSERT(__negvdi2(-1LL) == 1); - extern int __negvsi2(int x); - TEST_ASSERT(__negvsi2(-1) == 1); - extern int __nesf2(float x, float y); - TEST_ASSERT(__nesf2(2.0, 0.0) != 0); - extern int __paritysi2(unsigned x); - TEST_ASSERT(__paritysi2(0x10101010) == 0); - extern int __popcountdi2(uint64_t); - TEST_ASSERT(__popcountdi2(0xaaaaaaaa11111111ULL) == 24); - extern int __popcountsi2(unsigned x); - TEST_ASSERT(__popcountsi2(0x11111111) == 8); - extern double __powidf2(double x, int y); - TEST_ASSERT(__powidf2(2.0, -1) == 0.5); - extern float __powisf2(float x, int y); - TEST_ASSERT(__powisf2(2.0f, 2) == 4.0f); - extern double __subdf3(double x, double y); - TEST_ASSERT(__subdf3(2.0, 1.0) == 1.0); - extern float __subsf3(float x, float y); - TEST_ASSERT(__subsf3(5.0f, 4.0f) == 1.0f); - extern int64_t __subvdi3(int64_t x, int64_t y); - TEST_ASSERT(__subvdi3(-1LL, -1LL) == 0); - extern int __subvsi3(int x, int y); - TEST_ASSERT(__subvsi3(-1, -1) == 0); - extern float __truncdfsf2(double x); - TEST_ASSERT(__truncdfsf2(4.0) == 4.0f); - extern int __ucmpdi2(uint64_t x, uint64_t y); - TEST_ASSERT(__ucmpdi2(0x100000000ULL, 0x100000000ULL) == 1); - extern uint64_t __udivdi3(uint64_t x, uint64_t y); - TEST_ASSERT(__udivdi3(15, 2) == 7); - extern uint64_t __udivmoddi4(uint64_t x, uint64_t y, uint64_t* z); - uint64_t z; - TEST_ASSERT(__udivmoddi4(15, 2, &z) == 7); - TEST_ASSERT(z == 1); - extern unsigned __udivsi3(unsigned x, unsigned y); - TEST_ASSERT(__udivsi3(15, 2) == 7); - extern uint64_t __umoddi3(uint64_t x, uint64_t y); - TEST_ASSERT(__umoddi3(15, 2) == 1); - extern unsigned __umodsi3(unsigned x, unsigned y); - TEST_ASSERT(__umodsi3(15, 2) == 1); - extern uint64_t __umulsidi3(unsigned x, unsigned y); - TEST_ASSERT(__umulsidi3(0x10000000, 0x10000000) == 0x100000000000000ULL); - extern int __unorddf2(double x, double y); - TEST_ASSERT(__unorddf2(1.0, 2.0) == 0); - extern int __unordsf2(float x, float y); - TEST_ASSERT(__unordsf2(2.0f, 1.0f) == 0); - -} diff --git a/components/esp_rom/test/CMakeLists.txt b/components/esp_rom/test/CMakeLists.txt new file mode 100644 index 000000000..c28ddcca4 --- /dev/null +++ b/components/esp_rom/test/CMakeLists.txt @@ -0,0 +1,12 @@ +idf_component_register(SRC_DIRS . + PRIV_INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR} + PRIV_REQUIRES unity test_utils) + +if(IDF_TARGET STREQUAL "esp32") + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h" + COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h" + WORKING_DIRECTORY ${COMPONENT_DIR} + DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg") + add_custom_target(test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h") + add_dependencies(${COMPONENT_LIB} test_logo) +endif() diff --git a/components/esp_rom/test/component.mk b/components/esp_rom/test/component.mk new file mode 100644 index 000000000..07ea1205a --- /dev/null +++ b/components/esp_rom/test/component.mk @@ -0,0 +1,15 @@ +# +#Component Makefile +# + +COMPONENT_SRCDIRS := . + +COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive + +COMPONENT_EXTRA_CLEAN := test_tjpgd_logo.h + +test_tjpgd.o: test_tjpgd_logo.h + +test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg + $(summary) XXD logo.jpg + cd $(COMPONENT_PATH); xxd -i logo.jpg $(COMPONENT_BUILD_DIR)/test_tjpgd_logo.h diff --git a/components/esp32/test/logo.jpg b/components/esp_rom/test/logo.jpg similarity index 100% rename from components/esp32/test/logo.jpg rename to components/esp_rom/test/logo.jpg diff --git a/components/esp32/test/test_libgcc.c b/components/esp_rom/test/test_libgcc.c similarity index 97% rename from components/esp32/test/test_libgcc.c rename to components/esp_rom/test/test_libgcc.c index 7fca990d4..25c5ae7f1 100644 --- a/components/esp32/test/test_libgcc.c +++ b/components/esp_rom/test/test_libgcc.c @@ -1,7 +1,7 @@ #include #include "unity.h" -TEST_CASE("libgcc math functions", "[rom]") +TEST_CASE("libgcc math functions", "[rom][libgcc]") { extern int64_t __absvdi2(int64_t x); TEST_ASSERT(__absvdi2(-1L) == 1); @@ -117,9 +117,9 @@ TEST_CASE("libgcc math functions", "[rom]") TEST_ASSERT(__muldf3(2.0, 8.0) == 16.0); extern int64_t __muldi3(int64_t x, int64_t y); TEST_ASSERT(__muldi3(2, 8) == 16); - extern complex float __mulsc3 (float a, float b, float c, float d); + extern complex float __mulsc3(float a, float b, float c, float d); TEST_ASSERT(__mulsc3(1.0f, 0.0f, 0.0f, -1.0f) == -I); - extern float __mulsf3 (float a, float b); + extern float __mulsf3(float a, float b); TEST_ASSERT(__mulsf3(2.0f, 8.0f) == 16.0f); extern int __mulsi3(int x, int y); TEST_ASSERT(__mulsi3(2, 8) == 16); @@ -165,7 +165,7 @@ TEST_CASE("libgcc math functions", "[rom]") TEST_ASSERT(__ucmpdi2(0x100000000ULL, 0x100000000ULL) == 1); extern uint64_t __udivdi3(uint64_t x, uint64_t y); TEST_ASSERT(__udivdi3(15, 2) == 7); - extern uint64_t __udivmoddi4(uint64_t x, uint64_t y, uint64_t* z); + extern uint64_t __udivmoddi4(uint64_t x, uint64_t y, uint64_t *z); uint64_t z; TEST_ASSERT(__udivmoddi4(15, 2, &z) == 7); TEST_ASSERT(z == 1); @@ -181,5 +181,4 @@ TEST_CASE("libgcc math functions", "[rom]") TEST_ASSERT(__unorddf2(1.0, 2.0) == 0); extern int __unordsf2(float x, float y); TEST_ASSERT(__unordsf2(2.0f, 1.0f) == 0); - } diff --git a/components/esp_rom/test/test_miniz.c b/components/esp_rom/test/test_miniz.c new file mode 100644 index 000000000..1ba742b33 --- /dev/null +++ b/components/esp_rom/test/test_miniz.c @@ -0,0 +1,105 @@ +#include +#include +#include +#include +#include "sdkconfig.h" +#include "unity.h" + +// compression/decompression will take off a bunch of memory +// test it only with PSRAM enabled +#ifdef CONFIG_SPIRAM + +#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32) + +#if CONFIG_IDF_TARGET_ESP32 +#include "esp32/rom/miniz.h" +#elif CONFIG_IDF_TARGET_ESP32S2 +#include "esp32s2/rom/miniz.h" +#else +#error "unsupported target" +#endif + + +#define DATASIZE (1024 * 64) + +TEST_CASE("Test miniz compression/decompression", "[rom][miniz]") +{ + size_t inbytes = 0, outbytes = 0, inpos = 0, outpos = 0, compsz; + printf("Allocating data buffer and filling it with semi-random data\r\n"); + uint8_t *inbuf = calloc(1, DATASIZE); + TEST_ASSERT_NOT_NULL_MESSAGE(inbuf, "allocate input buffer failed"); + + srand(0); // semi random data + for (int i = 0; i < DATASIZE; i++) { + inbuf[i] = (i & 0x01) ? rand() & 0xff : 0; + } + + printf("Allocating compressor\r\n"); + tdefl_compressor *comp = calloc(1, sizeof(tdefl_compressor)); + TEST_ASSERT_NOT_NULL_MESSAGE(comp, "allocate tdefl_compressor failed"); + + uint8_t *outbuf = calloc(1, DATASIZE); + TEST_ASSERT_NOT_NULL_MESSAGE(outbuf, "allocate output buffer failed"); + + printf("Compressing...\r\n"); + tdefl_status comp_status = tdefl_init(comp, NULL, NULL, TDEFL_WRITE_ZLIB_HEADER | 1500); + TEST_ASSERT_EQUAL_MESSAGE(TDEFL_STATUS_OKAY, comp_status, "tdefl_init failed"); + + while (1) { + outbytes = DATASIZE - outpos; + inbytes = DATASIZE - inpos; + comp_status = tdefl_compress(comp, &inbuf[inpos], &inbytes, &outbuf[outpos], &outbytes, TDEFL_FINISH); + inpos += inbytes; + outpos += outbytes; + printf("...Compressed %d into %d bytes\r\n", inpos, outpos); + if (comp_status == TDEFL_STATUS_DONE) { + break; + } else if (comp_status != TDEFL_STATUS_OKAY) { + TEST_ASSERT_MESSAGE(0, "tdefl_compress failed"); + } + } + + compsz = outpos; + free(comp); + free(inbuf); + + inbuf = outbuf; + outbuf = calloc(1, DATASIZE); + TEST_ASSERT_NOT_NULL_MESSAGE(outbuf, "allocate output buffer failed"); + + printf("Decompressing...\r\n"); + tinfl_decompressor *decomp = calloc(1, sizeof(tinfl_decompressor)); + TEST_ASSERT_NOT_NULL_MESSAGE(decomp, "allocate tinfl_decompressor failed"); + tinfl_init(decomp); + + inpos = 0; + outpos = 0; + while (1) { + outbytes = DATASIZE - outpos; + inbytes = compsz - inpos; + tinfl_status decomp_status = tinfl_decompress(decomp, &inbuf[inpos], &inbytes, outbuf, &outbuf[outpos], &outbytes, TINFL_FLAG_PARSE_ZLIB_HEADER); + inpos += inbytes; + outpos += outbytes; + printf("...Decompressed %d into %d bytes\r\n", inpos, outpos); + if (decomp_status == TINFL_STATUS_DONE) { + break; + } else if (decomp_status < TINFL_STATUS_DONE) { + printf("decomp status=%d\r\n", decomp_status); + TEST_ASSERT_MESSAGE(0, "tinfl_decompress failed"); + } + } + + printf("Verifying data between compression and decompression...\r\n"); + srand(0); // semi random data + for (int i = 0; i < DATASIZE; i++) { + uint8_t original = (i & 1) ? rand() & 0xff : 0; + TEST_ASSERT_EQUAL_MESSAGE(original, outbuf[i], "data after decompression doesn't match the original one"); + } + printf("Great Success!\n"); + free(inbuf); + free(outbuf); + free(decomp); +} + +#endif //#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32) +#endif // CONFIG_SPIRAM \ No newline at end of file diff --git a/components/esp32/test/test_tjpgd.c b/components/esp_rom/test/test_tjpgd.c similarity index 90% rename from components/esp32/test/test_tjpgd.c rename to components/esp_rom/test/test_tjpgd.c index 82c147b11..7a0439c0d 100644 --- a/components/esp32/test/test_tjpgd.c +++ b/components/esp_rom/test/test_tjpgd.c @@ -1,12 +1,13 @@ - - #include -#include "esp32/rom/tjpgd.h" #include #include #include +#include "sdkconfig.h" #include "unity.h" +#if CONFIG_IDF_TARGET_ESP32 + +#include "esp32/rom/tjpgd.h" #include "test_tjpgd_logo.h" typedef struct { @@ -17,7 +18,6 @@ typedef struct { int outH; } JpegDev; - static UINT infunc(JDEC *decoder, BYTE *buf, UINT len) { JpegDev *jd = (JpegDev *)decoder->device; @@ -29,7 +29,6 @@ static UINT infunc(JDEC *decoder, BYTE *buf, UINT len) return len; } - static UINT outfunc(JDEC *decoder, void *bitmap, JRECT *rect) { unsigned char *in = (unsigned char *)bitmap; @@ -49,7 +48,7 @@ static UINT outfunc(JDEC *decoder, void *bitmap, JRECT *rect) #define TESTH 48 #define WORKSZ 3100 -TEST_CASE("Test JPEG decompression library", "[tjpgd]") +TEST_CASE("Test JPEG decompression library", "[rom][tjpgd]") { char aapix[] = " .:;+=xX$$"; unsigned char *decoded, *p; @@ -60,7 +59,8 @@ TEST_CASE("Test JPEG decompression library", "[tjpgd]") JpegDev jd; decoded = malloc(48 * 48 * 3); for (x = 0; x < 48 * 48 * 3; x += 2) { - decoded[x] = 0; decoded[x + 1] = 0xff; + decoded[x] = 0; + decoded[x + 1] = 0xff; } work = malloc(WORKSZ); memset(work, 0, WORKSZ); @@ -89,3 +89,5 @@ TEST_CASE("Test JPEG decompression library", "[tjpgd]") free(work); free(decoded); } + +#endif // #if CONFIG_IDF_TARGET_ESP32