Closed felipebalbi closed 4 years ago
You also have other problems here which you will hit afterwards. How are you going to pass defconfigs and directly only sources which should compile according to that defconfig? Also selecting all arches will never happen as you will get multiple stuff defined for the same thing.
There is a reason why kernel uses its own build system :wink:
Not to dismiss ceedling in any way, just in the spirit of "right tool for the job", I read something about the kernel having its own unit testing/mocking framework these days: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html And some brief explanation on mocking: https://www.kernel.org/doc/html/latest/dev-tools/kunit/usage.html#isolating-behavior
Haven't used it myself but if it's in the mainline kernel, it should work I guess :)
In all fairness, this was really a fun experiment :-) Still, it highlights what may be a problem with Ceedling going forward. Trying to enumerate every directory in the include path and passing it to -I
may become an issue with larger projects, this is not something limited to the linux kernel :-)
Hey @felipebalbi, have you find a way to solve that?
Currently I'm working on a project that has a long folder structure, which produces a big argument for the compiler (the same situation you explained). With that, I'm not able to run the framework.
Let me know your updates!
I am also having the same issue. I tried to give a shorter path with symbolic link but it did not work. I gave me following error as it could not find the include files.
Procedure:
1.Creating a symbolic path
../Includes$ sudo ln -sf /opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi/usr/include
2.My folder structure looks like
../Includes$ tree . ├── can.h ├── defs.h ├── include -> /opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi/usr/include ├── main.h └── unit_tests └── include -> /opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi/usr/include
3.Running test using following
ceedling verbosity[5] test:all
4.Log
Test 'test_can.c'
-----------------
Verbose: exec(): arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -MM -MG -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "build/temp/_test_can.c"
> Shell executed command:
'arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -MM -MG -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "build/temp/_test_can.c"'
> Produced output:
_test_can.o: build/temp/_test_can.c \
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \
@@@@unity.h Includes/can.h @@@@can.h
Verbose: exec(): arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "tests/test_can.c" -o "build/test/preprocess/files/test_can.c"
> Shell executed command:
'arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "tests/test_can.c" -o "build/test/preprocess/files/test_can.c"'
Linking test_can.out...
Command: {:line=>"gcc -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now \"build/test/out/c/test_can_runner.o\" \"build/test/out/c/test_can.o\" \"build/test/out/c/unity.o\" \"build/test/out/c/can.o\" \"build/test/out/c/cmock.o\" -o \"build/test/out/test_can.out\"", :options=>{:stderr_redirect=>:none, :background_exec=>:none}}
Verbose: exec(): gcc -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now "build/test/out/c/test_can_runner.o" "build/test/out/c/test_can.o" "build/test/out/c/unity.o" "build/test/out/c/can.o" "build/test/out/c/cmock.o" -o "build/test/out/test_can.out"
/usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40)
build/test/out/c/test_can_runner.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
ERROR: Shell command failed.
> Shell executed command:
'gcc -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now "build/test/out/c/test_can_runner.o" "build/test/out/c/test_can.o" "build/test/out/c/unity.o" "build/test/out/c/can.o" "build/test/out/c/cmock.o" -o "build/test/out/test_can.out"'
> And exited with status: [1].
NOTICE: If the linker reports missing symbols, the following may be to blame:
1. Test lacks #include statements corresponding to needed source files.
2. Project search paths do not contain source files corresponding to #include statements in the test.
3. Test does not #include needed mocks.
rake aborted!
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/generator.rb:151:in `rescue in generate_executable_file'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/generator.rb:136:in `generate_executable_file'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/rules_tests.rake:39:in `block in <top (required)>'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/task_invoker.rb:107:in `invoke_test_results'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:125:in `block in setup_and_invoke'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:51:in `setup_and_invoke'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/tasks_tests.rake:13:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:345:in `block in <top (required)>'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:332:in `<top (required)>'
/usr/local/bin/ceedling:23:in `load'
/usr/local/bin/ceedling:23:in `<main>'
Caused by:
ShellExecutionException: ShellExecutionException
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/tool_executor.rb:88:in `exec'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/generator.rb:136:in `generate_executable_file'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/rules_tests.rake:39:in `block in <top (required)>'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/task_invoker.rb:107:in `invoke_test_results'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:125:in `block in setup_and_invoke'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:51:in `setup_and_invoke'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/tasks_tests.rake:13:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:345:in `block in <top (required)>'
/var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:332:in `<top (required)>'
/usr/local/bin/ceedling:23:in `load'
/usr/local/bin/ceedling:23:in `<main>'
Tasks: TOP => build/test/results/test_can.pass => build/test/out/test_can.out
(See full trace by running task with --trace)
ERROR: Ceedling Failed
Found same issue reported here: https://github.com/ThrowTheSwitch/Ceedling/issues/560
Any thoughts ?
I am also having the same issue. I tried to give a shorter path with symbolic link but it did not work. I gave me following error as it could not find the include files.
Procedure:
1.Creating a symbolic path
../Includes$
sudo ln -sf /opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi/usr/include
2.My folder structure looks like
../Includes$ tree . ├── can.h ├── defs.h ├── include -> /opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi/usr/include ├── main.h └── unit_tests └── include -> /opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi/usr/include
3.Running test using following
ceedling verbosity[5] test:all
4.Log
Test 'test_can.c' ----------------- Verbose: exec(): arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -MM -MG -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "build/temp/_test_can.c" > Shell executed command: 'arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -MM -MG -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "build/temp/_test_can.c"' > Produced output: _test_can.o: build/temp/_test_can.c \ /var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ /var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ @@@@unity.h Includes/can.h @@@@can.h Verbose: exec(): arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "tests/test_can.c" -o "build/test/preprocess/files/test_can.c" > Shell executed command: 'arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-imx-wayland/5.10-hardknott/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -E -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"/var/lib/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"tests" -I"src" -I"Includes" -I"Includes/include" -I"Includes/unit_tests" -I"Includes/unit_tests/include" -DTEST -DTEST -DGNU_COMPILER "tests/test_can.c" -o "build/test/preprocess/files/test_can.c"' Linking test_can.out... Command: {:line=>"gcc -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now \"build/test/out/c/test_can_runner.o\" \"build/test/out/c/test_can.o\" \"build/test/out/c/unity.o\" \"build/test/out/c/can.o\" \"build/test/out/c/cmock.o\" -o \"build/test/out/test_can.out\"", :options=>{:stderr_redirect=>:none, :background_exec=>:none}} Verbose: exec(): gcc -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now "build/test/out/c/test_can_runner.o" "build/test/out/c/test_can.o" "build/test/out/c/unity.o" "build/test/out/c/can.o" "build/test/out/c/cmock.o" -o "build/test/out/test_can.out" /usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40) /usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40) /usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40) /usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40) /usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40) /usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40) /usr/bin/ld: build/test/out/c/test_can_runner.o: Relocations in generic ELF (EM: 40) build/test/out/c/test_can_runner.o: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status ERROR: Shell command failed. > Shell executed command: 'gcc -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now "build/test/out/c/test_can_runner.o" "build/test/out/c/test_can.o" "build/test/out/c/unity.o" "build/test/out/c/can.o" "build/test/out/c/cmock.o" -o "build/test/out/test_can.out"' > And exited with status: [1]. NOTICE: If the linker reports missing symbols, the following may be to blame: 1. Test lacks #include statements corresponding to needed source files. 2. Project search paths do not contain source files corresponding to #include statements in the test. 3. Test does not #include needed mocks. rake aborted! /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/generator.rb:151:in `rescue in generate_executable_file' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/generator.rb:136:in `generate_executable_file' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/rules_tests.rake:39:in `block in <top (required)>' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/task_invoker.rb:107:in `invoke_test_results' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:125:in `block in setup_and_invoke' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:51:in `setup_and_invoke' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/tasks_tests.rake:13:in `block (2 levels) in <top (required)>' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:345:in `block in <top (required)>' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:332:in `<top (required)>' /usr/local/bin/ceedling:23:in `load' /usr/local/bin/ceedling:23:in `<main>' Caused by: ShellExecutionException: ShellExecutionException /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/tool_executor.rb:88:in `exec' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/generator.rb:136:in `generate_executable_file' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/rules_tests.rake:39:in `block in <top (required)>' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/task_invoker.rb:107:in `invoke_test_results' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:125:in `block in setup_and_invoke' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/test_invoker.rb:51:in `setup_and_invoke' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/lib/ceedling/tasks_tests.rake:13:in `block (2 levels) in <top (required)>' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:345:in `block in <top (required)>' /var/lib/gems/2.5.0/gems/ceedling-0.31.1/bin/ceedling:332:in `<top (required)>' /usr/local/bin/ceedling:23:in `load' /usr/local/bin/ceedling:23:in `<main>' Tasks: TOP => build/test/results/test_can.pass => build/test/out/test_can.out (See full trace by running task with --trace) ERROR: Ceedling Failed
Found same issue reported here: #560
Any thoughts ?
I am trying to do the same. It seems you have gotten a bit farther than me.
Have you found a solution, and are you using the tools settings in the .yml file?
Hi,
I've been playing around with using Ceedling to test the linux kernel. But
ceedling
ends with a far too long argument list because of the huge amount of include paths. Here's a snippet:test_gadget.c was created automatically. Here's the current
project.yml