[Solved] Beginners question: specifying multiple components in TEST_COMPONENTS

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

[Solved] Beginners question: specifying multiple components in TEST_COMPONENTS

Postby RobMeades » Fri Feb 01, 2019 5:34 pm

Hi there: apologies in advance, this is a stoopid question from someone new to the ESP32 tools. When unit testing, one can add the TEST_COMPONENTS directive to the make command in order to limit the components being tested:

https://docs.espressif.com/projects/esp ... t-test-app
make TEST_COMPONENTS=’xxx’ - build unit test app with tests for specific components
This works fine when I specify a single component but I can't figure out the syntax to specify more than one component. I've tried separating the component names with spaces, commas, semicolons and tried quoting the individual names and the whole lot but either nothing happens at all or the non-first components get me a "** No rule to make target blah" result.

What am I missing?
Last edited by RobMeades on Tue Feb 12, 2019 9:58 am, edited 1 time in total.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Beginners question: specifying multiple components in TEST_COMPONENTS

Postby ESP_igrr » Fri Feb 01, 2019 11:53 pm

Should be

make TEST_COMPONENTS="foo bar"

(double quotes, names separated with spaces)

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: Beginners question: specifying multiple components in TEST_COMPONENTS

Postby RobMeades » Mon Feb 04, 2019 11:06 am

Thanks, so using that syntax my tests compile but still only one test is listed as available to run.

To get specific, I have two components, accelerometer-lis2dw and battery-charger-bq24295, each containing a single unit test, plus a component named i2c-helper which they both require. I can compile the unit tests individually as follows:

Code: Select all

MINGW32> make -C ${IDF_PATH}/tools/unit-test-app EXTRA_COMPONENT_DIRS="~/esp/test-project/components/battery-charger-bq24295 ~/esp/test-project/components/i2c-helper" TEST_COMPONENTS=battery-charger-bq24295
...or:

Code: Select all

MINGW32> make -C ${IDF_PATH}/tools/unit-test-app EXTRA_COMPONENT_DIRS="~/esp/test-project/components/accelerometer-lis2dw ~/esp/test-project/components/i2c-helper" TEST_COMPONENTS=accelerometer-lis2dw
...and when I run them on the target make monitor shows a menu, in each case, with the single unit test for that component correctly listed.

However, if I do [showing the tools output as well as my command-lines this time]:

Code: Select all

MINGW32> make -C ${IDF_PATH}/tools/unit-test-app EXTRA_COMPONENT_DIRS="~/esp/test-project/components/accelerometer-lis2dw ~/esp/test-project/components/battery-charger-bq24295 ~/esp/test-project/components/i2c-helper" TEST_COMPONENTS="battery-charger-bq24295 accelerometer-lis2dw"

make: Entering directory '/home/rob/esp/esp-idf/tools/unit-test-app'
make[1]: Entering directory '/home/rob/esp/esp-idf/components/bootloader/subproject'
make[1]: Leaving directory '/home/rob/esp/esp-idf/components/bootloader/subproject'
make[1]: Entering directory '/home/rob/esp/esp-idf/tools/unit-test-app/build/accelerometer-lis2dw'
CC /home/rob/esp/esp-idf/tools/unit-test-app/build/accelerometer-lis2dw/lis2dw.o
AR /home/rob/esp/esp-idf/tools/unit-test-app/build/accelerometer-lis2dw/libaccelerometer-lis2dw.a
make[1]: Leaving directory '/home/rob/esp/esp-idf/tools/unit-test-app/build/accelerometer-lis2dw'
make[1]: Entering directory '/home/rob/esp/esp-idf/tools/unit-test-app/build/battery-charger-bq24295'
CC /home/rob/esp/esp-idf/tools/unit-test-app/build/battery-charger-bq24295/bq24295.o
AR /home/rob/esp/esp-idf/tools/unit-test-app/build/battery-charger-bq24295/libbattery-charger-bq24295.a
make[1]: Leaving directory '/home/rob/esp/esp-idf/tools/unit-test-app/build/battery-charger-bq24295'
LD /home/rob/esp/esp-idf/tools/unit-test-app/build/unit-test-app.elf
esptool.py v2.6-beta1
To flash all build output, run 'make flash' or:
python /home/rob/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port COM52 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 /home/rob/esp/esp-idf/tools/unit-test-app/build/bootloader/bootloader.bin 0x10000 /home/rob/esp/esp-idf/tools/unit-test-app/build/unit-test-app.bin 0x8000 /home/rob/esp/esp-idf/tools/unit-test-app/build/partition_table_unit_test_app.bin
make: Leaving directory '/home/rob/esp/esp-idf/tools/unit-test-app'
...and download that binary:

Code: Select all

MINGW32> python /home/rob/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port COM52 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 /home/rob/esp/esp-idf/tools/unit-test-app/build/bootloader/bootloader.bin 0x10000 /home/rob/esp/esp-idf/tools/unit-test-app/build/unit-test-app.bin 0x8000 /home/rob/esp/esp-idf/tools/unit-test-app/build/partition_table_unit_test_app.bin

esptool.py v2.6-beta1
Serial port COM52
Connecting........__
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, Coding Scheme None
MAC: 
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Compressed 19408 bytes to 11573...
Wrote 19408 bytes (11573 compressed) at 0x00001000 in 0.1 seconds (effective 1076.3 kbit/s)...
Hash of data verified.
Compressed 262720 bytes to 143611...
Wrote 262720 bytes (143611 compressed) at 0x00010000 in 4.5 seconds (effective 465.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 179...
Wrote 3072 bytes (179 compressed) at 0x00008000 in 0.0 seconds (effective 1532.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
...then when I run make monitor, only the accelerometer-lis2dw test shows up:

Code: Select all

MINGW32> make monitor

MONITOR
--- idf_monitor on COM52 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

...

Press ENTER to see the list of tests.

Here's the test menu, pick your combo:
(1)     "initialisation_1" [accelerometer-lis2dw]
What am I doing wrong? The test files compile, the test case names are different, why aren't they both listed?

I've attached one of the test files:
test_lis2dw.c
(847 Bytes) Downloaded 587 times
test_bq24295.c is similar but the test case name is different (TEST_CASE("initialisation", "[battery-charger-bq24295]")).

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Beginners question: specifying multiple components in TEST_COMPONENTS

Postby ESP_igrr » Mon Feb 04, 2019 1:09 pm

Could you please add 'list-components' target to your make command, to see if the components are located correctly?

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: Beginners question: specifying multiple components in TEST_COMPONENTS

Postby RobMeades » Mon Feb 04, 2019 5:06 pm

Certainly, output below, and, just to prove that I'm not going mad, the output if I just have battery-charger-bq24295 in EXTRA_COMPONENT_DIRS is below that. As soon as I add accelerometer-lis2dw to the extra component list, actually irrespective of what I list in TEST_COMPONENTS, only my accelerometer test is listed.

In other words, once I add ~/esp/test-project/components/accelerometer-lis2dw to EXTRA_COMPONENT_DIRS, even if I leave TEST_COMPONENTS as just battery-charger-bq24295, still accelerometer-lis2dw is the only test listed. There's clearly something I've not understood here, or a typo I have failed spot.

So that you get a complete picture, here's a directory tree of my project:

Code: Select all

│   .cproject
│   .gitignore
│   .project
│   gdbinit
│   Makefile
│   README.md
│   sdkconfig
│   sdkconfig.defaults
│   sdkconfig.old
│
├───components
│   ├───accelerometer-lis2dw
│   │   │   accelerometer.h
│   │   │   component.mk
│   │   │   Kconfig
│   │   │   lis2dw.c
│   │   │   lis2dw.h
│   │   │   README.md
│   │   │
│   │   └───test
│   │           component.mk
│   │           test_lis2dw.c
│   │
│   ├───battery-charger-bq24295
│   │   │   battery_charger.h
│   │   │   bq24295.c
│   │   │   bq24295.h
│   │   │   component.mk
│   │   │   Kconfig
│   │   │   README.md
│   │   │
│   │   └───test
│   │           component.mk
│   │           test_bq24295.c
│   │
└───main
        component.mk
        main.c
list-components output:

Code: Select all

make: Entering directory '/home/rob/esp/esp-idf/tools/unit-test-app'
*******************************************************************************
COMPONENT_DIRS (components searched for here)
/home/rob/esp/esp-idf/tools/unit-test-app/components
~/esp/test-project/components/accelerometer-lis2dw
~/esp/test-project/components/battery-charger-bq24295
~/esp/test-project/components/i2c-helper
/home/rob/esp/esp-idf/components
/home/rob/esp/esp-idf/tools/unit-test-app/main
*******************************************************************************
COMPONENTS (list of component names)
accelerometer-lis2dw app_trace app_update aws_iot battery-charger-bq24295 bootloader bootloader_support bt coap console cxx driver esp-tls esp32 esp_adc_cal esp_http_client esp_https_ota esptool_py ethernet expat fatfs freertos heap i2c-helper idf_test jsmn json libsodium log lwip main mbedtls mdns micro-ecc newlib nghttp nvs_flash openssl partition_table pthread sdmmc smartconfig_ack soc spi_flash spiffs tcpip_adapter test ulp unity vfs wear_levelling wpa_supplicant xtensa-debug-module
*******************************************************************************
EXCLUDE_COMPONENTS (list of excluded names)
C:/msys32/home/rob/esp/esp-idf/make/project.mk:541: warning: undefined variable 'EXCLUDE_COMPONENTS'
(none provided)
*******************************************************************************
COMPONENT_PATHS (paths to all components):
/home/rob/esp/test-project/components/accelerometer-lis2dw
/home/rob/esp/esp-idf/components/app_trace
/home/rob/esp/esp-idf/components/app_update
/home/rob/esp/esp-idf/components/aws_iot
/home/rob/esp/test-project/components/battery-charger-bq24295
/home/rob/esp/esp-idf/components/bootloader
/home/rob/esp/esp-idf/components/bootloader_support
/home/rob/esp/esp-idf/components/bt
/home/rob/esp/esp-idf/components/coap
/home/rob/esp/esp-idf/components/console
/home/rob/esp/esp-idf/components/cxx
/home/rob/esp/esp-idf/components/driver
/home/rob/esp/esp-idf/components/esp-tls
/home/rob/esp/esp-idf/components/esp32
/home/rob/esp/esp-idf/components/esp_adc_cal
/home/rob/esp/esp-idf/components/esp_http_client
/home/rob/esp/esp-idf/components/esp_https_ota
/home/rob/esp/esp-idf/components/esptool_py
/home/rob/esp/esp-idf/components/ethernet
/home/rob/esp/esp-idf/components/expat
/home/rob/esp/esp-idf/components/fatfs
/home/rob/esp/esp-idf/components/freertos
/home/rob/esp/esp-idf/components/heap
/home/rob/esp/test-project/components/i2c-helper
/home/rob/esp/esp-idf/components/idf_test
/home/rob/esp/esp-idf/components/jsmn
/home/rob/esp/esp-idf/components/json
/home/rob/esp/esp-idf/components/libsodium
/home/rob/esp/esp-idf/components/log
/home/rob/esp/esp-idf/components/lwip
/home/rob/esp/esp-idf/tools/unit-test-app/main
/home/rob/esp/esp-idf/components/mbedtls
/home/rob/esp/esp-idf/components/mdns
/home/rob/esp/esp-idf/components/micro-ecc
/home/rob/esp/esp-idf/components/newlib
/home/rob/esp/esp-idf/components/nghttp
/home/rob/esp/esp-idf/components/nvs_flash
/home/rob/esp/esp-idf/components/openssl
/home/rob/esp/esp-idf/components/partition_table
/home/rob/esp/esp-idf/components/pthread
/home/rob/esp/esp-idf/components/sdmmc
/home/rob/esp/esp-idf/components/smartconfig_ack
/home/rob/esp/esp-idf/components/soc
/home/rob/esp/esp-idf/components/spi_flash
/home/rob/esp/esp-idf/components/spiffs
/home/rob/esp/esp-idf/components/tcpip_adapter
/home/rob/esp/test-project/components/accelerometer-lis2dw/test
/home/rob/esp/esp-idf/components/ulp
/home/rob/esp/esp-idf/tools/unit-test-app/components/unity
/home/rob/esp/esp-idf/components/vfs
/home/rob/esp/esp-idf/components/wear_levelling
/home/rob/esp/esp-idf/components/wpa_supplicant
/home/rob/esp/esp-idf/components/xtensa-debug-module
make: Leaving directory '/home/rob/esp/esp-idf/tools/unit-test-app'
If I just build/run the battery-charger-bq24295 test:

Code: Select all

MINGW32> make -C ${IDF_PATH}/tools/unit-test-app EXTRA_COMPONENT_DIRS="~/esp/test-project/components/battery-charger-bq24295 ~/esp/test-project/components/i2c-helper" TEST_COMPONENTS="battery-charger-bq24295"

make: Entering directory '/home/rob/esp/esp-idf/tools/unit-test-app'
make[1]: Entering directory '/home/rob/esp/esp-idf/components/bootloader/subproject'
make[1]: Leaving directory '/home/rob/esp/esp-idf/components/bootloader/subproject'
make[1]: Entering directory '/home/rob/esp/esp-idf/tools/unit-test-app/build/test'
CC /home/rob/esp/esp-idf/tools/unit-test-app/build/test/test_bq24295.o
AR /home/rob/esp/esp-idf/tools/unit-test-app/build/test/libtest.a
make[1]: Leaving directory '/home/rob/esp/esp-idf/tools/unit-test-app/build/test'
LD /home/rob/esp/esp-idf/tools/unit-test-app/build/unit-test-app.elf
esptool.py v2.6-beta1
To flash all build output, run 'make flash' or:
python /home/rob/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port COM52 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 /home/rob/esp/esp-idf/tools/unit-test-app/build/bootloader/bootloader.bin 0x10000 /home/rob/esp/esp-idf/tools/unit-test-app/build/unit-test-app.bin 0x8000 /home/rob/esp/esp-idf/tools/unit-test-app/build/partition_table_unit_test_app.bin
make: Leaving directory '/home/rob/esp/esp-idf/tools/unit-test-app'

MINGW32> python /home/rob/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port COM52 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 /home/rob/esp/esp-idf/tools/unit-test-app/build/bootloader/bootloader.bin 0x10000 /home/rob/esp/esp-idf/tools/unit-test-app/build/unit-test-app.bin 0x8000 /home/rob/esp/esp-idf/tools/unit-test-app/build/partition_table_unit_test_app.bin

esptool.py v2.6-beta1
Serial port COM52
Connecting........____
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, Coding Scheme None
MAC: 30:ae:a4:52:94:d0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Compressed 19408 bytes to 11573...
Wrote 19408 bytes (11573 compressed) at 0x00001000 in 0.1 seconds (effective 1066.2 kbit/s)...
Hash of data verified.
Compressed 261872 bytes to 143487...
Wrote 261872 bytes (143487 compressed) at 0x00010000 in 4.3 seconds (effective 484.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 179...
Wrote 3072 bytes (179 compressed) at 0x00008000 in 0.0 seconds (effective 1532.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

MINGW32> make monitor

...

Press ENTER to see the list of tests.


Here's the test menu, pick your combo:
(1)     "initialisation" [battery-charger-bq24295]

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: Beginners question: specifying multiple components in TEST_COMPONENTS

Postby RobMeades » Mon Feb 11, 2019 1:29 pm

Any thoughts on this? I would like to resolve what's going on as running separate builds for each component's unit test is quite time consuming.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Beginners question: specifying multiple components in TEST_COMPONENTS

Postby ESP_igrr » Tue Feb 12, 2019 12:43 am

This seems to be a bug in the build system, related to the interaction between EXTRA_COMPONENT_DIRS and TEST_COMPONENTS. I don't immediately see what is the source of the issue, though. It might be a good idea if you open an issue on GitHub, so that this issue won't be forgotten, and you would get a notification when it is fixed.

As another data point, can you try setting EXTRA_COMPONENT_DIRS to /home/rob/esp/test-project/components instead?

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: Beginners question: specifying multiple components in TEST_COMPONENTS

Postby RobMeades » Tue Feb 12, 2019 9:58 am

Ah! Well, done, you've cracked it! If I do:

Code: Select all

MINGW32> make -C ${IDF_PATH}/tools/unit-test-app EXTRA_COMPONENT_DIRS="~/esp/test-project/components" TEST_COMPONENTS="accelerometer-lis2dw battery-charger-bq24295"
...then that builds both sets of tests. It's probably worth you updating some documentation link somewhere to say this. Or maybe people will find it in these fora.

Who is online

Users browsing this forum: artisdom, Bing [Bot], Sang_Huynh and 209 guests