summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-07 14:04:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-07 14:04:47 -0700
commitef3ad0898a60d30da7f170032992914998c366e5 (patch)
tree6076ccc1d0769a3b997f7948ab773e8bffcc784d /tools
parent37949075ab628e8ef36a877108c2d95b13221cc5 (diff)
parente67f85fb96ca80e5a60ea69c536affed0affc77d (diff)
Merge tag 'linux-kselftest-4.13-rc1-update' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull Kselftest updates from Shuah Khan: "This update consists of: - TAP13 framework and changes to some tests to convert to TAP13. Converting kselftest output to standard format will help identify run to run differences and pin point failures easily. TAP13 format has been in use for several years and the output is human friendly. Please find the specification: https://testanything.org/tap-version-13-specification.html Credit goes to Tim Bird for recommending TAP13 as a suitable format, and to Grag KH for kick starting the work with help from Paul Elder and Alice Ferrazzi The first phase of the TAp13 conversion is included in this update. Future updates will include updates to rest of the tests. - Masami Hiramatsu fixed ftrace to run on 4.9 stable kernels. - Kselftest documnetation has been converted to ReST format. Document now has a new home under Documentation/dev-tools. - kselftest_harness.h is now available for general use as a result of Mickaël Salaün's work. - Several fixes to skip and/or fail tests gracefully on older releases" * tag 'linux-kselftest-4.13-rc1-update' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (48 commits) selftests: membarrier: use ksft_* var arg msg api selftests: breakpoints: breakpoint_test_arm64: convert test to use TAP13 selftests: breakpoints: step_after_suspend_test use ksft_* var arg msg api selftests: breakpoint_test: use ksft_* var arg msg api kselftest: add ksft_print_msg() function to output general information kselftest: make ksft_* output functions variadic selftests/capabilities: Fix the test_execve test selftests: intel_pstate: add .gitignore selftests: fix memory-hotplug test selftests: add missing test name in memory-hotplug test selftests: check percentage range for memory-hotplug test selftests: check hot-pluggagble memory for memory-hotplug test selftests: typo correction for memory-hotplug test selftests: ftrace: Use md5sum to take less time of checking logs tools/testing/selftests/sysctl: Add pre-check to the value of writes_strict kselftest.rst: do some adjustments after ReST conversion selftest/net/Makefile: Specify output with $(OUTPUT) selftest/intel_pstate/aperf: Use LDLIBS instead of LDFLAGS selftest/memfd/Makefile: Fix build error selftests: lib: Skip tests on missing test modules ...
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/breakpoints/breakpoint_test.c45
-rw-r--r--tools/testing/selftests/breakpoints/breakpoint_test_arm64.c95
-rw-r--r--tools/testing/selftests/breakpoints/step_after_suspend_test.c84
-rw-r--r--tools/testing/selftests/capabilities/test_execve.c7
-rwxr-xr-xtools/testing/selftests/ftrace/ftracetest2
-rw-r--r--tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc8
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc28
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc9
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc19
-rw-r--r--tools/testing/selftests/ftrace/test.d/instances/instance-event.tc5
-rw-r--r--tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc1
-rw-r--r--tools/testing/selftests/futex/functional/futex_requeue_pi.c3
-rw-r--r--tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c4
-rw-r--r--tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c3
-rw-r--r--tools/testing/selftests/futex/functional/futex_wait_private_mapped_file.c5
-rw-r--r--tools/testing/selftests/futex/functional/futex_wait_timeout.c4
-rw-r--r--tools/testing/selftests/futex/functional/futex_wait_uninitialized_heap.c3
-rw-r--r--tools/testing/selftests/futex/functional/futex_wait_wouldblock.c3
-rw-r--r--tools/testing/selftests/futex/include/logging.h4
-rw-r--r--tools/testing/selftests/intel_pstate/.gitignore2
-rw-r--r--tools/testing/selftests/intel_pstate/Makefile2
-rw-r--r--tools/testing/selftests/kselftest.h98
-rw-r--r--tools/testing/selftests/kselftest_harness.h (renamed from tools/testing/selftests/seccomp/test_harness.h)689
-rwxr-xr-xtools/testing/selftests/lib/bitmap.sh4
-rwxr-xr-xtools/testing/selftests/lib/printf.sh4
-rw-r--r--tools/testing/selftests/membarrier/membarrier_test.c97
-rw-r--r--tools/testing/selftests/memfd/Makefile2
-rwxr-xr-xtools/testing/selftests/memory-hotplug/mem-on-off-test.sh86
-rw-r--r--tools/testing/selftests/net/Makefile3
-rw-r--r--tools/testing/selftests/seccomp/Makefile2
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c4
-rw-r--r--tools/testing/selftests/size/get_size.c27
-rw-r--r--tools/testing/selftests/sync/sync_test.c13
-rw-r--r--tools/testing/selftests/sysctl/common_tests22
-rwxr-xr-xtools/testing/selftests/sysctl/run_numerictests2
-rwxr-xr-xtools/testing/selftests/sysctl/run_stringtests2
-rw-r--r--tools/testing/selftests/vm/virtual_address_range.c35
37 files changed, 940 insertions, 486 deletions
diff --git a/tools/testing/selftests/breakpoints/breakpoint_test.c b/tools/testing/selftests/breakpoints/breakpoint_test.c
index 120895ab5505..f63356151ad4 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test.c
@@ -16,6 +16,8 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <errno.h>
+#include <string.h>
#include "../kselftest.h"
@@ -42,10 +44,9 @@ static void set_breakpoint_addr(void *addr, int n)
ret = ptrace(PTRACE_POKEUSER, child_pid,
offsetof(struct user, u_debugreg[n]), addr);
- if (ret) {
- perror("Can't set breakpoint addr\n");
- ksft_exit_fail();
- }
+ if (ret)
+ ksft_exit_fail_msg("Can't set breakpoint addr: %s\n",
+ strerror(errno));
}
static void toggle_breakpoint(int n, int type, int len,
@@ -106,8 +107,8 @@ static void toggle_breakpoint(int n, int type, int len,
ret = ptrace(PTRACE_POKEUSER, child_pid,
offsetof(struct user, u_debugreg[7]), dr7);
if (ret) {
- perror("Can't set dr7");
- ksft_exit_fail();
+ ksft_print_msg("Can't set dr7: %s\n", strerror(errno));
+ exit(-1);
}
}
@@ -206,7 +207,7 @@ static void trigger_tests(void)
ret = ptrace(PTRACE_TRACEME, 0, NULL, 0);
if (ret) {
- perror("Can't be traced?\n");
+ ksft_print_msg("Can't be traced? %s\n", strerror(errno));
return;
}
@@ -261,29 +262,30 @@ static void trigger_tests(void)
static void check_success(const char *msg)
{
- const char *msg2;
int child_nr_tests;
int status;
+ int ret;
/* Wait for the child to SIGTRAP */
wait(&status);
- msg2 = "Failed";
+ ret = 0;
if (WSTOPSIG(status) == SIGTRAP) {
child_nr_tests = ptrace(PTRACE_PEEKDATA, child_pid,
&nr_tests, 0);
if (child_nr_tests == nr_tests)
- msg2 = "Ok";
- if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1)) {
- perror("Can't poke\n");
- ksft_exit_fail();
- }
+ ret = 1;
+ if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1))
+ ksft_exit_fail_msg("Can't poke: %s\n", strerror(errno));
}
nr_tests++;
- printf("%s [%s]\n", msg, msg2);
+ if (ret)
+ ksft_test_result_pass(msg);
+ else
+ ksft_test_result_fail(msg);
}
static void launch_instruction_breakpoints(char *buf, int local, int global)
@@ -294,7 +296,7 @@ static void launch_instruction_breakpoints(char *buf, int local, int global)
set_breakpoint_addr(dummy_funcs[i], i);
toggle_breakpoint(i, BP_X, 1, local, global, 1);
ptrace(PTRACE_CONT, child_pid, NULL, 0);
- sprintf(buf, "Test breakpoint %d with local: %d global: %d",
+ sprintf(buf, "Test breakpoint %d with local: %d global: %d\n",
i, local, global);
check_success(buf);
toggle_breakpoint(i, BP_X, 1, local, global, 0);
@@ -316,8 +318,9 @@ static void launch_watchpoints(char *buf, int mode, int len,
set_breakpoint_addr(&dummy_var[i], i);
toggle_breakpoint(i, mode, len, local, global, 1);
ptrace(PTRACE_CONT, child_pid, NULL, 0);
- sprintf(buf, "Test %s watchpoint %d with len: %d local: "
- "%d global: %d", mode_str, i, len, local, global);
+ sprintf(buf,
+ "Test %s watchpoint %d with len: %d local: %d global: %d\n",
+ mode_str, i, len, local, global);
check_success(buf);
toggle_breakpoint(i, mode, len, local, global, 0);
}
@@ -378,10 +381,12 @@ int main(int argc, char **argv)
pid_t pid;
int ret;
+ ksft_print_header();
+
pid = fork();
if (!pid) {
trigger_tests();
- return 0;
+ exit(0);
}
child_pid = pid;
@@ -392,5 +397,5 @@ int main(int argc, char **argv)
wait(NULL);
- return ksft_exit_pass();
+ ksft_exit_pass();
}
diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
index 3897e996541e..960d02100c26 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
@@ -43,19 +43,25 @@ static void child(int size, int wr)
volatile uint8_t *addr = &var[32 + wr];
if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
- perror("ptrace(PTRACE_TRACEME) failed");
+ ksft_print_msg(
+ "ptrace(PTRACE_TRACEME) failed: %s\n",
+ strerror(errno));
_exit(1);
}
if (raise(SIGSTOP) != 0) {
- perror("raise(SIGSTOP) failed");
+ ksft_print_msg(
+ "raise(SIGSTOP) failed: %s\n", strerror(errno));
_exit(1);
}
if ((uintptr_t) addr % size) {
- perror("Wrong address write for the given size\n");
+ ksft_print_msg(
+ "Wrong address write for the given size: %s\n",
+ strerror(errno));
_exit(1);
}
+
switch (size) {
case 1:
*addr = 47;
@@ -100,12 +106,14 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
if (ptrace(PTRACE_SETREGSET, pid, NT_ARM_HW_WATCH, &iov) == 0)
return true;
- if (errno == EIO) {
- printf("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) "
- "not supported on this hardware\n");
- ksft_exit_skip();
- }
- perror("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed");
+ if (errno == EIO)
+ ksft_print_msg(
+ "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) not supported on this hardware: %s\n",
+ strerror(errno));
+
+ ksft_print_msg(
+ "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed: %s\n",
+ strerror(errno));
return false;
}
@@ -117,7 +125,8 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
pid_t wpid;
if (pid < 0) {
- perror("fork() failed");
+ ksft_test_result_fail(
+ "fork() failed: %s\n", strerror(errno));
return false;
}
if (pid == 0)
@@ -125,15 +134,17 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg(
+ "waitpid() failed: %s\n", strerror(errno));
return false;
}
if (!WIFSTOPPED(status)) {
- printf("child did not stop\n");
+ ksft_print_msg(
+ "child did not stop: %s\n", strerror(errno));
return false;
}
if (WSTOPSIG(status) != SIGSTOP) {
- printf("child did not stop with SIGSTOP\n");
+ ksft_print_msg("child did not stop with SIGSTOP\n");
return false;
}
@@ -141,42 +152,49 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
return false;
if (ptrace(PTRACE_CONT, pid, NULL, NULL) < 0) {
- perror("ptrace(PTRACE_SINGLESTEP) failed");
+ ksft_print_msg(
+ "ptrace(PTRACE_SINGLESTEP) failed: %s\n",
+ strerror(errno));
return false;
}
alarm(3);
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg(
+ "waitpid() failed: %s\n", strerror(errno));
return false;
}
alarm(0);
if (WIFEXITED(status)) {
- printf("child did not single-step\t");
+ ksft_print_msg("child did not single-step\n");
return false;
}
if (!WIFSTOPPED(status)) {
- printf("child did not stop\n");
+ ksft_print_msg("child did not stop\n");
return false;
}
if (WSTOPSIG(status) != SIGTRAP) {
- printf("child did not stop with SIGTRAP\n");
+ ksft_print_msg("child did not stop with SIGTRAP\n");
return false;
}
if (ptrace(PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0) {
- perror("ptrace(PTRACE_GETSIGINFO)");
+ ksft_print_msg(
+ "ptrace(PTRACE_GETSIGINFO): %s\n",
+ strerror(errno));
return false;
}
if (siginfo.si_code != TRAP_HWBKPT) {
- printf("Unexpected si_code %d\n", siginfo.si_code);
+ ksft_print_msg(
+ "Unexpected si_code %d\n", siginfo.si_code);
return false;
}
kill(pid, SIGKILL);
wpid = waitpid(pid, &status, 0);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg(
+ "waitpid() failed: %s\n", strerror(errno));
return false;
}
return true;
@@ -194,6 +212,8 @@ int main(int argc, char **argv)
int wr, wp, size;
bool result;
+ ksft_print_header();
+
act.sa_handler = sigalrm;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
@@ -201,14 +221,16 @@ int main(int argc, char **argv)
for (size = 1; size <= 32; size = size*2) {
for (wr = 0; wr <= 32; wr = wr + size) {
for (wp = wr - size; wp <= wr + size; wp = wp + size) {
- printf("Test size = %d write offset = %d watchpoint offset = %d\t", size, wr, wp);
result = run_test(size, MIN(size, 8), wr, wp);
- if ((result && wr == wp) || (!result && wr != wp)) {
- printf("[OK]\n");
- ksft_inc_pass_cnt();
- } else {
- printf("[FAILED]\n");
- ksft_inc_fail_cnt();
+ if ((result && wr == wp) ||
+ (!result && wr != wp))
+ ksft_test_result_pass(
+ "Test size = %d write offset = %d watchpoint offset = %d\n",
+ size, wr, wp);
+ else {
+ ksft_test_result_fail(
+ "Test size = %d write offset = %d watchpoint offset = %d\n",
+ size, wr, wp);
succeeded = false;
}
}
@@ -216,19 +238,18 @@ int main(int argc, char **argv)
}
for (size = 1; size <= 32; size = size*2) {
- printf("Test size = %d write offset = %d watchpoint offset = -8\t", size, -size);
-
- if (run_test(size, 8, -size, -8)) {
- printf("[OK]\n");
- ksft_inc_pass_cnt();
- } else {
- printf("[FAILED]\n");
- ksft_inc_fail_cnt();
+ if (run_test(size, 8, -size, -8))
+ ksft_test_result_pass(
+ "Test size = %d write offset = %d watchpoint offset = -8\n",
+ size, -size);
+ else {
+ ksft_test_result_fail(
+ "Test size = %d write offset = %d watchpoint offset = -8\n",
+ size, -size);
succeeded = false;
}
}
- ksft_print_cnts();
if (succeeded)
ksft_exit_pass();
else
diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index 60b8a95dac26..3fece06e9f64 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -37,17 +37,19 @@ void child(int cpu)
CPU_ZERO(&set);
CPU_SET(cpu, &set);
if (sched_setaffinity(0, sizeof(set), &set) != 0) {
- perror("sched_setaffinity() failed");
+ ksft_print_msg("sched_setaffinity() failed: %s\n",
+ strerror(errno));
_exit(1);
}
if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
- perror("ptrace(PTRACE_TRACEME) failed");
+ ksft_print_msg("ptrace(PTRACE_TRACEME) failed: %s\n",
+ strerror(errno));
_exit(1);
}
if (raise(SIGSTOP) != 0) {
- perror("raise(SIGSTOP) failed");
+ ksft_print_msg("raise(SIGSTOP) failed: %s\n", strerror(errno));
_exit(1);
}
@@ -61,7 +63,7 @@ bool run_test(int cpu)
pid_t wpid;
if (pid < 0) {
- perror("fork() failed");
+ ksft_print_msg("fork() failed: %s\n", strerror(errno));
return false;
}
if (pid == 0)
@@ -69,57 +71,64 @@ bool run_test(int cpu)
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg("waitpid() failed: %s\n", strerror(errno));
return false;
}
if (!WIFSTOPPED(status)) {
- printf("child did not stop\n");
+ ksft_print_msg("child did not stop: %s\n", strerror(errno));
return false;
}
if (WSTOPSIG(status) != SIGSTOP) {
- printf("child did not stop with SIGSTOP\n");
+ ksft_print_msg("child did not stop with SIGSTOP: %s\n",
+ strerror(errno));
return false;
}
if (ptrace(PTRACE_SINGLESTEP, pid, NULL, NULL) < 0) {
if (errno == EIO) {
- printf("ptrace(PTRACE_SINGLESTEP) not supported on this architecture\n");
- ksft_exit_skip();
+ ksft_exit_skip(
+ "ptrace(PTRACE_SINGLESTEP) not supported on this architecture: %s\n",
+ strerror(errno));
}
- perror("ptrace(PTRACE_SINGLESTEP) failed");
+ ksft_print_msg("ptrace(PTRACE_SINGLESTEP) failed: %s\n",
+ strerror(errno));
return false;
}
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg("waitpid() failed: $s\n", strerror(errno));
return false;
}
if (WIFEXITED(status)) {
- printf("child did not single-step\n");
+ ksft_print_msg("child did not single-step: %s\n",
+ strerror(errno));
return false;
}
if (!WIFSTOPPED(status)) {
- printf("child did not stop\n");
+ ksft_print_msg("child did not stop: %s\n", strerror(errno));
return false;
}
if (WSTOPSIG(status) != SIGTRAP) {
- printf("child did not stop with SIGTRAP\n");
+ ksft_print_msg("child did not stop with SIGTRAP: %s\n",
+ strerror(errno));
return false;
}
if (ptrace(PTRACE_CONT, pid, NULL, NULL) < 0) {
- perror("ptrace(PTRACE_CONT) failed");
+ ksft_print_msg("ptrace(PTRACE_CONT) failed: %s\n",
+ strerror(errno));
return false;
}
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg("waitpid() failed: %s\n", strerror(errno));
return false;
}
if (!WIFEXITED(status)) {
- printf("child did not exit after PTRACE_CONT\n");
+ ksft_print_msg("child did not exit after PTRACE_CONT: %s\n",
+ strerror(errno));
return false;
}
@@ -135,28 +144,21 @@ void suspend(void)
struct itimerspec spec = {};
power_state_fd = open("/sys/power/state", O_RDWR);
- if (power_state_fd < 0) {
- perror("open(\"/sys/power/state\") failed (is this test running as root?)");
- ksft_exit_fail();
- }
+ if (power_state_fd < 0)
+ ksft_exit_fail_msg(
+ "open(\"/sys/power/state\") failed (is this test running as root?)\n");
timerfd = timerfd_create(CLOCK_BOOTTIME_ALARM, 0);
- if (timerfd < 0) {
- perror("timerfd_create() failed");
- ksft_exit_fail();
- }
+ if (timerfd < 0)
+ ksft_exit_fail_msg("timerfd_create() failed\n");
spec.it_value.tv_sec = 5;
err = timerfd_settime(timerfd, 0, &spec, NULL);
- if (err < 0) {
- perror("timerfd_settime() failed");
- ksft_exit_fail();
- }
+ if (err < 0)
+ ksft_exit_fail_msg("timerfd_settime() failed\n");
- if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem")) {
- perror("entering suspend failed");
- ksft_exit_fail();
- }
+ if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
+ ksft_exit_fail_msg("Failed to enter Suspend state\n");
close(timerfd);
close(power_state_fd);
@@ -171,6 +173,8 @@ int main(int argc, char **argv)
int err;
int cpu;
+ ksft_print_header();
+
while ((opt = getopt(argc, argv, "n")) != -1) {
switch (opt) {
case 'n':
@@ -187,10 +191,8 @@ int main(int argc, char **argv)
suspend();
err = sched_getaffinity(0, sizeof(available_cpus), &available_cpus);
- if (err < 0) {
- perror("sched_getaffinity() failed");
- ksft_exit_fail();
- }
+ if (err < 0)
+ ksft_exit_fail_msg("sched_getaffinity() failed\n");
for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
bool test_success;
@@ -199,18 +201,14 @@ int main(int argc, char **argv)
continue;
test_success = run_test(cpu);
- printf("CPU %d: ", cpu);
if (test_success) {
- printf("[OK]\n");
- ksft_inc_pass_cnt();
+ ksft_test_result_pass("CPU %d\n", cpu);
} else {
- printf("[FAILED]\n");
- ksft_inc_fail_cnt();
+ ksft_test_result_fail("CPU %d\n", cpu);
succeeded = false;
}
}
- ksft_print_cnts();
if (succeeded)
ksft_exit_pass();
else
diff --git a/tools/testing/selftests/capabilities/test_execve.c b/tools/testing/selftests/capabilities/test_execve.c
index 10a21a958aaf..763f37fecfb8 100644
--- a/tools/testing/selftests/capabilities/test_execve.c
+++ b/tools/testing/selftests/capabilities/test_execve.c
@@ -138,9 +138,6 @@ static void chdir_to_tmpfs(void)
if (chdir(cwd) != 0)
err(1, "chdir to private tmpfs");
-
- if (umount2(".", MNT_DETACH) != 0)
- err(1, "detach private tmpfs");
}
static void copy_fromat_to(int fromfd, const char *fromname, const char *toname)
@@ -248,7 +245,7 @@ static int do_tests(int uid, const char *our_path)
err(1, "chown");
if (chmod("validate_cap_sgidnonroot", S_ISGID | 0710) != 0)
err(1, "chmod");
-}
+ }
capng_get_caps_process();
@@ -384,7 +381,7 @@ static int do_tests(int uid, const char *our_path)
} else {
printf("[RUN]\tNon-root +ia, sgidnonroot => i\n");
exec_other_validate_cap("./validate_cap_sgidnonroot",
- false, false, true, false);
+ false, false, true, false);
if (fork_wait()) {
printf("[RUN]\tNon-root +ia, sgidroot => i\n");
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 717581145cfc..14a03ea1e21d 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -250,7 +250,7 @@ run_test() { # testfile
local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX`
export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
testcase $1
- echo "execute: "$1 > $testlog
+ echo "execute$INSTANCE: "$1 > $testlog
SIG_RESULT=0
if [ $VERBOSE -ge 2 ]; then
__run_test $1 2>> $testlog | tee -a $testlog
diff --git a/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc b/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc
index 0bb5df3c00d4..15e2d3fe1731 100644
--- a/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc
+++ b/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc
@@ -28,7 +28,9 @@ echo '*:*' > set_event
yield
-count=`cat trace | grep -v ^# | wc -l`
+echo 0 > tracing_on
+
+count=`head -n 128 trace | grep -v ^# | wc -l`
if [ $count -eq 0 ]; then
fail "none of events are recorded"
fi
@@ -36,10 +38,12 @@ fi
do_reset
echo 1 > events/enable
+echo 1 > tracing_on
yield
-count=`cat trace | grep -v ^# | wc -l`
+echo 0 > tracing_on
+count=`head -n 128 trace | grep -v ^# | wc -l`
if [ $count -eq 0 ]; then
fail "none of events are recorded"
fi
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
index 9dcd0ca1f49c..8095e122daa9 100644
--- a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
@@ -11,17 +11,6 @@ fi
disable_tracing
clear_trace
-# filter by ?, schedule is always good
-if ! echo "sch?dule" > set_ftrace_filter; then
- # test for powerpc 64
- if ! echo ".sch?dule" > set_ftrace_filter; then
- fail "can not enable schedule filter"
- fi
- cat set_ftrace_filter | grep '^.schedule$'
-else
- cat set_ftrace_filter | grep '^schedule$'
-fi
-
ftrace_filter_check() { # glob grep
echo "$1" > set_ftrace_filter
cut -f1 -d" " set_ftrace_filter > $TMPDIR/actual
@@ -39,11 +28,28 @@ ftrace_filter_check '*schedule*' '^.*schedule.*$'
# filter by *, end match
ftrace_filter_check 'schedule*' '^schedule.*$'
+# Advanced full-glob matching feature is recently supported.
+# Skip the tests if we are sure the kernel does not support it.
+if grep -q 'accepts: .* glob-matching-pattern' README ; then
+
# filter by *, both side match
ftrace_filter_check 'sch*ule' '^sch.*ule$'
# filter by char class.
ftrace_filter_check '[Ss]y[Ss]_*' '^[Ss]y[Ss]_.*$'
+# filter by ?, schedule is always good
+if ! echo "sch?dule" > set_ftrace_filter; then
+ # test for powerpc 64
+ if ! echo ".sch?dule" > set_ftrace_filter; then
+ fail "can not enable schedule filter"
+ fi
+ cat set_ftrace_filter | grep '^.schedule$'
+else
+ cat set_ftrace_filter | grep '^schedule$'
+fi
+
+fi
+
echo > set_ftrace_filter
enable_tracing
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
index aa31368851c9..77dfb6b48186 100644
--- a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
@@ -72,6 +72,15 @@ run_enable_disable() {
test_event_enabled $check_disable
echo "schedule:${enable}_event:$EVENT" > set_ftrace_filter
+ if [ -d ../../instances ]; then # Check instances
+ cur=`cat set_ftrace_filter`
+ top=`cat ../../set_ftrace_filter`
+ if [ "$cur" = "$top" ]; then
+ echo "This kernel is too old to support per instance filter"
+ reset_ftrace_filter
+ exit_unsupported
+ fi
+ fi
echo " make sure it works 5 times"
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
index c8e02ec01eaf..7a9ab4ff83b6 100644
--- a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
@@ -63,6 +63,10 @@ fi
# powerpc uses .schedule
func="schedule"
+available_file=available_filter_functions
+if [ -d ../../instances -a -f ../../available_filter_functions ]; then
+ available_file=../../available_filter_functions
+fi
x=`grep '^\.schedule$' available_filter_functions | wc -l`
if [ "$x" -eq 1 ]; then
func=".schedule"
@@ -71,6 +75,15 @@ fi
echo '** SET TRACEOFF'
echo "$func:traceoff" > set_ftrace_filter
+if [ -d ../../instances ]; then # Check instances