* Ability to run linux tests with AddressSanitizer
This makes it possible to compile and run the tests with Address
Sanitizer (ASAN) [1].
The command is:
```
make -f custom.mk clean; ASAN=1 make -f custom.mk && ./build/win_main -runUnitTests 2
```
Building without ASAN works without change.
Address Sanitizer saves a lot of time debugging memory issues, for
example for a bug where we index in an array with negative index it
gives this nice error message:
```
=================================================================
==2532658==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5642389c5e37 at pc 0x564237e67492 bp 0x7fff17726e50 sp 0x7fff17726e40
READ of size 1 at 0x5642389c5e37 thread T0
#0 0x564237e67491 in CHANNEL_GetType src/new_cfg.c:427
#1 0x564237dfc933 in TuyaMCU_ApplyMapping src/driver/drv_tuyaMCU.c:1126
#2 0x564237dff92f in TuyaMCU_ParseStateMessage src/driver/drv_tuyaMCU.c:1632
#3 0x564237e019fa in TuyaMCU_ProcessIncoming src/driver/drv_tuyaMCU.c:1977
#4 0x564237e027ee in TuyaMCU_RunReceive src/driver/drv_tuyaMCU.c:2178
#5 0x564237e02dc2 in TuyaMCU_RunFrame src/driver/drv_tuyaMCU.c:2335
#6 0x564237dd2ce6 in DRV_RunQuickTick src/driver/drv_main.c:536
#7 0x564237ec4037 in QuickTick src/user_main.c:946
#8 0x564237eca8a5 in Sim_RunFrame src/win_main.c:106
#9 0x564237eca993 in Sim_RunFrames src/win_main.c:134
#10 0x564237ebce4a in Test_TuyaMCU_Basic src/selftest/selftest_tuyaMCU.c:369
#11 0x564237ecab1f in Win_DoUnitTests src/win_main.c:194
#12 0x564237ecba57 in main src/win_main.c:535
#13 0x7fb55312ed8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#14 0x7fb55312ee3f in __libc_start_main_impl ../csu/libc-start.c:392
#15 0x564237cb16b4 in _start (/home/niteria/tmp/broken-realloc/OpenBK7231T_App/build/win_main+0xcf6b4)
0x5642389c5e37 is located 51 bytes to the right of global variable 'stat_deduper_culled_tooFast' defined in 'src/mqtt/new_mqtt_deduper.c:40:12' (0x5642389c5e00) of size 4
0x5642389c5e37 is located 9 bytes to the left of global variable 'g_mutex' defined in 'src/mqtt/new_mqtt_deduper.c:42:26' (0x5642389c5e40) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow src/new_cfg.c:427 in CHANNEL_GetType
Shadow bytes around the buggy address:
0x0ac8c7130b70: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x0ac8c7130b80: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x0ac8c7130b90: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x0ac8c7130ba0: 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9
0x0ac8c7130bb0: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
=>0x0ac8c7130bc0: 04 f9 f9 f9 f9 f9[f9]f9 04 f9 f9 f9 f9 f9 f9 f9
0x0ac8c7130bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac8c7130be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac8c7130bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac8c7130c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac8c7130c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==2532658==ABORTING
```
[1] https://github.com/google/sanitizers/wiki/addresssanitizer
* disable tests broken on linux
* add a suppression file for known leaks
* attempt at adding an ASAN workflow
* fix autogen
* Update workflow.yaml
---------
Co-authored-by: openshwprojects <85486843+openshwprojects@users.noreply.github.com>
The tests were segfaulting on linux, I don't know how they work on
Windows, perhaps casting `void*` to `int` happens to work there.
Generally it's not portable.
Berry has a dedicated `comptr` type, so let's use that and be portable.
Also makes `run_closure` handle arbitrary number of arguments, see
https://berry.readthedocs.io/en/latest/source/en/Chapter-5.html#function-with-variable-number-of-arguments-vararg
for docs.
Test Plan:
* CI
* make -f custom.mk, ./build/win_main -runUnitTests 2
* berry workaround for broken realloc on OpenBK7231N
I ran `addRepeatingEvent 1 -1 testRealloc 100` on a OpenBK7231N device
and it failed. This is the same problem as #1563.
This might be related to mysterious crashes I was getting while
importing big modules like this:
`addRepeatingEvent 1 1 berry import modulename`.
* fix
* t
* fx
* split closure handler
* setTimeout, setInterval
* split berry frm SVM, but I need to move event waiter to separate struct?
* fx
* fx
* split relations
* remvoe ode duplciaton
* POC - pass value to berry
* POC - pass str to berry
* berry preps + lfs test
* lfs test + bytes
* save
* remove code duplication
* try dpid calls
* working test for bytes
* tyuamcu to file in eberry
* str for berry test
* tuyamcu to berry glue
* fx1
* fixes
* try berry http
* fix
* tests
* test vaar lifespan
* test
* test
* test if
* berry in html
* #if ENABLE_OBK_BERRY
* fx
* better
* fx
* test nested loop
* free mem
* simpler
* split lfs run
* arg
* fx
* fix
* #if ENABLE_OBK_BERRY
* comamnd hook
* vars access, ntp
* finalize?
* unfinished
Don't continue with the state machine if the device is in Open WiFi mode
based on a user button press.
This avoids the device shutting down itself when in recovery mode. The
MCU will reset the device after 90 seconds automatically.
Communicate to the MCU the device is in configuration mode. This will
change the status LED blink pattern to reflect the state.
Signed-off-by: David Bauer <mail@david-bauer.net>