nuttx-apps/testing/ostest/CMakeLists.txt
Marco Casaroli 2631d3e59a testing/ostest: build the perf test only where it can link
perf_gettime() and perf_getfreq() are kernel functions, defined in
sched/clock/clock_perf.c.  Neither appears in syscall.csv, and libc supplies
only perf_gettime(), under CONFIG_ARCH_HAVE_PERF_EVENTS_USER_ACCESS.  So a
protected or kernel build cannot resolve either of them from user space:

  ostest/perf_gettime.c:91:  undefined reference to `perf_gettime'
  ostest/perf_gettime.c:184: undefined reference to `perf_getfreq'
  make[1]: *** [nuttx_user.elf] Error 1

The call in user_main() is guarded by CONFIG_ARCH_PERF_EVENTS &&
!CONFIG_ARCH_PERF_EVENTS_USER_ACCESS -- which is exactly the case where the
symbols are kernel-only -- so every such configuration fails to link.
mps3-an547:knsh is one: it sets CONFIG_SCHED_IRQMONITOR, which makes
ARCH_PERF_EVENTS default y.  mps2-an521:knsh escapes only because it sets
neither monitor, leaving ARCH_PERF_EVENTS off, so the call compiles out and
the archive member is never pulled in.

Require CONFIG_BUILD_FLAT, where ostest links against the kernel's own copy.
No configuration that runs the test today stops running it.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 09:49:59 -03:00

181 lines
4.4 KiB
CMake

# ##############################################################################
# apps/testing/ostest/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_TESTING_OSTEST)
set(SRCS getopt.c libc_memmem.c restart.c sighelper.c)
if(CONFIG_ENABLE_ALL_SIGNALS)
list(APPEND SRCS sighand.c signest.c)
endif()
if(NOT CONFIG_DISABLE_ALL_SIGNALS)
list(APPEND SRCS sigprocmask.c)
endif()
if(CONFIG_DEV_NULL)
list(APPEND SRCS dev_null.c)
endif()
if(CONFIG_SIG_SIGSTOP_ACTION)
if(CONFIG_SIG_SIGKILL_ACTION)
list(APPEND SRCS suspend.c)
endif()
endif()
if(CONFIG_ARCH_FPU)
if(NOT CONFIG_TESTING_OSTEST_FPUTESTDISABLE)
list(APPEND SRCS fpu.c)
endif()
endif()
if(NOT CONFIG_STDIO_DISABLE_BUFFERING)
list(APPEND SRCS setvbuf.c)
endif()
if(NOT CONFIG_TLS_NELEM EQUAL 0)
list(APPEND SRCS tls.c)
endif()
if(CONFIG_TESTING_OSTEST_AIO)
list(APPEND SRCS aio.c)
endif()
if(CONFIG_TESTING_OSTEST_MULTIUSER)
list(APPEND SRCS multiuser.c)
endif()
if(CONFIG_SCHED_WAITPID)
list(APPEND SRCS waitpid.c)
endif()
if(NOT CONFIG_DISABLE_PTHREAD)
list(
APPEND
SRCS
cancel.c
cond.c
mutex.c
timedmutex.c
sem.c
semtimed.c
barrier.c)
list(APPEND SRCS timedwait.c pthread_rwlock.c pthread_rwlock_cancel.c
schedlock.c)
if(CONFIG_SCHED_WAITPID)
list(APPEND SRCS pthread_exit.c)
endif()
if(NOT CONFIG_TLS_NELEM EQUAL 0)
list(APPEND SRCS specific.c)
endif()
if(CONFIG_SCHED_THREAD_LOCAL)
list(APPEND SRCS sched_thread_local.c)
endif()
if(NOT CONFIG_TLS_NCLEANUP EQUAL 0)
list(APPEND SRCS pthread_cleanup.c)
endif()
if(NOT CONFIG_PTHREAD_MUTEX_UNSAFE)
list(APPEND SRCS robust.c)
endif()
if(CONFIG_PTHREAD_MUTEX_TYPES)
list(APPEND SRCS rmutex.c)
endif()
if(CONFIG_FS_NAMED_SEMAPHORES)
list(APPEND SRCS nsem.c)
endif()
if(NOT "${CONFIG_RR_INTERVAL}" STREQUAL "0")
list(APPEND SRCS roundrobin.c)
endif()
if(CONFIG_SCHED_SPORADIC)
list(APPEND SRCS sporadic.c sporadic2.c)
endif()
if(CONFIG_SCHED_WORKQUEUE)
list(APPEND SRCS wqueue.c)
endif()
if(CONFIG_PRIORITY_INHERITANCE)
list(APPEND SRCS prioinherit.c)
endif() # CONFIG_PRIORITY_INHERITANCE
endif() # CONFIG_DISABLE_PTHREAD
if(NOT CONFIG_DISABLE_MQUEUE)
if(NOT CONFIG_DISABLE_PTHREAD)
list(APPEND SRCS timedmqueue.c)
if(NOT CONFIG_DISABLE_ALL_SIGNALS)
list(APPEND SRCS mqueue.c)
endif()
endif() # CONFIG_DISABLE_PTHREAD
endif() # CONFIG_DISABLE_MQUEUE
if(NOT CONFIG_DISABLE_POSIX_TIMERS)
list(APPEND SRCS posixtimer.c)
if(CONFIG_SIG_EVTHREAD)
list(APPEND SRCS sigev_thread.c)
endif()
endif()
if(CONFIG_ARCH_HAVE_FORK)
if(CONFIG_SCHED_WAITPID)
list(APPEND SRCS vfork.c)
endif()
endif()
if(CONFIG_ARCH_SETJMP_H)
list(APPEND SRCS setjmp.c)
endif()
if(CONFIG_SMP)
list(APPEND SRCS smp_call.c)
endif()
if(CONFIG_SCHED_EVENTS AND CONFIG_BUILD_FLAT)
list(APPEND SRCS nxevent.c)
endif()
# perf_gettime() and perf_getfreq() live in the kernel and are not system
# calls, so only a flat build can reach them from here.
if(CONFIG_ARCH_HAVE_PERF_EVENTS AND CONFIG_BUILD_FLAT)
list(APPEND SRCS perf_gettime.c)
endif()
if(CONFIG_BUILD_FLAT)
list(APPEND SRCS wdog.c spinlock.c)
if(CONFIG_HRTIMER)
list(APPEND SRCS hrtimer.c)
endif()
endif()
set(OSTEST_SRCS ostest_main.c ${SRCS})
nuttx_add_application(NAME ostest SRCS ${OSTEST_SRCS})
endif()