Commit dedbf31a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-kselftest-next-6.5-rc1' of...

Merge tag 'linux-kselftest-next-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:

 - allow runners to override the timeout

   This change is made to avoid future increases of long timeouts

 - several other spelling and cleanups

 - a new subtest to video_device_test

 - enhancements to test coverage in clone3 test

 - other fixes to ftrace and cpufreq tests

* tag 'linux-kselftest-next-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/ftace: Fix KTAP output ordering
  selftests/cpufreq: Don't enable generic lock debugging options
  kselftests: Sort the collections list to avoid duplicate tests
  selftest: pidfd: Omit long and repeating outputs
  selftests: allow runners to override the timeout
  selftests/ftrace: Add new test case which checks for optimized probes
  selftests/clone3: test clone3 with exit signal in flags
  kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined
  selftests: prctl: Fix spelling mistake "anonynous" -> "anonymous"
  selftests: media_tests: Add new subtest to video_device_test
parents 9ba92dc1 8cd0d863
......@@ -168,6 +168,28 @@ the `-t` option for specific single tests. Either can be used multiple times::
For other features see the script usage output, seen with the `-h` option.
Timeout for selftests
=====================
Selftests are designed to be quick and so a default timeout is used of 45
seconds for each test. Tests can override the default timeout by adding
a settings file in their directory and set a timeout variable there to the
configured a desired upper timeout for the test. Only a few tests override
the timeout with a value higher than 45 seconds, selftests strives to keep
it that way. Timeouts in selftests are not considered fatal because the
system under which a test runs may change and this can also modify the
expected time it takes to run a test. If you have control over the systems
which will run the tests you can configure a test runner on those systems to
use a greater or lower timeout on the command line as with the `-o` or
the `--override-timeout` argument. For example to use 165 seconds instead
one would use:
$ ./run_kselftest.sh --override-timeout 165
You can look at the TAP output to see if you ran into the timeout. Test
runners which know a test must run under a specific time can then optionally
treat these timeouts then as fatal.
Packaging selftests
===================
......
......@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
uid_t uid = getuid();
ksft_print_header();
ksft_set_plan(18);
ksft_set_plan(19);
test_clone3_supported();
/* Just a simple clone3() should return 0.*/
......@@ -198,5 +198,8 @@ int main(int argc, char *argv[])
/* Do a clone3() in a new time namespace */
test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST);
/* Do a clone3() with exit signal (SIGCHLD) in flags */
test_clone3(SIGCHLD, 0, -EINVAL, CLONE3_ARGS_NO_TEST);
ksft_finished();
}
......@@ -5,11 +5,3 @@ CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
CONFIG_DEBUG_RT_MUTEXES=y
CONFIG_DEBUG_PLIST=y
CONFIG_DEBUG_SPINLOCK=y
CONFIG_DEBUG_MUTEXES=y
CONFIG_DEBUG_LOCK_ALLOC=y
CONFIG_PROVE_LOCKING=y
CONFIG_LOCKDEP=y
CONFIG_DEBUG_ATOMIC_SLEEP=y
......@@ -301,7 +301,7 @@ ktaptest() { # result comment
comment="# $comment"
fi
echo $CASENO $result $INSTANCE$CASENAME $comment
echo $result $CASENO $INSTANCE$CASENAME $comment
}
eval_result() { # sigval
......
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2023 Akanksha J N, IBM corporation
# description: Register/unregister optimized probe
# requires: kprobe_events
case `uname -m` in
x86_64)
;;
arm*)
;;
ppc*)
;;
*)
echo "Please implement other architecture here"
exit_unsupported
esac
DEFAULT=$(cat /proc/sys/debug/kprobes-optimization)
echo 1 > /proc/sys/debug/kprobes-optimization
for i in `seq 0 255`; do
echo "p:testprobe $FUNCTION_FORK+${i}" > kprobe_events || continue
echo 1 > events/kprobes/enable || continue
(echo "forked")
PROBE=$(grep $FUNCTION_FORK /sys/kernel/debug/kprobes/list)
echo 0 > events/kprobes/enable
echo > kprobe_events
if echo $PROBE | grep -q OPTIMIZED; then
echo "$DEFAULT" > /proc/sys/debug/kprobes-optimization
exit_pass
fi
done
echo "$DEFAULT" > /proc/sys/debug/kprobes-optimization
exit_unresolved
......@@ -8,7 +8,8 @@ export logfile=/dev/stdout
export per_test_logging=
# Defaults for "settings" file fields:
# "timeout" how many seconds to let each test run before failing.
# "timeout" how many seconds to let each test run before running
# over our soft timeout limit.
export kselftest_default_timeout=45
# There isn't a shell-agnostic way to find the path of a sourced file,
......@@ -90,6 +91,14 @@ run_one()
done < "$settings"
fi
# Command line timeout overrides the settings file
if [ -n "$kselftest_override_timeout" ]; then
kselftest_timeout="$kselftest_override_timeout"
echo "# overriding timeout to $kselftest_timeout" >> "$logfile"
else
echo "# timeout set to $kselftest_timeout" >> "$logfile"
fi
TEST_HDR_MSG="selftests: $DIR: $BASENAME_TEST"
echo "# $TEST_HDR_MSG"
if [ ! -e "$TEST" ]; then
......
......@@ -37,45 +37,58 @@
#include <time.h>
#include <linux/videodev2.h>
int main(int argc, char **argv)
#define PRIORITY_MAX 4
int priority_test(int fd)
{
int opt;
char video_dev[256];
int count;
struct v4l2_tuner vtuner;
struct v4l2_capability vcap;
/* This test will try to update the priority associated with a file descriptor */
enum v4l2_priority old_priority, new_priority, priority_to_compare;
int ret;
int fd;
int result = 0;
if (argc < 2) {
printf("Usage: %s [-d </dev/videoX>]\n", argv[0]);
exit(-1);
ret = ioctl(fd, VIDIOC_G_PRIORITY, &old_priority);
if (ret < 0) {
printf("Failed to get priority: %s\n", strerror(errno));
return -1;
}
new_priority = (old_priority + 1) % PRIORITY_MAX;
ret = ioctl(fd, VIDIOC_S_PRIORITY, &new_priority);
if (ret < 0) {
printf("Failed to set priority: %s\n", strerror(errno));
return -1;
}
ret = ioctl(fd, VIDIOC_G_PRIORITY, &priority_to_compare);
if (ret < 0) {
printf("Failed to get new priority: %s\n", strerror(errno));
result = -1;
goto cleanup;
}
if (priority_to_compare != new_priority) {
printf("Priority wasn't set - test failed\n");
result = -1;
}
/* Process arguments */
while ((opt = getopt(argc, argv, "d:")) != -1) {
switch (opt) {
case 'd':
strncpy(video_dev, optarg, sizeof(video_dev) - 1);
video_dev[sizeof(video_dev)-1] = '\0';
break;
default:
printf("Usage: %s [-d </dev/videoX>]\n", argv[0]);
exit(-1);
}
cleanup:
ret = ioctl(fd, VIDIOC_S_PRIORITY, &old_priority);
if (ret < 0) {
printf("Failed to restore priority: %s\n", strerror(errno));
return -1;
}
return result;
}
int loop_test(int fd)
{
int count;
struct v4l2_tuner vtuner;
struct v4l2_capability vcap;
int ret;
/* Generate random number of interations */
srand((unsigned int) time(NULL));
count = rand();
/* Open Video device and keep it open */
fd = open(video_dev, O_RDWR);
if (fd == -1) {
printf("Video Device open errno %s\n", strerror(errno));
exit(-1);
}
printf("\nNote:\n"
"While test is running, remove the device or unbind\n"
"driver and ensure there are no use after free errors\n"
......@@ -98,4 +111,46 @@ int main(int argc, char **argv)
sleep(10);
count--;
}
return 0;
}
int main(int argc, char **argv)
{
int opt;
char video_dev[256];
int fd;
int test_result;
if (argc < 2) {
printf("Usage: %s [-d </dev/videoX>]\n", argv[0]);
exit(-1);
}
/* Process arguments */
while ((opt = getopt(argc, argv, "d:")) != -1) {
switch (opt) {
case 'd':
strncpy(video_dev, optarg, sizeof(video_dev) - 1);
video_dev[sizeof(video_dev)-1] = '\0';
break;
default:
printf("Usage: %s [-d </dev/videoX>]\n", argv[0]);
exit(-1);
}
}
/* Open Video device and keep it open */
fd = open(video_dev, O_RDWR);
if (fd == -1) {
printf("Video Device open errno %s\n", strerror(errno));
exit(-1);
}
test_result = priority_test(fd);
if (!test_result)
printf("Priority test - PASSED\n");
else
printf("Priority test - FAILED\n");
loop_test(fd);
}
......@@ -90,7 +90,6 @@ static inline int wait_for_pid(pid_t pid)
}
ret = WEXITSTATUS(status);
ksft_print_msg("waitpid WEXITSTATUS=%d\n", ret);
return ret;
}
......
......@@ -143,6 +143,7 @@ static inline int child_join(struct child *child, struct error *err)
r = -1;
}
ksft_print_msg("waitpid WEXITSTATUS=%d\n", r);
return r;
}
......
......@@ -115,7 +115,8 @@ static int test_pidfd_send_signal_exited_fail(void)
pidfd = open(buf, O_DIRECTORY | O_CLOEXEC);
(void)wait_for_pid(pid);
ret = wait_for_pid(pid);
ksft_print_msg("waitpid WEXITSTATUS=%d\n", ret);
if (pidfd < 0)
ksft_exit_fail_msg(
......
......@@ -97,7 +97,7 @@ TEST_F(vma, renaming) {
TH_LOG("Try to pass invalid name (with non-printable character \\1) to rename the VMA");
EXPECT_EQ(rename_vma((unsigned long)self->ptr_anon, AREA_SIZE, BAD_NAME), -EINVAL);
TH_LOG("Try to rename non-anonynous VMA");
TH_LOG("Try to rename non-anonymous VMA");
EXPECT_EQ(rename_vma((unsigned long) self->ptr_not_anon, AREA_SIZE, GOOD_NAME), -EINVAL);
}
......
......@@ -26,6 +26,7 @@ Usage: $0 [OPTIONS]
-l | --list List the available collection:test entries
-d | --dry-run Don't actually run any tests
-h | --help Show this usage info
-o | --override-timeout Number of seconds after which we timeout
EOF
exit $1
}
......@@ -33,6 +34,7 @@ EOF
COLLECTIONS=""
TESTS=""
dryrun=""
kselftest_override_timeout=""
while true; do
case "$1" in
-s | --summary)
......@@ -51,6 +53,9 @@ while true; do
-d | --dry-run)
dryrun="echo"
shift ;;
-o | --override-timeout)
kselftest_override_timeout="$2"
shift 2 ;;
-h | --help)
usage 0 ;;
"")
......@@ -85,7 +90,7 @@ if [ -n "$TESTS" ]; then
available="$(echo "$valid" | sed -e 's/ /\n/g')"
fi
collections=$(echo "$available" | cut -d: -f1 | uniq)
collections=$(echo "$available" | cut -d: -f1 | sort | uniq)
for collection in $collections ; do
[ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg
tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2)
......
......@@ -84,12 +84,12 @@ static inline int vdso_test_clock(unsigned int clock_id)
int main(int argc, char **argv)
{
int ret;
int ret = 0;
#if _POSIX_TIMERS > 0
#ifdef CLOCK_REALTIME
ret = vdso_test_clock(CLOCK_REALTIME);
ret += vdso_test_clock(CLOCK_REALTIME);
#endif
#ifdef CLOCK_BOOTTIME
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment