Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/fff: Add fake functions framework package #17076

Merged
merged 1 commit into from Nov 3, 2021

Conversation

jenswet
Copy link
Contributor

@jenswet jenswet commented Oct 28, 2021

Contribution description

Add the fake functions framework for mocks in unit tests.

I'd like to use this in #17066. @aabadie suggested to make this a separate PR.

I need feedback on the Kconfig since I have no experience with that. It was copied from other packages.

Testing procedure

Please have a look at the sample test fff_test.

Issues/PRs references

See also #17066.

@github-actions github-actions bot added Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports Area: tests Area: tests and testing framework labels Oct 28, 2021
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, fff can be very useful for unit testing a lot of stuff (drivers, etc) without hardware.

I have inline comments and I would rename the test application pkg_fff to be consistent with other pkg test applications.

tests/fff_test/Makefile Outdated Show resolved Hide resolved
tests/fff_test/main.c Outdated Show resolved Hide resolved
tests/fff_test/main.c Outdated Show resolved Hide resolved
@jenswet jenswet requested a review from aabadie October 28, 2021 18:13
@aabadie
Copy link
Contributor

aabadie commented Oct 29, 2021

Looks good, please squash !

@aabadie
Copy link
Contributor

aabadie commented Oct 29, 2021

Hmm, I tried to build manually and it doesn't build on native and esp32 platforms:

native (in docker)
$ BUILD_IN_DOCKER=1 make -C tests/pkg_fff --no-print-directory 
Launching build container using image "riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/Europe/Paris:/etc/localtime:ro' -v '/work/riot/RIOT:/data/riotbuild/riotbase:delegated' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'        -w '/data/riotbuild/riotbase/tests/pkg_fff/' 'riot/riotbuild:latest' make     
Building application "tests_pkg_fff" for "native" with MCU "native".

"make" -C /data/riotbuild/riotbase/pkg/fff
/data/riotbuild/riotbase/tests/pkg_fff/main.c:24:42: error: ISO C99 requires at least one argument for the "..." in a variadic macro [-Werror]
 FAKE_VALUE_FUNC(unsigned int, irq_disable)
                                          ^
/data/riotbuild/riotbase/tests/pkg_fff/main.c:25:41: error: ISO C99 requires at least one argument for the "..." in a variadic macro [-Werror]
 FAKE_VALUE_FUNC(unsigned int, irq_enable)
                                         ^
/data/riotbuild/riotbase/tests/pkg_fff/main.c:26:36: error: ISO C99 requires at least one argument for the "..." in a variadic macro [-Werror]
 FAKE_VALUE_FUNC(int, irq_is_enabled)
                                    ^
/data/riotbuild/riotbase/tests/pkg_fff/main.c:27:31: error: ISO C99 requires at least one argument for the "..." in a variadic macro [-Werror]
 FAKE_VALUE_FUNC(int, irq_is_in)
                               ^
cc1: all warnings being treated as errors
/data/riotbuild/riotbase/Makefile.base:142: recipe for target '/data/riotbuild/riotbase/tests/pkg_fff/bin/native/application_tests_pkg_fff/main.o' failed
make[1]: *** [/data/riotbuild/riotbase/tests/pkg_fff/bin/native/application_tests_pkg_fff/main.o] Error 1
/data/riotbuild/riotbase/Makefile.include:686: recipe for target 'application_tests_pkg_fff.module' failed
native (not in docker, with gcc 11.2)
$ make -C tests/pkg_fff --no-print-directory 
Building application "tests_pkg_fff" for "native" with MCU "native".

"make" -C /work/riot/RIOT/pkg/fff
"make" -C /work/riot/RIOT/boards/native
"make" -C /work/riot/RIOT/boards/native/drivers
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/native
"make" -C /work/riot/RIOT/cpu/native/periph
"make" -C /work/riot/RIOT/cpu/native/stdio_native
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/test_utils/interactive_sync
/usr/bin/ld: /work/riot/RIOT/tests/pkg_fff/bin/native/cpu/irq_cpu.o: in function `irq_disable':
/work/riot/RIOT/cpu/native/irq_cpu.c:150: multiple definition of `irq_disable'; /usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/usr/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x503fe vs 0xe688)
/work/riot/RIOT/tests/pkg_fff/bin/native/application_tests_pkg_fff/main.o:/work/riot/RIOT/tests/pkg_fff/main.c:24: first defined here
/usr/bin/ld: /work/riot/RIOT/tests/pkg_fff/bin/native/cpu/irq_cpu.o: in function `irq_enable':
/work/riot/RIOT/cpu/native/irq_cpu.c:177: multiple definition of `irq_enable'; /work/riot/RIOT/tests/pkg_fff/bin/native/application_tests_pkg_fff/main.o:/work/riot/RIOT/tests/pkg_fff/main.c:25: first defined here
/usr/bin/ld: /work/riot/RIOT/tests/pkg_fff/bin/native/cpu/irq_cpu.o: in function `irq_restore':
/work/riot/RIOT/cpu/native/irq_cpu.c:215: multiple definition of `irq_restore'; /work/riot/RIOT/tests/pkg_fff/bin/native/application_tests_pkg_fff/main.o:/work/riot/RIOT/tests/pkg_fff/main.c:28: first defined here
/usr/bin/ld: /work/riot/RIOT/tests/pkg_fff/bin/native/cpu/irq_cpu.o: in function `irq_is_enabled':
/work/riot/RIOT/cpu/native/irq_cpu.c:229: multiple definition of `irq_is_enabled'; /work/riot/RIOT/tests/pkg_fff/bin/native/application_tests_pkg_fff/main.o:/work/riot/RIOT/tests/pkg_fff/main.c:26: first defined here
/usr/bin/ld: /work/riot/RIOT/tests/pkg_fff/bin/native/cpu/irq_cpu.o: in function `irq_is_in':
/work/riot/RIOT/cpu/native/irq_cpu.c:234: multiple definition of `irq_is_in'; /work/riot/RIOT/tests/pkg_fff/bin/native/application_tests_pkg_fff/main.o:/work/riot/RIOT/tests/pkg_fff/main.c:27: first defined here
/usr/bin/ld: /work/riot/RIOT/tests/pkg_fff/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
esp32
$ BUILD_IN_DOCKER=1 BOARD=esp32-wroom-32 make -C tests/pkg_fff --no-print-directory 
ESP32_SDK_DIR should be defined as /path/to/esp-idf directory
ESP32_SDK_DIR is set by default to /opt/esp/esp-idf
Launching build container using image "riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/Europe/Paris:/etc/localtime:ro' -v '/work/riot/RIOT:/data/riotbuild/riotbase:delegated' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'      -e 'BOARD=esp32-wroom-32'  -w '/data/riotbuild/riotbase/tests/pkg_fff/' 'riot/riotbuild:latest' make     
ESP32_SDK_DIR should be defined as /path/to/esp-idf directory
ESP32_SDK_DIR is set by default to /opt/esp/esp-idf
Building application "tests_pkg_fff" for "esp32-wroom-32" with MCU "esp32".

"make" -C /data/riotbuild/riotbase/pkg/fff
"make" -C /data/riotbuild/riotbase/boards/esp32-wroom-32
"make" -C /data/riotbuild/riotbase/boards/common/esp32
"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/cpu/esp32
"make" -C /data/riotbuild/riotbase/cpu/esp32/freertos
"make" -C /data/riotbuild/riotbase/cpu/esp32/periph
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/driver
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/esp32
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/soc
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/spi_flash
"make" -C /data/riotbuild/riotbase/cpu/esp_common
"make" -C /data/riotbuild/riotbase/cpu/esp_common/freertos
"make" -C /data/riotbuild/riotbase/cpu/esp_common/periph
"make" -C /data/riotbuild/riotbase/cpu/esp_common/vendor
"make" -C /data/riotbuild/riotbase/cpu/esp_common/vendor/xtensa
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/isrpipe
"make" -C /data/riotbuild/riotbase/sys/log
"make" -C /data/riotbuild/riotbase/sys/luid
"make" -C /data/riotbuild/riotbase/sys/newlib_syscalls_default
"make" -C /data/riotbuild/riotbase/sys/pm_layered
"make" -C /data/riotbuild/riotbase/sys/random
"make" -C /data/riotbuild/riotbase/sys/random/tinymt32
"make" -C /data/riotbuild/riotbase/sys/stdio_uart
"make" -C /data/riotbuild/riotbase/sys/test_utils/interactive_sync
"make" -C /data/riotbuild/riotbase/sys/tsrb
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/esp_common/irq_arch.o: In function `irq_disable':
/data/riotbuild/riotbase/cpu/esp_common/irq_arch.c:44: multiple definition of `irq_disable'
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/application_tests_pkg_fff/main.o:/data/riotbuild/riotbase/tests/pkg_fff/main.c:24: first defined here
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/esp_common/irq_arch.o: In function `irq_enable':
/data/riotbuild/riotbase/cpu/esp_common/irq_arch.c:61: multiple definition of `irq_enable'
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/application_tests_pkg_fff/main.o:/data/riotbuild/riotbase/tests/pkg_fff/main.c:24: first defined here
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/esp_common/irq_arch.o: In function `irq_restore':
/data/riotbuild/riotbase/cpu/esp_common/irq_arch.c:78: multiple definition of `irq_restore'
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/application_tests_pkg_fff/main.o:/data/riotbuild/riotbase/tests/pkg_fff/main.c:24: first defined here
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/esp_common/irq_arch.o: In function `irq_is_in':
/data/riotbuild/riotbase/cpu/esp_common/irq_arch.c:98: multiple definition of `irq_is_in'
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/application_tests_pkg_fff/main.o:/data/riotbuild/riotbase/tests/pkg_fff/main.c:24: first defined here
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/esp_common/irq_arch.o: In function `irq_is_enabled':
/data/riotbuild/riotbase/cpu/esp_common/irq_arch.c:107: multiple definition of `irq_is_enabled'
/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/application_tests_pkg_fff/main.o:/data/riotbuild/riotbase/tests/pkg_fff/main.c:24: first defined here
collect2: error: ld returned 1 exit status
/data/riotbuild/riotbase/Makefile.include:677: recipe for target '/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/tests_pkg_fff.elf' failed
make: *** [/data/riotbuild/riotbase/tests/pkg_fff/bin/esp32-wroom-32/tests_pkg_fff.elf] Error 1

It builds fine on arm, riscv and avr.

@jenswet
Copy link
Contributor Author

jenswet commented Oct 29, 2021

Hmm, I tried to build manually and it doesn't build on native and esp32 platforms:

native (in docker)
native (not in docker, with gcc 11.2)
esp32
It builds fine on arm, riscv and avr.

Hmm okay. I only tried avr and arm so far.

It works on ARM because all irq functions are defined inline. Because of that replacing the original header by our mock header in the test directory is enough. On other platforms these IRQ functions are obviously not defined inline.

To mock them we'd either need the possibility to avoid compiling the original C files or make the functions weak.

Any suggestions on what to do? For some cases the framework is still very helpful. E.g. for many peripherals, drivers, etc it's possible to avoid building their C files by not adding the corresponding USEMODULE. For others we'd need to adjust the build process to support mocking better.

Should I just add different example for the package test or should we exclude some platforms from running the test?

Thanks.

@maribu
Copy link
Member

maribu commented Oct 29, 2021

The issue on ESP is that irq_disable() and irq_restore() are on all other platforms static inline functions, but not so on ESP.

Conceptionally fff provides a mock implementation of a function instead of the real one. But with irq_disable() and irq_restore() one cannot get rid of the real ones, as those are used by core functionality of RIOT.

Maybe it is better to let the test example use some periph API without actually using that implementation? That would make sure that there are not two implementations of that functions available.

To get this working with unmodified drivers, something like this could help:

diff --git a/makefiles/features_modules.inc.mk b/makefiles/features_modules.inc.mk
index abde96c438..cb98b29872 100644
--- a/makefiles/features_modules.inc.mk
+++ b/makefiles/features_modules.inc.mk
@@ -11,7 +11,7 @@ USEMODULE += $(PERIPH_FEATURES)
 
 # Add all USED periph_% init modules unless they are blacklisted
 ifneq (,$(filter periph_init, $(USEMODULE)))
-  PERIPH_IGNORE_MODULES := \
+  PERIPH_IGNORE_MODULES += \
     periph_init% \
     periph_common \
     periph_rtc_rtt \

And in the Makefile of the test you add PERIPH_IGNORE_MODULES += periph_spi to e.g. mock the SPI interface.

@maribu
Copy link
Member

maribu commented Oct 29, 2021

To mock them we'd either need the possibility to avoid compiling the original C files or make the functions weak.

This will not work for irq_disable() and irq_restore(). Those are too essential to be mocked system-wide. If one really wants to mock them, one would have to resort to some dark magic (e.g. still providing the original functionality in the mock functions or replacing the calls in the driver to test with calls to functions named differently while having the rest of RIOT compiled as is by preprocessor magic or renaming of symbols in object files). In any case, I think that this would be too complex for a simple showcase application.

Regarding the issues with -pedantic about the missing argument for the variadic arguments of the function-like preprocessor macro: I think it wouldn't hurt to just drop -pedantic when fff is used. I don't expect that anyone would use fff outside of tests and strict ISO C11 compliance in tests is likely not that important. (The message warns about C99 compliance, but we compile with C11 - GCC's warning was not updated.)

Also: I think this might actually be a false positive from the preprocessor in the docker, rather than really fff being not compliant.

@aabadie
Copy link
Contributor

aabadie commented Oct 29, 2021

Maybe it is better to let the test example use some periph API without actually using that implementation?

I think that's probably better since IMHO fff can be really useful when testing a driver without the hardware. I agree that adding a way to exclude the mocked module from the build system is probably the best solution but I'm not sure if it should be done by extending PERIPH_IGNORE_MODULES.
We could need to test a higher level API by mocking another high level API, not directly connected to a periph API (I'm thinking of disp_dev that depends on a high-level driver).
Would it makes sense to introduce an IGNORE_MODULES variables that would be used to filter-out its content from USEMODULE ? That should also work for periph_% features since in the end they are turned into regular modules.

@maribu
Copy link
Member

maribu commented Oct 29, 2021

+1 for IGNORE_MODULES as this would allow mocking non-peripheral functions as well.

@aabadie
Copy link
Contributor

aabadie commented Oct 29, 2021

I'd like to have @fjmolinas's opinion on IGNORE_MODULES since he's quite involved in build system stuff and (according to git grep) he already used that variable name in a couple of packages.

@github-actions github-actions bot added the Area: sys Area: System label Oct 29, 2021
@jenswet
Copy link
Contributor Author

jenswet commented Oct 29, 2021

Maybe it is better to let the test example use some periph API without actually using that implementation? That would make sure that there are not two implementations of that functions available.

I adjusted the example to mock some i2c functions. Since one of them writes to a buffer I added a test to show on how to let the mock call a fake implementation.

The new example compiles for native and esp. I tried both. I ran the test on a Nucleo board and that works too.

Is that a better example? It doesn't require any Makefile changes so far.

I also like the IGNORE_MODULES idea, that would be great for unit testing.

Regarding the issues with -pedantic about the missing argument for the variadic arguments of the function-like preprocessor macro: I think it wouldn't hurt to just drop -pedantic when fff is used. I don't expect that anyone would use fff outside of tests and strict ISO C11 compliance in tests is likely not that important. (The message warns about C99 compliance, but we compile with C11 - GCC's warning was not updated.)

Where would I need to add that for the package?

Additionally I've added a note to the embUnit doxygen docs that links the fff framework. Then it is easier to find for new test writers.

@fjmolinas
Copy link
Contributor

+1 for IGNORE_MODULES as this would allow mocking non-peripheral functions as well.

I would be in favor of a simpler solution that would fit this use case, and then open a separate PR/ISSUE to discuss this generic solution. There are already cases of mocked modules in the tree, and this will make this PR more complicated than it needs.

@jenswet
Copy link
Contributor Author

jenswet commented Oct 29, 2021

I would be in favor of a simpler solution that would fit this use case, and then open a separate PR/ISSUE to discuss this generic solution. There are already cases of mocked modules in the tree, and this will make this PR more complicated than it needs.

Yes that's fine. My updated pkg_fff test doesn't require any change on makefiles. So the IGNORE_MODULES suggestion could be moved to a new issue. I have not enough insight in the build system to introduce something like that anyways.

tests/pkg_fff/main.c Outdated Show resolved Hide resolved
@fjmolinas
Copy link
Contributor

I would be in favor of a simpler solution that would fit this use case, and then open a separate PR/ISSUE to discuss this generic solution. There are already cases of mocked modules in the tree, and this will make this PR more complicated than it needs.

Yes that's fine. My updated pkg_fff test doesn't require any change on makefiles. So the IGNORE_MODULES suggestion could be moved to a new issue. I have not enough insight in the build system to introduce something like that anyways.

Note that periph_i2c is a bit of a special case since its a SUBMODULE and therefore its harder to exclude the C file from the build. To keep this test very simple you could add and EXTERNAL_MODULE with very simple function to mock and add that module to PSEUDOMODULES. I think you would just need this patch for it to work (untested so if you have a working workflow its already good):

diff --git a/Makefile.include b/Makefile.include
index f93bbb740a..4311e5b628 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -642,7 +642,7 @@ endif
 LINKFLAGPREFIX ?= -Wl,
 
 # Also build external modules
-DIRS += $(EXTERNAL_MODULE_PATHS)
+DIRS += $(filter-out $(PSEUDOMODULES),$(EXTERNAL_MODULE_PATHS))

 # Define dependencies required for building (headers, downloading source files,)
 BUILDDEPS += $(RIOTBUILD_CONFIG_HEADER_C)

@jenswet jenswet requested a review from aabadie October 29, 2021 16:39
@MrKevinWeiss MrKevinWeiss added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 29, 2021
@MrKevinWeiss
Copy link
Contributor

Lets see what murdock says now :)

@maribu
Copy link
Member

maribu commented Oct 30, 2021

Two compilation failures still. One is failing to link due to too little RAM - just add that board to Makefile.ci to skip linking there.

The other fails with two definitions of i2c_acquire(). That one needs a closer look.

@jenswet
Copy link
Contributor Author

jenswet commented Oct 30, 2021

Two compilation failures still. One is failing to link due to too little RAM - just add that board to Makefile.ci to skip linking there.

The other fails with two definitions of i2c_acquire(). That one needs a closer look.

The sltb001a seems to have periph_i2c as (transitive) dependency in the board definition. The build conflicts with the implementation in cpu/efm32/periph/i2c.c.

Should we just exclude both boards from the build process? Is there only BOARD_INSUFFICIENT_MEMORY or different rulesets too?

I can use a different mock example too, but it might be difficult the perfect one.

@maribu
Copy link
Member

maribu commented Oct 31, 2021

You can use BOARD_BLACKLIST to fully disable an application for a specific board (this will skip both compilation and linking). This goes into the Makefile rather than into Makefile.ci (for historic reasons, maybe it would also be better placed in Makefile.ci - but that is out of topic).

For the one with too little RAM use BOARD_INSUFFICIENT_MEMORY, which goes into Makefile.ci. This will only skip the linking.

@miri64
Copy link
Member

miri64 commented Nov 1, 2021

You can use BOARD_BLACKLIST to fully disable an application for a specific board (this will skip both compilation and linking). This goes into the Makefile rather than into Makefile.ci (for historic reasons, maybe it would also be better placed in Makefile.ci - but that is out of topic).

It would be preferable to use FEATURES_BLACKLIST for efm32 though ;-), since BOARD_BLACKLIST (like BOARD_INSUFFICIENT_MEMORY) can 1. lead to lots of merge conflicts, 2. forces contributors of new efm32 boards to touch the application's Makefile.ci.

@miri64
Copy link
Member

miri64 commented Nov 1, 2021

(unless of course it is, IISC as it is the case in this instance, just a single board from that CPU type that breaks the mold... Might point to a bug in its definitions actually, but in your case then BOARD_BLACKLIST is okay)

@jenswet
Copy link
Contributor Author

jenswet commented Nov 1, 2021

Should I squash?

@fjmolinas
Copy link
Contributor

I don't, if Murdock passes its all good, and I don't think periph_i2c will be used by default by any BOARD, but if for some reason it was the case you would get the implementation conflict. If for example, you had chosen to mock periph_rtt that would be the case.

Seem like it was the case at the end ;)

@fjmolinas
Copy link
Contributor

Should I squash?

Go ahead

@jenswet
Copy link
Contributor Author

jenswet commented Nov 2, 2021

I don't, if Murdock passes its all good, and I don't think periph_i2c will be used by default by any BOARD, but if for some reason it was the case you would get the implementation conflict. If for example, you had chosen to mock periph_rtt that would be the case.

Seem like it was the case at the end ;)

Yes you had the right feeling. 😄

Go ahead

Done 👍

@aabadie
Copy link
Contributor

aabadie commented Nov 2, 2021

I was wondering something: instead of blacklisting boards that pull in periph_i2c by default, would it work to blacklist the i2c feature instead (with FEATURES_BLACKLIST += periph_i2c) ? This way Murdock won't build it for these boards and no need to maintain an explicit list of boards to blacklist.

@aabadie
Copy link
Contributor

aabadie commented Nov 2, 2021

This way Murdock won't build it for these boards and no need to maintain an explicit list of boards to blacklist.

On a second thought, the proposal is stupid: that will exclude all boards that provide periph_i2c, so not a good idea at all :)

@maribu
Copy link
Member

maribu commented Nov 2, 2021

This way Murdock won't build it for these boards and no need to maintain an explicit list of boards to blacklist.

On a second thought, the proposal is stupid: that will exclude all boards that provide periph_i2c, so not a good idea at all :)

It should only exclude boards that provide and use that feature. In fact, blacklisting the feature will result in the feature not being used on the blacklisted board, so this is indeed the better approach. (Optional features will only get included if they are not blacklisted and provided.)

tests/pkg_fff/Makefile Outdated Show resolved Hide resolved
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. Thanks for the contribution!

@miri64 miri64 merged commit 67f67bf into RIOT-OS:master Nov 3, 2021
@fjmolinas fjmolinas added this to the Release 2022.01 milestone Nov 18, 2021
@gschorcht
Copy link
Contributor

Even though tests/pkg_fff is compilable for EPS32, it doesn't work on ESP32, so that CI can't succeed if label CI: run tests is set, see the log. How can we solve it to get CI green when running tests in CI?

@aabadie
Copy link
Contributor

aabadie commented Jun 15, 2022

How can we solve it to get CI green when running tests in CI?

Maybe just blacklist that package on esp32 that would skip it from both build and test.

@jenswet
Copy link
Contributor Author

jenswet commented Jun 15, 2022

Even though tests/pkg_fff is compilable for EPS32, it doesn't work on ESP32, so that CI can't succeed if label CI: run tests is set, see the log. How can we solve it to get CI green when running tests in CI?

2a13f07 broke the test. This prevents any UART output. Hello world is also unsuccessful on the ESP32 platform with this flag.

What was the reason to add it?

@maribu
Copy link
Member

maribu commented Jun 15, 2022

MAXTHREADS controls the number of threads RIOT can run simultaneously. Reducing it lowers the RAM requirements. So when applications fail to link on some boards due to RAM constrains, it is an easy option to lower RAM requirements to keep the test available for the boards.

Any app that never calls thread_create() directly or implicitly will have at most two threads (the main thread and the idle thread, for platforms that cannot idle threadless). But it seems that ESP32 is special in that it uses more threads no matter what.

bors bot added a commit that referenced this pull request Jan 15, 2023
17066: sys/irq: Add C++ wrapper using RAII r=maribu a=jenswet

### Contribution description

This adds a C++ wrapper around the `irq.h` API. The wrapper uses RAII to accomplish a convenient and bug resistent use.
 
A little background: I'm currently writing my master thesis on using C++ for embedded development, at the working group that `@maribu` is part of. For that I will try to add better C++ support to several parts of RIOT and then do some benchmarking and metrics to compare it with the C implementation. For example, I also plan to add a wrapper around i2c, a std::cout drop-in replacement and probably some more about networks or threads.

### Testing procedure

I've added a unit test to verify that the IRQ wrapper calls the original `irq` functions as expected. As C++ and wrapper testing isn't done much so far in this project, I've added two additional headers to ease testing:
1.  #17076 - fake functions framework, already merged
2. As there is no framework for C++ unit tests yet, I've added something for this too. Unfortunately the existing frameworks like GoogleTest, CppUTest or CppUnit don't easily compile for embedded or are difficult to integrate in to the RIOT build process. That's why I wrote some (simple) helper functions and macros inspired by the above frameworks. That allows to create C++ tests based on a fixture class with set up and tear down methods. It also allows some simple assertions and is easily extendable for other use cases. It wraps some of the fff functionality too.

Both of this is obviously not required for the initial reason of this PR. But I'd like to provide unit tests for the features that I suggest to introduce where possible. So I'd appreciate some feedback on that too. If you'd prefer a PR without or different tests please let me know.

You can run the test `irq_cpp` locally or on the CI to test the implementation.

Please feel free to give feedback or suggest improvements!

Co-authored-by: Jens Wetterich <jens@wetterich-net.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants