aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/timers
AgeCommit message (Collapse)AuthorFilesLines
2024-09-30selftests:timers: posix_timers: Fix warn_unused_result in __fatal_error()Shuah Khan1-4/+8
__fatal_error routine doesn't check strerror_r() return value, which results in the following compile time warning: posix_timers.c: In function ‘__fatal_error’: posix_timers.c:31:9: warning: ignoring return value of ‘strerror_r’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | strerror_r(errno, buf, sizeof(buf)); Fix this by adding a check for return value and error handling appropriate for the GNU-specific strerror_r() in use in __fatal_error(). Check if return string is null and handle accordingly. From Linux strerror_r() manual page: "The GNU-specific strerror_r() returns a pointer to a string containing the error message. This may be either a pointer to a string that the function stores in buf, or a pointer to some (immutable) static string (in which case buf is unused). If the function stores a string in buf, then at most buflen bytes are stored (the string may be truncated if buflen is too small and errnum is unknown). The string always includes a terminating null byte." Signed-off-by: Shuah Khan <[email protected]> Acked-by: John Stultz <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2024-09-17Merge tag 'linux_kselftest-next-6.12-rc1' of ↵Linus Torvalds3-7/+2
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest Pull kselftest update from Shuah Khan: - test coverage for dup_fd() failure handling in unshare_fd() - new selftest for the acct() syscall - basic uprobe testcase - several small fixes and cleanups to existing tests - user and strscpy removal as they became kunit tests - fixes to build failures and warnings * tag 'linux_kselftest-next-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (21 commits) selftests: kselftest: Use strerror() on nolibc selftests/timers: Remove unused NSEC_PER_SEC macro selftests:resctrl: Fix build failure on archs without __cpuid_count() selftests/ftrace: Fix eventfs ownership testcase to find mount point selftests: filesystems: fix warn_unused_result build warnings selftests:core: test coverage for dup_fd() failure handling in unshare_fd() selftests/ftrace: Fix test to handle both old and new kernels kselftest: timers: Fix const correctness selftests/ftrace: Add required dependency for kprobe tests selftests: rust: config: disable GCC_PLUGINS selftests: rust: config: add trailing newline tracing/selftests: Run the ownership test twice selftests/uprobes: Add a basic uprobe testcase selftests: harness: rename __constructor_order for clarification selftests: harness: remove unneeded __constructor_order_last() selftest: acct: Add selftest for the acct() syscall selftests: lib: remove strscpy test selftests: user: remove user suite kselftest: cpufreq: Add RTC wakeup alarm selftests/exec: Fix grammar in an error message. ...
2024-09-06selftests/timers: Remove unused NSEC_PER_SEC macrozhang jiao2-5/+0
By reading the code, I found the macro NSEC_PER_SEC is never referenced in the code. Just remove it. Signed-off-by: zhang jiao <[email protected]> Reviewed-by: Shuah Khan <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2024-08-21kselftest: timers: Fix const correctnessPiotr Zalewski1-2/+2
Make timespec pointers, pointers to const in checklist function. As a consequence, make list parameter in checklist function pointer to const as well. Const-correctness increases readability. Improvement was found by running cppcheck tool on the patched file as follows: ``` cppcheck --enable=all \ tools/testing/selftests/timers/threadtest.c \ --suppress=missingIncludeSystem \ --suppress=unusedFunction ``` Reviewed-by: Shuah Khan <[email protected]> Signed-off-by: Piotr Zalewski <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2024-07-29selftests/timers/posix-timers: Validate overrun after unblockThomas Gleixner1-1/+60
When a timer signal is blocked and later unblocked then one signal should be delivered with the correct number of overruns since the timer was queued. Validate that behaviour. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
2024-07-29selftests/timers/posix-timers: Validate timer_gettime()Thomas Gleixner1-1/+57
timer_gettime() must return the correct expiry time for interval timers even when the timer is not armed, which is the case when a signal is pending but blocked. Works correctly for regular posix timers, but not for posix CPU timers. Add a selftest to validate the fixes. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
2024-07-29selftests/timers/posix-timers: Validate SIGEV_NONEThomas Gleixner1-1/+52
Posix timers with a delivery mode of SIGEV_NONE deliver no signals but the remaining expiry time must be readable via timer_gettime() for both one shot and interval timers. That's implemented correctly for regular posix timers but broken for posix CPU timers. Add a self test so the fixes can be verified. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
2024-07-29selftests/timers/posix_timers: Validate signal rulesThomas Gleixner1-1/+107
Add a test case to validate correct behaviour vs. timer reprogramming and deletion. The handling of queued signals in case of timer reprogramming or deletion is inconsistent at best. POSIX does not really specify the behaviour for that: - "The effect of disarming or resetting a timer with pending expiration notifications is unspecified." - "The disposition of pending signals for the deleted timer is unspecified." In both cases it is reasonable to expect that pending signals are discarded. Especially in the reprogramming case it does not make sense to account for previous overruns or to deliver a signal for a timer which has been disarmed. Add tests to validate that no unexpected signals are delivered. They fail for now until the signal and posix timer code is updated. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
2024-07-29selftests/timers/posix_timers: Add SIG_IGN testThomas Gleixner1-2/+125
Add a test case to validate correct behaviour vs. SIG_IGN. The posix specification states: "Setting a signal action to SIG_IGN for a signal that is pending shall cause the pending signal to be discarded, whether or not it is blocked." The kernel implements this in the signal handling code, but due to the way how posix timers are handling SIG_IGN for periodic timers, the behaviour after installing a real handler again is inconsistent and suprising. The following sequence is expected to deliver a signal: install_handler(SIG); block_signal(SIG); timer_create(...); <- Should send SIG timer_settime(value=100ms, interval=100ms); sleep(1); <- Timer expires and queues signal, timer is not rearmed as that should happen in the signal delivery path ignore_signal(SIG); <- Discards queued signal install_handler(SIG); <- Restore handler, should rearm but does not sleep(1); unblock_signal(SIG); <- Should deliver one signal with overrun count set in siginfo This fails because nothing rearms the timer when the signal handler is restored. Add a test for this case which fails until the signal and posix timer code is fixed. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
2024-07-29selftests/timers/posix_timers: Simplify error handlingThomas Gleixner1-99/+52
No point in returning to main() on fatal errors. Just exit right away. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Reviewed-by: Anna-Maria Behnsen <[email protected]>
2024-07-11selftests/timers: remove unused irqcount variableJohn Hubbard1-2/+1
When building with clang, via: make LLVM=1 -C tools/testing/selftest ...clang warns about an unused irqcount variable. clang is correct: the variable is incremented and then ignored. Fix this by deleting the irqcount variable. Signed-off-by: John Hubbard <[email protected]> Acked-by: John Stultz <[email protected]> Reviewed-by: Muhammad Usama Anjum <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2024-05-06selftests: timers: ksft_exit functions do not returnNathan Chancellor16-40/+40
After commit f7d5bcd35d42 ("selftests: kselftest: Mark functions that unconditionally call exit() as __noreturn"), ksft_exit_...() functions are marked as __noreturn, which means the return type should not be 'int' but 'void' because they are not returning anything (and never were since exit() has always been called). To facilitate updating the return type of these functions, remove 'return' before the calls to ksft_exit_...(), as __noreturn prevents the compiler from warning that a caller of the ksft_exit functions does not return a value because the program will terminate upon calling these functions. Reviewed-by: Muhammad Usama Anjum <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2024-04-12selftests: timers: Fix abs() warning in posix_timers testJohn Stultz1-1/+1
Building with clang results in the following warning: posix_timers.c:69:6: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { ^ So switch to using llabs() instead. Fixes: 0bc4b0cf1570 ("selftests: add basic posix timers selftests") Signed-off-by: John Stultz <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
2024-04-12selftests: timers: Fix posix_timers ksft_print_msg() warningJohn Stultz1-1/+1
After commit 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()") the following warning occurs when building with an older gcc: posix_timers.c:250:2: warning: format not a string literal and no format arguments [-Wformat-security] 250 | ksft_print_msg(errmsg); | ^~~~~~~~~~~~~~ Fix this up by changing it to ksft_print_msg("%s", errmsg) Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()") Signed-off-by: John Stultz <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Justin Stitt <[email protected]> Acked-by: Shuah Khan <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
2024-04-10selftests: timers: Fix valid-adjtimex signed left-shift undefined behaviorJohn Stultz1-37/+36
The struct adjtimex freq field takes a signed value who's units are in shifted (<<16) parts-per-million. Unfortunately for negative adjustments, the straightforward use of: freq = ppm << 16 trips undefined behavior warnings with clang: valid-adjtimex.c:66:6: warning: shifting a negative signed value is undefined [-Wshift-negative-value] -499<<16, ~~~~^ valid-adjtimex.c:67:6: warning: shifting a negative signed value is undefined [-Wshift-negative-value] -450<<16, ~~~~^ .. Fix it by using a multiply by (1 << 16) instead of shifting negative values in the valid-adjtimex test case. Align the values for better readability. Reported-by: Lee Jones <[email protected]> Reported-by: Muhammad Usama Anjum <[email protected]> Signed-off-by: John Stultz <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Muhammad Usama Anjum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/lkml/[email protected]/
2024-04-09selftests/timers/posix_timers: Reimplement check_timer_distribution()Oleg Nesterov1-56/+47
check_timer_distribution() runs ten threads in a busy loop and tries to test that the kernel distributes a process posix CPU timer signal to every thread over time. There is not guarantee that this is true even after commit bcb7ee79029d ("posix-timers: Prefer delivery of signals to the current thread") because that commit only avoids waking up the sleeping process leader thread, but that has nothing to do with the actual signal delivery. As the signal is process wide the first thread which observes sigpending and wins the race to lock sighand will deliver the signal. Testing shows that this hangs on a regular base because some threads never win the race. The comment "This primarily tests that the kernel does not favour any one." is wrong. The kernel does favour a thread which hits the timer interrupt when CLOCK_PROCESS_CPUTIME_ID expires. Rewrite the test so it only checks that the group leader sleeping in join() never receives SIGALRM and the thread which burns CPU cycles receives all signals. In older kernels which do not have commit bcb7ee79029d ("posix-timers: Prefer delivery of signals to the current thread") the test-case fails immediately, the very 1st tick wakes the leader up. Otherwise it quickly succeeds after 100 ticks. CI testing wants to use newer selftest versions on stable kernels. In this case the test is guaranteed to fail. So check in the failure case whether the kernel version is less than v6.3 and skip the test result in that case. [ tglx: Massaged change log, renamed the version check helper ] Fixes: e797203fb3ba ("selftests/timers/posix_timers: Test delivery of signals across threads") Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
2023-10-05selftests: timers: Convert nsleep-lat test to generate KTAP outputMark Brown1-14/+12
Currently the nsleep-lat test does not produce KTAP output but rather a custom format. This means that we only get a pass/fail for the suite, not for each individual test that the suite does. Convert to using the standard kselftest output functions which result in KTAP output being generated. Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2023-10-05selftests: timers: Convert posix_timers test to generate KTAP outputMark Brown1-40/+41
Currently the posix_timers test does not produce KTAP output but rather a custom format. This means that we only get a pass/fail for the suite, not for each individual test that the suite does. Convert to using the standard kselftest output functions which result in KTAP output being generated. As part of this fix the printing of diagnostics in the unlikely event that the pthread APIs fail, these were using perror() but the API functions directly return an error code instead of setting errno. Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2023-07-13tools: timers: fix freq average calculationMinjie Du1-2/+1
Delete a duplicate assignment from this function implementation. The note means ppm is average of the two actual freq samples. But ppm have a duplicate assignment. Signed-off-by: Minjie Du <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2023-04-16selftests/timers/posix_timers: Test delivery of signals across threadsDmitry Vyukov1-0/+77
Test that POSIX timers using CLOCK_PROCESS_CPUTIME_ID eventually deliver a signal to all running threads. This effectively tests that the kernel doesn't prefer any one thread (or subset of threads) for signal delivery. Signed-off-by: Dmitry Vyukov <[email protected]> Signed-off-by: Marco Elver <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2022-07-14selftests: timers: clocksource-switch: adapt to kselftest frameworkWolfram Sang1-3/+5
So we have proper counters at the end of a test. We also print the kselftest header at the end of the test, so we don't mix with the output of the child process. There is only this one test anyhow. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: clocksource-switch: add 'runtime' command line parameterWolfram Sang1-3/+8
So the user can decide how long the test should run. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: clocksource-switch: add command line switch to skip ↵Wolfram Sang1-12/+28
sanity check The sanity check takes a while. If you do repeated checks when debugging, this is time consuming. Add a parameter to skip it. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: clocksource-switch: sort includesWolfram Sang1-5/+5
It is easier to check if you need to add an include if the existing ones are sorted. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: clocksource-switch: fix passing errors from childWolfram Sang1-3/+3
The return value from system() is a waitpid-style integer. Do not return it directly because with the implicit masking in exit() it will always return 0. Access it with appropriate macros to really pass on errors. Fixes: 7290ce1423c3 ("selftests/timers: Add clocksource-switch test from timetest suite") Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: inconsistency-check: adapt to kselftest frameworkWolfram Sang1-14/+18
So we have proper counters at the end of a test, e.g.: # Totals: pass:11 fail:0 xfail:0 xpass:0 skip:1 error:0 Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: nanosleep: adapt to kselftest frameworkWolfram Sang1-7/+11
So we have proper counters at the end of a test, e.g.: # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:8 error:0 Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: fix declarations of main()Wolfram Sang4-4/+4
Mixing up argc/argv went unnoticed because they were not used. Still, this is worth fixing. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-14selftests: timers: valid-adjtimex: build fix for newer toolchainsWolfram Sang1-1/+1
Toolchains with an include file 'sys/timex.h' based on 3.18 will have a 'clock_adjtime' definition added, so it can't be static in the code: valid-adjtimex.c:43:12: error: static declaration of ‘clock_adjtime’ follows non-static declaration Fixes: e03a58c320e1 ("kselftests: timers: Add adjtimex SETOFFSET validity tests") Signed-off-by: Wolfram Sang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2022-07-03selftests:timers: globals don't need initialization to 0Zan Aziz1-1/+1
Global variables do not need to be initialized to 0 and checkpatch flags this error in tools/testing/selftests/timers/alarmtimer-suspend.c: ERROR: do not initialise globals to 0 +int final_ret = 0; Fix this checkpatch error. Signed-off-by: Zan Aziz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2021-12-10selftests: timers: Remove unneeded semicolonZhang Mingyu1-1/+1
Eliminate the following coccinelle check warning: tools/testing/selftests/timers/inconsistency-check.c:75:2-3 Reported-by: Zeal Robot <[email protected]> Signed-off-by: Zhang Mingyu <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2021-12-10kselftests: timers:Remove unneeded semicolonZhang Mingyu1-1/+1
Eliminate the following coccinelle check warning: tools/testing/selftests/timers/alarmtimer-suspend.c:82:2-3 Reported-by: Zeal Robot <[email protected]> Signed-off-by: Zhang Mingyu <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2021-06-07selftests: timers: rtcpie: skip test if default RTC device does not existPo-Hsu Lin1-1/+9
This test will require /dev/rtc0, the default RTC device, or one specified by user to run. Since this default RTC is not guaranteed to exist on all of the devices, so check its existence first, otherwise skip this test with the kselftest skip code 4. Without this patch this test will fail like this on a s390x zVM: $ selftests: timers: rtcpie $ /dev/rtc0: No such file or directory not ok 1 selftests: timers: rtcpie # exit=22 With this patch: $ selftests: timers: rtcpie $ Default RTC /dev/rtc0 does not exist. Test Skipped! not ok 9 selftests: timers: rtcpie # SKIP Fixed up change log so "With this patch" text doesn't get dropped. Shuah Khan <[email protected]> Signed-off-by: Po-Hsu Lin <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2021-03-22timekeeping, clocksource: Fix various typos in commentsIngo Molnar4-6/+6
Fix ~56 single-word typos in timekeeping & clocksource code comments. Signed-off-by: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Stephen Boyd <[email protected]> Cc: Daniel Lezcano <[email protected]> Cc: [email protected]
2020-08-20selftests/timers: Turn off timeout settingPo-Hsu Lin2-0/+2
The following 4 tests in timers can take longer than the default 45 seconds that added in commit 852c8cbf34d3 ("selftests/kselftest/runner.sh: Add 45 second timeout per test") to run: * nsleep-lat - 2m7.350s * set-timer-lat - 2m0.66s * inconsistency-check - 1m45.074s * raw_skew - 2m0.013s Thus they will be marked as failed with the current 45s setting: not ok 3 selftests: timers: nsleep-lat # TIMEOUT not ok 4 selftests: timers: set-timer-lat # TIMEOUT not ok 6 selftests: timers: inconsistency-check # TIMEOUT not ok 7 selftests: timers: raw_skew # TIMEOUT Disable the timeout setting for timers can make these tests finish properly: ok 3 selftests: timers: nsleep-lat ok 4 selftests: timers: set-timer-lat ok 6 selftests: timers: inconsistency-check ok 7 selftests: timers: raw_skew https://bugs.launchpad.net/bugs/1864626 Fixes: 852c8cbf34d3 ("selftests/kselftest/runner.sh: Add 45 second timeout per test") Signed-off-by: Po-Hsu Lin <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2020-03-25.gitignore: add SPDX License IdentifierMasahiro Yamada1-0/+1
Add SPDX License Identifier to all .gitignore files. Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-06-22kselftests: timers: freq-step: Update maximum acceptable precision and errorsMiroslav Lichvar1-3/+3
PTI has a significant impact on precision of the MONOTONIC_RAW clock, which prevents a lot of computers from running the freq-step test. Increase the maximum acceptable precision for the test to not be skipped to 500 nanoseconds. After commit 78b98e3c5a66 ("timekeeping/ntp: Determine the multiplier directly from NTP tick length") the frequency and time errors should be much smaller. Reduce the maximum acceptable values for the test to pass to 0.02 ppm and 50 nanoseconds respectively. Signed-off-by: Miroslav Lichvar <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Prarit Bhargava <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Stephen Boyd <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 295Thomas Gleixner1-9/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of version 2 of the gnu general public license as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 64 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Alexios Zavras <[email protected]> Reviewed-by: Allison Randal <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 166Thomas Gleixner1-2/+1
Based on 1 normalized pattern(s): licensed under the terms of the gnu gpl license version 2 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 62 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Allison Randal <[email protected]> Reviewed-by: Kate Stewart <[email protected]> Reviewed-by: Richard Fontana <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-05-21selftests/timers: Add missing fflush(stdout) callsKees Cook10-0/+12
When running under a pipe, some timer tests would not report output in real-time because stdout flushes were missing after printf()s that lacked a newline. This adds them to restore real-time status output that humans can enjoy. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08selftest/timers: Remove duplicate headerSabyasachi Gupta1-1/+0
Remove duplicate header which is included twice. Signed-off-by: Sabyasachi Gupta <[email protected]> Signed-off-by: Souptick Joarder <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-01-28selftests: timers: use LDLIBS instead of LDFLAGSFathi Boudra1-1/+1
posix_timers fails to build due to undefined reference errors: aarch64-linaro-linux-gcc --sysroot=/build/tmp-rpb-glibc/sysroots/hikey -O2 -pipe -g -feliminate-unused-debug-types -O3 -Wl,-no-as-needed -Wall -DKTEST -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lrt -lpthread posix_timers.c -o /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers /tmp/cc1FTZzT.o: In function `check_timer_create': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:157: undefined reference to `timer_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:170: undefined reference to `timer_settime' collect2: error: ld returned 1 exit status It's GNU Make and linker specific. The default Makefile rule looks like: $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS) When linking is done by gcc itself, no issue, but when it needs to be passed to proper ld, only LDLIBS follows and then ld cannot know what libs to link with. More detail: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html LDFLAGS Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable instead. LDLIBS Library flags or names given to compilers when they are supposed to invoke the linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS variable. https://lkml.org/lkml/2010/2/10/362 tools/perf: libraries must come after objects Link order matters, use LDLIBS instead of LDFLAGS to properly link against libpthread. Signed-off-by: Denys Dmytriyenko <[email protected]> Signed-off-by: Fathi Boudra <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2018-07-10selftest: timers: Tweak raw_skew to SKIP when ADJ_OFFSET/other clock ↵John Stultz1-0/+5
adjustments are in progress In the past we've warned when ADJ_OFFSET was in progress, usually caused by ntpd or some other time adjusting daemon running in non steady sate, which can cause the skew calculations to be incorrect. Thus, this patch checks to see if the clock was being adjusted when we fail so that we don't cause false negatives. Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Miroslav Lichvar <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Prarit Bhargava <[email protected]> Cc: Stephen Boyd <[email protected]> Cc: Shuah Khan <[email protected]> Cc: [email protected] Suggested-by: Miroslav Lichvar <[email protected]> Signed-off-by: John Stultz <[email protected]> --- v2: Widened the checks to look for other clock adjustments that could happen, as suggested by Miroslav v3: Fixed up commit message
2018-05-30selftests: move RTC tests to rtc subfolderAlexandre Belloni4-418/+2
Move the RTC tests out of the timers folder as they are mostly unrelated. Keep rtcpie in timers as it only test hrtimers. Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Shuah Khan (Samsung OSG) <[email protected]>
2018-05-30selftests: timers: rtcpie: restore previous PIE rateAlexandre Belloni1-3/+5
After the test ends, restore the PIE rate to its previous value to be less disruptive. Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Shuah Khan (Samsung OSG) <[email protected]>
2018-05-30selftests: timers: move PIE tests out of rtctestAlexandre Belloni4-80/+138
Since commit 6610e0893b8bc ("RTC: Rework RTC code to use timerqueue for events"), PIE are completely handled using hrtimers, without actually using any underlying hardware RTC. Move PIE testing out of rtctest. It still depends on the presence of an RTC (to access the device file) but doesn't depend on it actually working. Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Shuah Khan (Samsung OSG) <[email protected]>
2017-11-15selftests: timers: Update .gitignore with newly added testsShuah Khan1-0/+2
Update .gitignore with newly added tests. Signed-off-by: Shuah Khan <[email protected]>
2017-11-02License cleanup: add SPDX GPL-2.0 license identifier to files with no licenseGreg Kroah-Hartman1-0/+1
Many source files in the tree are missing licensing information, which makes it harder for compliance tools to determine the correct license. By default all files without license information are under the default license of the kernel, which is GPL version 2. Update the files which contain no license information with the 'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This patch is based on work done by Thomas Gleixner and Kate Stewart and Philippe Ombredanne. How this work was done: Patches were generated and checked against linux-4.14-rc6 for a subset of the use cases: - file had no licensing information it it. - file was a */uapi/* one with no licensing information in it, - file was a */uapi/* one with existing licensing information, Further patches will be generated in subsequent months to fix up cases where non-standard license headers were used, and references to license had to be inferred by heuristics based on keywords. The analysis to determine which SPDX License Identifier to be applied to a file was done in a spreadsheet of side by side results from of the output of two independent scanners (ScanCode & Windriver) producing SPDX tag:value files created by Philippe Ombredanne. Philippe prepared the base worksheet, and did an initial spot review of a few 1000 files. The 4.13 kernel was the starting point of the analysis with 60,537 files assessed. Kate Stewart did a file by file comparison of the scanner results in the spreadsheet to determine which SPDX license identifier(s) to be applied to the file. She confirmed any determination that was not immediately clear with lawyers working with the Linux Foundation. Criteria used to select files for SPDX license identifier tagging was: - Files considered eligible had to be source code files. - Make and config files were included as candidates if they contained >5 lines of source - File already had some variant of a license header in it (even if <5 lines). All documentation files were explicitly excluded. The following heuristics were used to determine which SPDX license identifiers to apply. - when both scanners couldn't find any license traces, file was considered to have no license information in it, and the top level COPYING file license applied. For non */uapi/* files that summary was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 11139 and resulted in the first patch in this series. If that file was a */uapi/* path one, it was "GPL-2.0 WITH Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 WITH Linux-syscall-note 930 and resulted in the second patch in this series. - if a file had some form of licensing information in it, and was one of the */uapi/* ones, it was denoted with the Linux-syscall-note if any GPL family license was found in the file or had no licensing in it (per prior point). Results summary: SPDX license identifier # files ---------------------------------------------------|------ GPL-2.0 WITH Linux-syscall-note 270 GPL-2.0+ WITH Linux-syscall-note 169 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17 LGPL-2.1+ WITH Linux-syscall-note 15 GPL-1.0+ WITH Linux-syscall-note 14 ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5 LGPL-2.0+ WITH Linux-syscall-note 4 LGPL-2.1 WITH Linux-syscall-note 3 ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3 ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1 and that resulted in the third patch in this series. - when the two scanners agreed on the detected license(s), that became the concluded license(s). - when there was disagreement between the two scanners (one detected a license but the other didn't, or they both detected different licenses) a manual inspection of the file occurred. - In most cases a manual inspection of the information in the file resulted in a clear resolution of the license that should apply (and which scanner probably needed to revisit its heuristics). - When it was not immediately clear, the license identifier was confirmed with lawyers working with the Linux Foundation. - If there was any question as to the appropriate license identifier, the file was flagged for further research and to be revisited later in time. In total, over 70 hours of logged manual review was done on the spreadsheet to determine the SPDX license identifiers to apply to the source files by Kate, Philippe, Thomas and, in some cases, confirmation by lawyers working with the Linux Foundation. Kate also obtained a third independent scan of the 4.13 code base from FOSSology, and compared selected files where the other two scanners disagreed against that SPDX file, to see if there was new insights. The Windriver scanner is based on an older version of FOSSology in part, so they are related. Thomas did random spot checks in about 500 files from the spreadsheets for the uapi headers and agreed with SPDX license identifier in the files he inspected. For the non-uapi files Thomas did random spot checks in about 15000 files. In initial set of patches against 4.14-rc6, 3 files were found to have copy/paste license identifier errors, and have been fixed to reflect the correct identifier. Additionally Philippe spent 10 hours this week doing a detailed manual inspection and review of the 12,461 patched files from the initial patch version early this week with: - a full scancode scan run, collecting the matched texts, detected license ids and scores - reviewing anything where there was a license detected (about 500+ files) to ensure that the applied SPDX license was correct - reviewing anything where there was no detection but the patch license was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied SPDX license was correct This produced a worksheet with 20 files needing minor correction. This worksheet was then exported into 3 different .csv files for the different types of files to be modified. These .csv files were then reviewed by Greg. Thomas wrote a script to parse the csv files and add the proper SPDX tag to the file, in the format that the file expected. This script was further refined by Greg based on the output to detect more types of files automatically and to distinguish between header and source .c files (which need different comment types.) Finally Greg ran the script using the .csv files to generate the patches. Reviewed-by: Kate Stewart <[email protected]> Reviewed-by: Philippe Ombredanne <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-09-25selftests: timers: set-timer-lat: Fix hang when testing unsupported alarmsShuah Khan1-3/+6
When timer_create() fails on a bootime or realtime clock, setup_timer() returns 0 as if timer has been set. Callers wait forever for the timer to expire. This hang is seen on a system that doesn't have support for: CLOCK_REALTIME_ALARM ABSTIME missing CAP_WAKE_ALARM? : [UNSUPPORTED] Test hangs waiting for a timer that hasn't been set to expire. Fix setup_timer() to return 1, add handling in callers to detect the unsupported case and return 0 without waiting to not fail the test. Signed-off-by: Shuah Khan <[email protected]>
2017-09-25selftests: timers: set-timer-lat: fix hang when std out/err are redirectedShuah Khan1-3/+1
do_timer_oneshot() uses select() as a timer with FD_SETSIZE and readfs is cleared with FD_ZERO without FD_SET. When stdout and stderr are redirected, the test hangs in select forever. Fix the problem calling select() with readfds empty and nfds zero. This is sufficient for using select() for timer. With this fix "./set-timer-lat > /dev/null 2>&1" no longer hangs. Signed-off-by: Shuah Khan <[email protected]> Acked-by: Greg Hackmann <[email protected]> Signed-off-by: Shuah Khan <[email protected]>