aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-16 16:15:12 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-16 16:15:12 -0500
commit61de8e53640ceeda564a65170a46c1edc2b37e11 (patch)
treef5b28f510ba8b6515fbdf67a4d81eccdeae742f5 /tools/testing/selftests
parenta7c180aa7e76a55642e8492f28353303a50292c2 (diff)
parent3ce51050fadd63737c03627293ca2dc4be238891 (diff)
Merge tag 'linux-kselftest-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest update from Shuah Khan: "kselftest updates for 3.19-rc1: - kcmp test include file cleanup - kcmp change to build on all architectures - A light weight kselftest framework that provides a set of interfaces for tests to use to report results. In addition, several tests are updated to use the framework. - A new runtime system size test that prints the amount of RAM that the currently running system is using" * tag 'linux-kselftest-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftest: size: Add size test for Linux kernel selftests/kcmp: Always try to build the test selftests/kcmp: Don't include kernel headers kcmp: Move kcmp.h into uapi selftests/timers: change test to use ksft framework selftests/kcmp: change test to use ksft framework selftests/ipc: change test to use ksft framework selftests/breakpoints: change test to use ksft framework selftests: add kselftest framework for uniform test reporting selftests/user: move test out of Makefile into a shell script selftests/net: move test out of Makefile into a shell script
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r--tools/testing/selftests/Makefile1
-rw-r--r--tools/testing/selftests/breakpoints/breakpoint_test.c10
-rw-r--r--tools/testing/selftests/ipc/msgque.c26
-rw-r--r--tools/testing/selftests/kcmp/Makefile22
-rw-r--r--tools/testing/selftests/kcmp/kcmp_test.c27
-rw-r--r--tools/testing/selftests/kselftest.h62
-rw-r--r--tools/testing/selftests/net/Makefile8
-rwxr-xr-xtools/testing/selftests/net/test_bpf.sh10
-rw-r--r--tools/testing/selftests/size/.gitignore1
-rw-r--r--tools/testing/selftests/size/Makefile12
-rw-r--r--tools/testing/selftests/size/get_size.c100
-rw-r--r--tools/testing/selftests/timers/posix_timers.c14
-rw-r--r--tools/testing/selftests/user/Makefile8
-rwxr-xr-xtools/testing/selftests/user/test_user_copy.sh10
14 files changed, 248 insertions, 63 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index c14893b501a9..b3831f4ba845 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -16,6 +16,7 @@ TARGETS += sysctl
16TARGETS += firmware 16TARGETS += firmware
17TARGETS += ftrace 17TARGETS += ftrace
18TARGETS += exec 18TARGETS += exec
19TARGETS += size
19 20
20TARGETS_HOTPLUG = cpu-hotplug 21TARGETS_HOTPLUG = cpu-hotplug
21TARGETS_HOTPLUG += memory-hotplug 22TARGETS_HOTPLUG += memory-hotplug
diff --git a/tools/testing/selftests/breakpoints/breakpoint_test.c b/tools/testing/selftests/breakpoints/breakpoint_test.c
index a0743f3b2b57..120895ab5505 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test.c
@@ -17,6 +17,8 @@
17#include <sys/types.h> 17#include <sys/types.h>
18#include <sys/wait.h> 18#include <sys/wait.h>
19 19
20#include "../kselftest.h"
21
20 22
21/* Breakpoint access modes */ 23/* Breakpoint access modes */
22enum { 24enum {
@@ -42,7 +44,7 @@ static void set_breakpoint_addr(void *addr, int n)
42 offsetof(struct user, u_debugreg[n]), addr); 44 offsetof(struct user, u_debugreg[n]), addr);
43 if (ret) { 45 if (ret) {
44 perror("Can't set breakpoint addr\n"); 46 perror("Can't set breakpoint addr\n");
45 exit(-1); 47 ksft_exit_fail();
46 } 48 }
47} 49}
48 50
@@ -105,7 +107,7 @@ static void toggle_breakpoint(int n, int type, int len,
105 offsetof(struct user, u_debugreg[7]), dr7); 107 offsetof(struct user, u_debugreg[7]), dr7);
106 if (ret) { 108 if (ret) {
107 perror("Can't set dr7"); 109 perror("Can't set dr7");
108 exit(-1); 110 ksft_exit_fail();
109 } 111 }
110} 112}
111 113
@@ -275,7 +277,7 @@ static void check_success(const char *msg)
275 msg2 = "Ok"; 277 msg2 = "Ok";
276 if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1)) { 278 if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1)) {
277 perror("Can't poke\n"); 279 perror("Can't poke\n");
278 exit(-1); 280 ksft_exit_fail();
279 } 281 }
280 } 282 }
281 283
@@ -390,5 +392,5 @@ int main(int argc, char **argv)
390 392
391 wait(NULL); 393 wait(NULL);
392 394
393 return 0; 395 return ksft_exit_pass();
394} 396}
diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c
index 552f0810bffb..1b2ce334bb3f 100644
--- a/tools/testing/selftests/ipc/msgque.c
+++ b/tools/testing/selftests/ipc/msgque.c
@@ -5,6 +5,8 @@
5#include <linux/msg.h> 5#include <linux/msg.h>
6#include <fcntl.h> 6#include <fcntl.h>
7 7
8#include "../kselftest.h"
9
8#define MAX_MSG_SIZE 32 10#define MAX_MSG_SIZE 32
9 11
10struct msg1 { 12struct msg1 {
@@ -195,58 +197,58 @@ int main(int argc, char **argv)
195 197
196 if (getuid() != 0) { 198 if (getuid() != 0) {
197 printf("Please run the test as root - Exiting.\n"); 199 printf("Please run the test as root - Exiting.\n");
198 exit(1); 200 return ksft_exit_fail();
199 } 201 }
200 202
201 msgque.key = ftok(argv[0], 822155650); 203 msgque.key = ftok(argv[0], 822155650);
202 if (msgque.key == -1) { 204 if (msgque.key == -1) {
203 printf("Can't make key\n"); 205 printf("Can't make key: %d\n", -errno);
204 return -errno; 206 return ksft_exit_fail();
205 } 207 }
206 208
207 msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666); 209 msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666);
208 if (msgque.msq_id == -1) { 210 if (msgque.msq_id == -1) {
209 err = -errno; 211 err = -errno;
210 printf("Can't create queue\n"); 212 printf("Can't create queue: %d\n", err);
211 goto err_out; 213 goto err_out;
212 } 214 }
213 215
214 err = fill_msgque(&msgque); 216 err = fill_msgque(&msgque);
215 if (err) { 217 if (err) {
216 printf("Failed to fill queue\n"); 218 printf("Failed to fill queue: %d\n", err);
217 goto err_destroy; 219 goto err_destroy;
218 } 220 }
219 221
220 err = dump_queue(&msgque); 222 err = dump_queue(&msgque);
221 if (err) { 223 if (err) {
222 printf("Failed to dump queue\n"); 224 printf("Failed to dump queue: %d\n", err);
223 goto err_destroy; 225 goto err_destroy;
224 } 226 }
225 227
226 err = check_and_destroy_queue(&msgque); 228 err = check_and_destroy_queue(&msgque);
227 if (err) { 229 if (err) {
228 printf("Failed to check and destroy queue\n"); 230 printf("Failed to check and destroy queue: %d\n", err);
229 goto err_out; 231 goto err_out;
230 } 232 }
231 233
232 err = restore_queue(&msgque); 234 err = restore_queue(&msgque);
233 if (err) { 235 if (err) {
234 printf("Failed to restore queue\n"); 236 printf("Failed to restore queue: %d\n", err);
235 goto err_destroy; 237 goto err_destroy;
236 } 238 }
237 239
238 err = check_and_destroy_queue(&msgque); 240 err = check_and_destroy_queue(&msgque);
239 if (err) { 241 if (err) {
240 printf("Failed to test queue\n"); 242 printf("Failed to test queue: %d\n", err);
241 goto err_out; 243 goto err_out;
242 } 244 }
243 return 0; 245 return ksft_exit_pass();
244 246
245err_destroy: 247err_destroy:
246 if (msgctl(msgque.msq_id, IPC_RMID, 0)) { 248 if (msgctl(msgque.msq_id, IPC_RMID, 0)) {
247 printf("Failed to destroy queue: %d\n", -errno); 249 printf("Failed to destroy queue: %d\n", -errno);
248 return -errno; 250 return ksft_exit_fail();
249 } 251 }
250err_out: 252err_out:
251 return err; 253 return ksft_exit_fail();
252} 254}
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 8aabd82db9e4..ff0eefdc6ceb 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,25 +1,7 @@
1uname_M := $(shell uname -m 2>/dev/null || echo not) 1CC := $(CROSS_COMPILE)$(CC)
2ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
3ifeq ($(ARCH),i386)
4 ARCH := x86
5 CFLAGS := -DCONFIG_X86_32 -D__i386__
6endif
7ifeq ($(ARCH),x86_64)
8 ARCH := x86
9 CFLAGS := -DCONFIG_X86_64 -D__x86_64__
10endif
11
12CFLAGS += -I../../../../arch/x86/include/generated/
13CFLAGS += -I../../../../include/
14CFLAGS += -I../../../../usr/include/ 2CFLAGS += -I../../../../usr/include/
15CFLAGS += -I../../../../arch/x86/include/
16 3
17all: 4all: kcmp_test
18ifeq ($(ARCH),x86)
19 gcc $(CFLAGS) kcmp_test.c -o kcmp_test
20else
21 echo "Not an x86 target, can't build kcmp selftest"
22endif
23 5
24run_tests: all 6run_tests: all
25 @./kcmp_test || echo "kcmp_test: [FAIL]" 7 @./kcmp_test || echo "kcmp_test: [FAIL]"
diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c
index dbba4084869c..a5a4da856dfe 100644
--- a/tools/testing/selftests/kcmp/kcmp_test.c
+++ b/tools/testing/selftests/kcmp/kcmp_test.c
@@ -17,6 +17,8 @@
17#include <sys/stat.h> 17#include <sys/stat.h>
18#include <sys/wait.h> 18#include <sys/wait.h>
19 19
20#include "../kselftest.h"
21
20static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2) 22static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2)
21{ 23{
22 return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2); 24 return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
@@ -34,13 +36,13 @@ int main(int argc, char **argv)
34 36
35 if (fd1 < 0) { 37 if (fd1 < 0) {
36 perror("Can't create file"); 38 perror("Can't create file");
37 exit(1); 39 ksft_exit_fail();
38 } 40 }
39 41
40 pid2 = fork(); 42 pid2 = fork();
41 if (pid2 < 0) { 43 if (pid2 < 0) {
42 perror("fork failed"); 44 perror("fork failed");
43 exit(1); 45 ksft_exit_fail();
44 } 46 }
45 47
46 if (!pid2) { 48 if (!pid2) {
@@ -50,7 +52,7 @@ int main(int argc, char **argv)
50 fd2 = open(kpath, O_RDWR, 0644); 52 fd2 = open(kpath, O_RDWR, 0644);
51 if (fd2 < 0) { 53 if (fd2 < 0) {
52 perror("Can't open file"); 54 perror("Can't open file");
53 exit(1); 55 ksft_exit_fail();
54 } 56 }
55 57
56 /* An example of output and arguments */ 58 /* An example of output and arguments */
@@ -74,23 +76,34 @@ int main(int argc, char **argv)
74 if (ret) { 76 if (ret) {
75 printf("FAIL: 0 expected but %d returned (%s)\n", 77 printf("FAIL: 0 expected but %d returned (%s)\n",
76 ret, strerror(errno)); 78 ret, strerror(errno));
79 ksft_inc_fail_cnt();
77 ret = -1; 80 ret = -1;
78 } else 81 } else {
79 printf("PASS: 0 returned as expected\n"); 82 printf("PASS: 0 returned as expected\n");
83 ksft_inc_pass_cnt();
84 }
80 85
81 /* Compare with self */ 86 /* Compare with self */
82 ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0); 87 ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0);
83 if (ret) { 88 if (ret) {
84 printf("FAIL: 0 expected but %d returned (%s)\n", 89 printf("FAIL: 0 expected but %d returned (%s)\n",
85 ret, strerror(errno)); 90 ret, strerror(errno));
91 ksft_inc_fail_cnt();
86 ret = -1; 92 ret = -1;
87 } else 93 } else {
88 printf("PASS: 0 returned as expected\n"); 94 printf("PASS: 0 returned as expected\n");
95 ksft_inc_pass_cnt();
96 }
97
98 ksft_print_cnts();
89 99
90 exit(ret); 100 if (ret)
101 ksft_exit_fail();
102 else
103 ksft_exit_pass();
91 } 104 }
92 105
93 waitpid(pid2, &status, P_ALL); 106 waitpid(pid2, &status, P_ALL);
94 107
95 return 0; 108 return ksft_exit_pass();
96} 109}
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
new file mode 100644
index 000000000000..572c8888167a
--- /dev/null
+++ b/tools/testing/selftests/kselftest.h
@@ -0,0 +1,62 @@
1/*
2 * kselftest.h: kselftest framework return codes to include from
3 * selftests.
4 *
5 * Copyright (c) 2014 Shuah Khan <shuahkh@osg.samsung.com>
6 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 *
8 * This file is released under the GPLv2.
9 */
10#ifndef __KSELFTEST_H
11#define __KSELFTEST_H
12
13#include <stdlib.h>
14#include <unistd.h>
15
16/* counters */
17struct ksft_count {
18 unsigned int ksft_pass;
19 unsigned int ksft_fail;
20 unsigned int ksft_xfail;
21 unsigned int ksft_xpass;
22 unsigned int ksft_xskip;
23};
24
25static struct ksft_count ksft_cnt;
26
27static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
28static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
29static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
30static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
31static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
32
33static inline void ksft_print_cnts(void)
34{
35 printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n",
36 ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
37 ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
38 ksft_cnt.ksft_xskip);
39}
40
41static inline int ksft_exit_pass(void)
42{
43 exit(0);
44}
45static inline int ksft_exit_fail(void)
46{
47 exit(1);
48}
49static inline int ksft_exit_xfail(void)
50{
51 exit(2);
52}
53static inline int ksft_exit_xpass(void)
54{
55 exit(3);
56}
57static inline int ksft_exit_skip(void)
58{
59 exit(4);
60}
61
62#endif /* __KSELFTEST_H */
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index c7493b8f9b0e..62f22cc9941c 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -14,12 +14,6 @@ all: $(NET_PROGS)
14run_tests: all 14run_tests: all
15 @/bin/sh ./run_netsocktests || echo "sockettests: [FAIL]" 15 @/bin/sh ./run_netsocktests || echo "sockettests: [FAIL]"
16 @/bin/sh ./run_afpackettests || echo "afpackettests: [FAIL]" 16 @/bin/sh ./run_afpackettests || echo "afpackettests: [FAIL]"
17 @if /sbin/modprobe test_bpf ; then \ 17 ./test_bpf.sh
18 /sbin/rmmod test_bpf; \
19 echo "test_bpf: ok"; \
20 else \
21 echo "test_bpf: [FAIL]"; \
22 exit 1; \
23 fi
24clean: 18clean:
25 $(RM) $(NET_PROGS) 19 $(RM) $(NET_PROGS)
diff --git a/tools/testing/selftests/net/test_bpf.sh b/tools/testing/selftests/net/test_bpf.sh
new file mode 100755
index 000000000000..8b29796d46aa
--- /dev/null
+++ b/tools/testing/selftests/net/test_bpf.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2# Runs bpf test using test_bpf kernel module
3
4if /sbin/modprobe -q test_bpf ; then
5 /sbin/modprobe -q -r test_bpf;
6 echo "test_bpf: ok";
7else
8 echo "test_bpf: [FAIL]";
9 exit 1;
10fi
diff --git a/tools/testing/selftests/size/.gitignore b/tools/testing/selftests/size/.gitignore
new file mode 100644
index 000000000000..189b7818de34
--- /dev/null
+++ b/tools/testing/selftests/size/.gitignore
@@ -0,0 +1 @@
get_size
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
new file mode 100644
index 000000000000..04dc25e4fa92
--- /dev/null
+++ b/tools/testing/selftests/size/Makefile
@@ -0,0 +1,12 @@
1CC = $(CROSS_COMPILE)gcc
2
3all: get_size
4
5get_size: get_size.c
6 $(CC) -static -ffreestanding -nostartfiles -s $< -o $@
7
8run_tests: all
9 ./get_size
10
11clean:
12 $(RM) get_size
diff --git a/tools/testing/selftests/size/get_size.c b/tools/testing/selftests/size/get_size.c
new file mode 100644
index 000000000000..2d1af7cca463
--- /dev/null
+++ b/tools/testing/selftests/size/get_size.c
@@ -0,0 +1,100 @@
1/*
2 * Copyright 2014 Sony Mobile Communications Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2
5 *
6 * Selftest for runtime system size
7 *
8 * Prints the amount of RAM that the currently running system is using.
9 *
10 * This program tries to be as small as possible itself, to
11 * avoid perturbing the system memory utilization with its
12 * own execution. It also attempts to have as few dependencies
13 * on kernel features as possible.
14 *
15 * It should be statically linked, with startup libs avoided.
16 * It uses no library calls, and only the following 3 syscalls:
17 * sysinfo(), write(), and _exit()
18 *
19 * For output, it avoids printf (which in some C libraries
20 * has large external dependencies) by implementing it's own
21 * number output and print routines, and using __builtin_strlen()
22 */
23
24#include <sys/sysinfo.h>
25#include <unistd.h>
26
27#define STDOUT_FILENO 1
28
29static int print(const char *s)
30{
31 return write(STDOUT_FILENO, s, __builtin_strlen(s));
32}
33
34static inline char *num_to_str(unsigned long num, char *buf, int len)
35{
36 unsigned int digit;
37
38 /* put digits in buffer from back to front */
39 buf += len - 1;
40 *buf = 0;
41 do {
42 digit = num % 10;
43 *(--buf) = digit + '0';
44 num /= 10;
45 } while (num > 0);
46
47 return buf;
48}
49
50static int print_num(unsigned long num)
51{
52 char num_buf[30];
53
54 return print(num_to_str(num, num_buf, sizeof(num_buf)));
55}
56
57static int print_k_value(const char *s, unsigned long num, unsigned long units)
58{
59 unsigned long long temp;
60 int ccode;
61
62 print(s);
63
64 temp = num;
65 temp = (temp * units)/1024;
66 num = temp;
67 ccode = print_num(num);
68 print("\n");
69 return ccode;
70}
71
72/* this program has no main(), as startup libraries are not used */
73void _start(void)
74{
75 int ccode;
76 struct sysinfo info;
77 unsigned long used;
78
79 print("Testing system size.\n");
80 print("1..1\n");
81
82 ccode = sysinfo(&info);
83 if (ccode < 0) {
84 print("not ok 1 get runtime memory use\n");
85 print("# could not get sysinfo\n");
86 _exit(ccode);
87 }
88 /* ignore cache complexities for now */
89 used = info.totalram - info.freeram - info.bufferram;
90 print_k_value("ok 1 get runtime memory use # size = ", used,
91 info.mem_unit);
92
93 print("# System runtime memory report (units in Kilobytes):\n");
94 print_k_value("# Total: ", info.totalram, info.mem_unit);
95 print_k_value("# Free: ", info.freeram, info.mem_unit);
96 print_k_value("# Buffer: ", info.bufferram, info.mem_unit);
97 print_k_value("# In use: ", used, info.mem_unit);
98
99 _exit(0);
100}
diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c
index 41bd85559d4b..f87d970a485c 100644
--- a/tools/testing/selftests/timers/posix_timers.c
+++ b/tools/testing/selftests/timers/posix_timers.c
@@ -15,6 +15,8 @@
15#include <time.h> 15#include <time.h>
16#include <pthread.h> 16#include <pthread.h>
17 17
18#include "../kselftest.h"
19
18#define DELAY 2 20#define DELAY 2
19#define USECS_PER_SEC 1000000 21#define USECS_PER_SEC 1000000
20 22
@@ -194,16 +196,16 @@ int main(int argc, char **argv)
194 printf("based timers if other threads run on the CPU...\n"); 196 printf("based timers if other threads run on the CPU...\n");
195 197
196 if (check_itimer(ITIMER_VIRTUAL) < 0) 198 if (check_itimer(ITIMER_VIRTUAL) < 0)
197 return -1; 199 return ksft_exit_fail();
198 200
199 if (check_itimer(ITIMER_PROF) < 0) 201 if (check_itimer(ITIMER_PROF) < 0)
200 return -1; 202 return ksft_exit_fail();
201 203
202 if (check_itimer(ITIMER_REAL) < 0) 204 if (check_itimer(ITIMER_REAL) < 0)
203 return -1; 205 return ksft_exit_fail();
204 206
205 if (check_timer_create(CLOCK_THREAD_CPUTIME_ID) < 0) 207 if (check_timer_create(CLOCK_THREAD_CPUTIME_ID) < 0)
206 return -1; 208 return ksft_exit_fail();
207 209
208 /* 210 /*
209 * It's unfortunately hard to reliably test a timer expiration 211 * It's unfortunately hard to reliably test a timer expiration
@@ -215,7 +217,7 @@ int main(int argc, char **argv)
215 * find a better solution. 217 * find a better solution.
216 */ 218 */
217 if (check_timer_create(CLOCK_PROCESS_CPUTIME_ID) < 0) 219 if (check_timer_create(CLOCK_PROCESS_CPUTIME_ID) < 0)
218 return -1; 220 return ksft_exit_fail();
219 221
220 return 0; 222 return ksft_exit_pass();
221} 223}
diff --git a/tools/testing/selftests/user/Makefile b/tools/testing/selftests/user/Makefile
index 396255bd720e..12c9d15bab07 100644
--- a/tools/testing/selftests/user/Makefile
+++ b/tools/testing/selftests/user/Makefile
@@ -4,10 +4,4 @@
4all: 4all:
5 5
6run_tests: all 6run_tests: all
7 @if /sbin/modprobe test_user_copy ; then \ 7 ./test_user_copy.sh
8 rmmod test_user_copy; \
9 echo "user_copy: ok"; \
10 else \
11 echo "user_copy: [FAIL]"; \
12 exit 1; \
13 fi
diff --git a/tools/testing/selftests/user/test_user_copy.sh b/tools/testing/selftests/user/test_user_copy.sh
new file mode 100755
index 000000000000..350107f40c1d
--- /dev/null
+++ b/tools/testing/selftests/user/test_user_copy.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2# Runs copy_to/from_user infrastructure using test_user_copy kernel module
3
4if /sbin/modprobe -q test_user_copy; then
5 /sbin/modprobe -q -r test_user_copy
6 echo "user_copy: ok"
7else
8 echo "user_copy: [FAIL]"
9 exit 1
10fi