nuttx
nuttx copied to clipboard
Add LTP build for sim and allow long arguments for archive
Summary
This adds a build configuration for sim that includes the LTP posix tests. Because this test suite is very large there are a couple build system related changes that were also needed:
- Include the relative path in the archive. Without this we overwrite the files in the archive if they have two object names that are the same. (P argument on ar)
- Add a
MAX_ARGS
Makefile macro that helps split up calls that include a large number of augments. Here this is used withARCHIVE_ADD
so batches of 100 objects are added at a time, keeping us under the limit for max command line arguments in a normal situation.
Impact
The simulator can now run the LTP tests. Note that many of the fail including causing segfaults this will need to be iterated on.
Testing
Local testing as well as CI
NOTE: We will need to adjust the app repo so that the expected compiler warnings are allowed for this application. This needs to be done prior to merging this.
NuttShell (NSH) NuttX-10.0.1
nsh> ltp_interfaces_timer_settime_9_2
Test for value 1618085024 sec 735625645 nsec
Timer expired 1618085024 sec 735725645 nsec
Test for value 1618085025 sec 735725645 nsec
Timer expired 1618085025 sec 735825645 nsec
Test for value 1618085026 sec 765825645 nsec
Timer expired 1618085026 sec 765925645 nsec
Test for value 1618085028 sec 765925645 nsec
Timer expired 1618085028 sec 766025645 nsec
Test for value 1618085031 sec 766030645 nsec
Timer expired 1618085031 sec 766225645 nsec
Test for value 1618085035 sec 766225650 nsec
Timer expired 1618085035 sec 766425645 nsec
Test PASSED
nsh> ltp_interfaces_pthread_once_1_1
Test PASSED
nsh> ltp_interfaces_pthread_sigmask_10_1
FAIL: SIGKILL was added to the signal mask
Test FAILED
nsh> ltp_stress_signals_sigismember_stress_1
nsh> ltp_mq_unlink_speculative_7_2
Test PASSED
nsh>
Partial list:
Builtin Apps:
hello
ltp_behavior_timers_1_1
ltp_behavior_timers_2_1
ltp_clock_settime_speculative_4_3
ltp_clock_settime_speculative_4_4
ltp_definitions_errno_h_3_2
ltp_definitions_errno_h_4_1
ltp_definitions_mqueue_h_1_1
ltp_definitions_sched_h_10_1
ltp_definitions_signal_h_26_1
ltp_functional_mqueues_send_rev_2
ltp_functional_semaphores_sem_conpro
ltp_functional_semaphores_sem_philosopher
ltp_functional_semaphores_sem_readerwriter
ltp_functional_semaphores_sem_sleepingbarber
ltp_interfaces_aio_suspend_5_1
ltp_interfaces_asctime_1_1
ltp_interfaces_clock_1_1
ltp_interfaces_clock_2_1
ltp_interfaces_clock_getcpuclockid_1_1
ltp_interfaces_clock_getcpuclockid_1_2
ltp_interfaces_clock_getcpuclockid_5_1
ltp_interfaces_clock_getcpuclockid_6_1
ltp_interfaces_clock_getres_1_1
ltp_interfaces_clock_getres_3_1
ltp_interfaces_clock_getres_5_1
ltp_interfaces_clock_getres_6_1
ltp_interfaces_clock_getres_6_2
ltp_interfaces_clock_gettime_1_1
ltp_interfaces_clock_gettime_1_2
ltp_interfaces_clock_gettime_2_1
ltp_interfaces_clock_gettime_3_1
ltp_interfaces_clock_gettime_7_1
ltp_interfaces_clock_gettime_8_1
ltp_interfaces_clock_gettime_8_2
ltp_interfaces_clock_nanosleep_11_1
ltp_interfaces_clock_nanosleep_1_1
ltp_interfaces_clock_nanosleep_13_1
ltp_interfaces_clock_nanosleep_2_1
ltp_interfaces_clock_nanosleep_3_1
ltp_interfaces_clock_settime_1_1
ltp_interfaces_clock_settime_17_1
ltp_interfaces_clock_settime_17_2
ltp_interfaces_clock_settime_19_1
ltp_interfaces_clock_settime_20_1
ltp_interfaces_clock_settime_4_1
ltp_interfaces_clock_settime_4_2
ltp_interfaces_clock_settime_5_1
ltp_interfaces_clock_settime_5_2
ltp_interfaces_clock_settime_6_1
ltp_interfaces_ctime_1_1
ltp_interfaces_difftime_1_1
ltp_interfaces_fsync_4_1
ltp_interfaces_fsync_5_1
ltp_interfaces_fsync_7_1
ltp_interfaces_gmtime_1_1
ltp_interfaces_gmtime_2_1
ltp_interfaces_kill_2_1
ltp_interfaces_kill_2_2
ltp_interfaces_kill_3_1
ltp_interfaces_killpg_1_1
ltp_interfaces_killpg_2_1
ltp_interfaces_killpg_4_1
ltp_interfaces_killpg_5_1
ltp_interfaces_killpg_6_1
ltp_interfaces_killpg_8_1
ltp_interfaces_localtime_1_1
ltp_interfaces_mktime_1_1
ltp_interfaces_mlock_10_1
ltp_interfaces_mlock_5_1
ltp_interfaces_mlock_8_1
ltp_interfaces_mlockall_13_1
ltp_interfaces_mlockall_13_2
ltp_interfaces_mlockall_3_6
ltp_interfaces_mlockall_3_7
ltp_interfaces_mlockall_8_1
ltp_interfaces_mmap_10_1
Looks like llvm-ar does not support the P
modifier so we will need to use a different solution here. Probably the right thing is to generate the suffix based on the source file directory instead of the makefile directory. That way we will have unique object file names.
@btashton could you explain a little bit about the problem resolved P option?
@btashton could you explain a little bit about the problem resolved P option?
Sure, the main issue is that our object files look something like myfile.a.top.dir.o
but we have that same object name if the object is in dir/1/myfile.c
and dir/2/myfile.c
this means we overwrite the object files adding them to the archive. The P option was a ugly solution because it means that the archive has dir/2/myfile.a.top.dir.o
and dir/1/myfile.a.top.dir.o
instead of just myfile.a.top.dir.o
.
I think the correct solution is that the dirname()
of the object file needs to be included in the object file name not just the CWD
.
This is also technically an issue in the Make.dep file that gets generated as well. I have a solution for that, but the Makefile side is a little more complicated to fix.
@btashton could you explain a little bit about the problem resolved P option?
Sure, the main issue is that our object files look something like
myfile.a.top.dir.o
but we have that same object name if the object is indir/1/myfile.c
anddir/2/myfile.c
We need change CSRCS=myfile.c to CSRCS=dir/1/myfile.c. Application.mk already contain the special process to ensure the unique object file name in this case. Here is the related patch: https://github.com/apache/incubator-nuttx-apps/commit/e48a74f358f119087100cb124707e96e74f81eef
this means we overwrite the object files adding them to the archive. The P option was a ugly solution because it means that the archive has
dir/2/myfile.a.top.dir.o
anddir/1/myfile.a.top.dir.o
instead of justmyfile.a.top.dir.o
.I think the correct solution is that the
dirname()
of the object file needs to be included in the object file name not just theCWD
.This is also technically an issue in the Make.dep file that gets generated as well. I have a solution for that, but the Makefile side is a little more complicated to fix.
Since all source files under apps archive into one library(libapps.a), it is very bad practice to just list the file name and supply the path prefix by VPATH/DEPPATH.
We need change CSRCS=myfile.c to CSRCS=dir/1/myfile.c. Application.mk already contain the special process to ensure the unique object file name in this case. Here is the related patch: apache/incubator-nuttx-apps@e48a74f
I know this. but it is not enough because $(SUFFIX) ends up just being home.bashton.nuttx.apps.testing.ltp.o
So in this case
in apps/testing/ltp/
we have ltp/testcases/open_posix_testsuite/conformance/interfaces/clock/1-1.c
and ltp/testcases/open_posix_testsuite/conformance/interfaces/ctime/1-1.c
This object will be generated 1-1.home.bashton.nuttx.apps.testing.ltp.o
for both on these files.
So we get
ar rcs libapp.a ltp/testcases/open_posix_testsuite/conformance/interfaces/clock/1-1.home.bashton.nuttx.apps.testing.ltp.o ltp/testcases/open_posix_testsuite/conformance/interfaces/ctime/1-1.home.bashton.nuttx.apps.testing.ltp.o
This will result in the second object overwriting the first one in the archive.
I am suggesting that SUFFIX is not good enough using CWD of the Makefile. It instead should be something like $(CWD).$(subst $(DELIM), ., $(basename $(CSRC))).o