Commit graph

229 commits

Author SHA1 Message Date
Abhishek Mishra
ee4727fdba testing/ostest: Add multi-user permission regression tests
Add CONFIG_TESTING_OSTEST_MULTIUSER tests for seteuid, file permissions,
and pseudoFS/tmpfs permission enforcement.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-06-19 12:19:18 -03:00
Jukka Laitinen
4740945157 ostest: Make POSIX timers test work with CONFIG_ENABLE_PARTIAL_SIGNALS
POSIX timers test doesn't really need signal actions, so we can change it
to synchronously wait for the signal in sigwaitinfo, instead of registering
a signal handler.

Also exclude the test from compilation with CONFIG_DISABLE_ALL_SIGNALS;
the test does require at least partial signal support.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-06-16 08:49:22 +02:00
Nightt
5c703f5603 nshlib/testing: Fix open() arguments.
Pass explicit open flags for the NSH script redirect file so the mode argument is used as file creation permissions.

Add the missing mode argument to AIO ostest open() calls that create the test file.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-22 13:39:04 +08:00
Xiang Xiao
f9f59bd0f8 !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats
Now that time_t is unconditionally 64-bit (signed int64_t) and the
struct timespec fields tv_sec / tv_nsec are wide enough on their own,
the explicit (uint64_t)/(int64_t)/(int) casts that used to guard the
multiplications and subtractions in *_us / *_ms / *_ns helpers are no
longer needed.  Drop them to keep the timekeeping math readable.

In the same spirit, this commit also normalises the printf-style format
specifiers and casts used to print tv_sec / tv_nsec / tv_usec values.
The prior code was a mix of "%d"/"%u"/"%ld"/"%lu"/"%lld" with matching
(int)/(unsigned long)/(long long) casts; some formats truncated time_t
on 32-bit hosts, others mismatched signedness or width.  Replace all
such cases with the portable POSIX-recommended forms:

  - tv_sec  (time_t,       signed, impl-defined width) -> %jd  + (intmax_t)
  - tv_nsec (long,         signed)                     -> %ld  (no cast)
  - tv_usec (suseconds_t / long)                       -> %ld  (no cast)

Also drop two stale `(FAR const time_t *)&ts.tv_sec` casts that are
unnecessary now that ts.tv_sec is plain time_t.

Arithmetic-cleanup files (existing scope):

  - benchmarks/cyclictest/cyclictest.c:        timediff_us()
  - benchmarks/sd_bench/sd_bench_main.c:       get_time_delta_us()
  - examples/oneshot/oneshot_main.c:           maxus computation
  - examples/watchdog/watchdog_main.c:         current_time_ms (x2)
  - industry/nxmodbus/nxmb_internal.h:         nxmb_util_clock_ms()
  - netutils/ntpclient/ntpclient.c:            timespec2ntp()
  - netutils/ptpd/ptpd.c:                      ptp_adjtime()
  - system/dd/dd_main.c:                       elapsed accounting
  - testing/drivers/drivertest/drivertest_posix_timer.c:
                                               get_timestamp()
  - testing/drivers/sd_stress/sd_stress_main.c:get_time_delta()
  - testing/sched/getprime/getprime_main.c:    elapsed accounting
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c:
                                               timespec_avg()

Printf-format-fix files (new in this revision):

  - examples/adjtime/adjtime_main.c
  - examples/charger/charger_main.c
  - examples/netpkt/netpkt_ethercat.c
  - fsutils/mkfatfs/mkfatfs.c
  - graphics/tiff/tiff_initialize.c
  - netutils/ptpd/ptpd.c
  - nshlib/nsh_timcmds.c
  - system/coredump/coredump.c
  - system/ptpd/ptpd_main.c
  - testing/drivers/drivertest/drivertest_oneshot.c
  - testing/mm/kasantest/kasantest.c
  - testing/ostest/semtimed.c
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c
  - testing/sched/timerjitter/timerjitter.c
  - testing/testsuites/kernel/time/cases/clock_test_clock01.c
  - testing/testsuites/kernel/time/cases/clock_test_smoke.c

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-22 13:38:25 +08:00
Xiang Xiao
a6477ec8dc !apps: replace sclock_t with clock_t and drop redundant time_t/off_t casts
Align with the upstream nuttx change that drops the sclock_t alias now
that clock_t is itself a signed 64-bit type (int64_t).  Beyond the pure
sclock_t -> clock_t rename, this commit also removes the
now-unnecessary (time_t)-1 / (time_t)0 / (off_t)-1 casts that were
papering over the previously-unsigned time_t.

Files touched:

  - examples/alarm/alarm_main.c:        sclock_t -> clock_t
  - netutils/dhcpd/dhcpd.c:             sclock_t -> clock_t
  - netutils/ftpd/ftpd.c:               sclock_t -> clock_t
  - netutils/thttpd/libhttpd.c,
    netutils/thttpd/tdate_parse.c:      drop (time_t)-1 / (time_t)0 /
                                        (off_t)-1 sentinel casts
  - system/resmonitor/filldisk.c,
    system/zmodem/zm_receive.c:         sclock_t -> clock_t
  - testing/ostest/wdog.c:              sclock_t -> clock_t (the bulk
                                        of the rename, 30 sites)
  - testing/testsuites/kernel/syscall/cases/{clock_nanosleep_test,
    fsync_test,time_test}.c:            drop (time_t)-1 casts in the
                                        new signed-time_t world

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
Xiang Xiao
72837c8d26 !apps: drop CONFIG_SYSTEM_TIME64 conditionals
NuttX always uses a 64-bit system clock now (time_t/clock_t are
always 64-bit). Remove the obsolete CONFIG_SYSTEM_TIME64 #ifdef
branches and Kconfig dependency.

  - examples/dronecan: drop SYSTEM_TIME64 dependency
  - examples/netlink_route: always use PRIx64
  - netutils/netinit: always use the 1-hour LONG_TIME_SEC
  - netutils/ptpd: always pack the 48-bit seconds field and apply
    the 64-bit overflow guard in timespec_delta_ns()
  - testing/ostest/semtimed: always validate tv_sec >= 0

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
Piyush Patle
9d849adfab include/debug.h: Use <nuttx/debug.h> in apps
Replace app-side includes of <debug.h> with <nuttx/debug.h> to use the
header from the NuttX tree explicitly after the header move.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-11 10:39:27 -03:00
ouyangxiangzhen
e4b84b29d4 ostest/hrtimer: Update the comments.
This commit updated the comments.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
256d6685d5 sched/hrtimer: Refactor the hrtimer_test.
This commit refactored the hrtimer_test and provided significantly
improved test-cases for both SMP and non-SMP.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
d33830e83f ostest/hrtimer: Increase the tolerent latency.
For QEMU, virtual CPUs can be preempted by any high priority thread in
test environments. This can cause the timer to be triggered later than
expected. This commit increased the tolerant latency to avoid the test
failures.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
0bbf5dc092 sched/hrtimer: Improve code readability
This commit improved the code readability.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
1c0281be15 sched/hrtimer: relocate the hrtimer test to simplify.
This commit relocated the hrtimer test to simplify the code.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
e69f9e902b sched/hrtimer: Fix test in QEMU.
This commit fixed the hrtimer test.
In a QEMU environment, the hrtimer latency can be arbitrary because vCPUs can be preempted. We can not assert the latency. we can only issue alerts for excessively high latency.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
9b84a0ab02 sched/hrtimer: Simplify the hrtimer test.
This commit simplified the hrtimer test.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
05e8b0ae60 ostest/hrtimer: Remove HRTIMER_TEST to simplify the code.
This commit removed HRTIMER_TEST to simplify the code.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
da105afee2 ostest/hrtimer: Add missing assert.h
This commit added missing assert.h.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
Matteo Golin
7289c27a85 testing/{ostest,sched/smp}: Remove BOARD_LOOPSPERMSEC references
In an effort to avoid unexpected behaviour from users not calibrating
BOARD_LOOPSPERMSEC, a compilation error occurs when it is undefined. On
some systems, this is allowed (those that use timer implementations
instead of busy-looping for delays). In these cases, we should busy-loop
using the clock time instead of relying on a possibly
undefined/uncalibrated macro.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-09 09:21:50 +01:00
hujun5
b2d4ad67b1 testing/ostest: Add performance event time counter test
Integrate up_perf_gettime() test into ostest suite with comprehensive
test coverage including monotonicity verification, interval statistics,
and frequency validation. The test verifies performance event counter
functionality across 5 independent test cases with proper error handling.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 14:01:00 +08:00
wangchengdong
ebe2dd57dd ostest/hrtimer: sync hrtimer ostest with latest hritmer update
sync hrtimer ostest with latest hritmer update

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-27 23:11:48 +08:00
ouyangxiangzhen
71561d2979 testing/ostest: run spinlock_test only in flat mode.
Since the kernel spinlocks can only work in flat mode, this commit
allowed spinlock_test only in flat mode.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
06d07b1522 testing/ostest: Fix Coverity for spinlock test.
This commit fixed coverity for spinlock test.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
5eef7f324f testing/ostest: refactor the spinlock test.
This commit refactored the spinlock test for better accuracy and
minimized jitters introduced by scheduling.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
anpeiyun
52c2a8909b ostest/spinlock: Check the return value.
This commit added checking for the return value.

Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
2026-01-27 22:59:36 +08:00
anpeiyun
f86246f7c6 ostest/spinlock: fix the operations does not affect the result.
When expanding the macro VERIY, (0 == pthread_barrier_wait(&param->pub->barrier)) < 0 always false.
Regardless of the value of its operands.

Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
36e701448c ostest/spinlock: Check the return value.
This commit added checking for the return value.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
jiangtao16
1b8c90c12d ostest: Add spinlock/rspinlock.
This commit added spinlock/rspinlock test.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
62fe1a3ac5 ostest/wdog: Fix a synchronizing bug.
If we updated `callback_cnt` before the `triggered_tick` in the wdog timer callback, the `wdtest_rand` might failed randomly. This commit fixed the synchronizing bug by swapping the execution order of updating.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
69bfda8736 apps/ostest: Fix wqueue_test in flat mode.
This commit re-enabled wqueue_test in flat mode.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
hujun5
80c2b43197 testing/ostest: fix uninitialized variable warning in wdog test
Initialize the flags variable to 0 to fix compiler warning about
potential use of uninitialized variable. The flags variable is
conditionally assigned in wdtest_rand() based on callback count.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 03:09:24 +08:00
hujun5
d1de009bc2 sched: inline enter_critical_section
Inline enter_critical_section function calls in performance-critical
paths to reduce function call overhead while maintaining consistent
semantics, improving overall system latency and responsiveness in
real-time scenarios.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-26 16:39:15 +08:00
wangchengdong
5456849446 ostest/hrtimer: Add threaded hrtimer tests
Add threaded hrtimer tests

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-21 00:29:40 +08:00
wangchengdong
840c4fceef ostest/hrtimer: align hrtimer callback declaration
align hrtimer callback declaration with latest update of hrtimer

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-21 00:29:40 +08:00
wangchengdong
19dd2531fb testing/ostest: fix build issue
fix:

  Building NuttX...

  /d/a/nuttx-apps/nuttx-apps/sources/apps/Application.mk:238: target 'signest.c.d.a.nuttx-apps.nuttx-  apps.sources.apps.testing.ostest.o' given more than once in the same rule

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-20 17:01:42 +01:00
wangchengdong
d9afe2db8c signals: fix build and runtime issues when signals all isabled
Fix build and runtime issues when signals all disabled.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-19 22:55:19 +08:00
wangchengdong
df30f84f33 ostest/hrtimer: sync hrtimer test with latest updates
Synchronize the hrtimer ostest with the latest hrtimer changes.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-19 08:37:08 -03:00
wangchengdong
60d814efa2 sched/signal: Add support to disable partial or all signals
Fix dependency issue when signals are partially or fully enabled

Co-authored-by: guoshichao <guoshichao@xiaomi.com>
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-15 15:48:54 +08:00
hujun5
21f4156048 sighand: need block WAKEUP_SIGNAL in current tcb
If the main thread receives the signal, the waiter_main will not be awakened.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-12 00:55:33 +08:00
wangchengdong
416c315f92 ostest: sync hrtimer ostest with hrtimer updates
Update the hrtimer ostest to reflect recent changes in the hrtimer
implementation.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-07 09:44:42 +08:00
wangchengdong
fb4f80665d ostest/hrtimer: Fix typos
The current code incorrectly used the CONFIG_SCHED_EVENTS
macro in ostest.h for hrtimer_test(). This has been corrected to use CONFIG_HRTIMER.

Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
2025-12-25 23:06:42 +08:00
wangchengdong
4d98ecccaf testing/ostest: add hrtimer API functional tests
Add functional tests for the newly added hrtimer APIs,
including hrtimer_init(), hrtimer_start(), and hrtimer_cancel().

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-12-24 09:52:18 +08:00
hujun5
24e1c4df6f testing/ostest/smp_call.c: fix smp_call cpu_set inconsistency issue
If we set CONFIG_SMP_DEFAULT_CPUSET=1
This will cause the value of cpuset to be 0x1,
((1 << CONFIG_SMP_NCPUS) - 1) will result in the cpuset being 0x11,
leading to test case errors.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-09 09:44:37 -05:00
buxiasen
3bd8506ae8 testing/ostest/roundrobin: add compatible for SMP
Fix if SMP cause calculation run in multi-core cause case break.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-12-01 19:09:27 +08:00
buxiasen
b95c9980b5 apps/ostest/roundrobin: add fail detect and print
Before patch we never detect the roundrobin fail.
After patch use a array to detect if the calculation swapped when
processing.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-12-01 19:09:27 +08:00
wangchengdong
bd10572851 testing/ostest: align wdog ostest with wdog bugfix
https://github.com/apache/nuttx/pull/17293 fixed
    wd_start bug, and this patch fixed the related ostest
    accordingly

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-11-10 10:44:53 +08:00
wangchengdong
1b9d420e79 sched/event: add nxevent_getmask tests
add test cases for the new nxevent_getmask() function

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-09-10 13:59:04 +08:00
wangchengdong
7c5800924a testing/ostest: add nxevent_clear() test cases
Add test cases to verify the new recently added nxevent_clear() api

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-09-09 15:36:01 +08:00
ouyangxiangzhen
a03ed46947 ostest/wdog: Remove periodical wdog test cases.
The peridiodical wdog test cases should be removed after removing of the periodical wdog APIs.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-06-05 19:42:52 +08:00
ouyangxiangzhen
a570953257 ostest/wdog: update wdog_test.
This commit updated the wdog_test to adapt to the semantic changes of
the wd_start.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-05-22 13:27:16 +08:00
ouyangxiangzhen
afade4f5c9 testing/ostest: add periodic wdog testing.
This commit added periodic wdog testing.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-05-22 13:27:16 +08:00
Jukka Laitinen
376cc5a731 testing/ostest: Add checking of signal delivery TID to signest test
- Add another signal action, "interfere_action", and signal the interfere thread
- In both signal action functions (waiter and interfere), check that they get executed
  in correct thread's context

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-05-08 23:21:13 +08:00