diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 23:58:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 23:58:09 -0500 |
commit | 2a7d2b96d5cba7568139d9ab157a0e97ab32440f (patch) | |
tree | ad029d8cc7b7068b7250e914360ec6315fdfa114 /tools | |
parent | e3c4877de8b9d93bd47b6ee88eb594b1c1e10da5 (diff) | |
parent | b67bfe0d42cac56c512dd5da4b1b347a23f4b70a (diff) |
Merge branch 'akpm' (final batch from Andrew)
Merge third patch-bumb from Andrew Morton:
"This wraps me up for -rc1.
- Lots of misc stuff and things which were deferred/missed from
patchbombings 1 & 2.
- ocfs2 things
- lib/scatterlist
- hfsplus
- fatfs
- documentation
- signals
- procfs
- lockdep
- coredump
- seqfile core
- kexec
- Tejun's large IDR tree reworkings
- ipmi
- partitions
- nbd
- random() things
- kfifo
- tools/testing/selftests updates
- Sasha's large and pointless hlist cleanup"
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (163 commits)
hlist: drop the node parameter from iterators
kcmp: make it depend on CHECKPOINT_RESTORE
selftests: add a simple doc
tools/testing/selftests/Makefile: rearrange targets
selftests/efivarfs: add create-read test
selftests/efivarfs: add empty file creation test
selftests: add tests for efivarfs
kfifo: fix kfifo_alloc() and kfifo_init()
kfifo: move kfifo.c from kernel/ to lib/
arch Kconfig: centralise CONFIG_ARCH_NO_VIRT_TO_BUS
w1: add support for DS2413 Dual Channel Addressable Switch
memstick: move the dereference below the NULL test
drivers/pps/clients/pps-gpio.c: use devm_kzalloc
Documentation/DMA-API-HOWTO.txt: fix typo
include/linux/eventfd.h: fix incorrect filename is a comment
mtd: mtd_stresstest: use prandom_bytes()
mtd: mtd_subpagetest: convert to use prandom library
mtd: mtd_speedtest: use prandom_bytes
mtd: mtd_pagetest: convert to use prandom library
mtd: mtd_oobtest: convert to use prandom library
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/evlist.c | 3 | ||||
-rw-r--r-- | tools/testing/selftests/Makefile | 8 | ||||
-rw-r--r-- | tools/testing/selftests/README.txt | 42 | ||||
-rw-r--r-- | tools/testing/selftests/efivarfs/Makefile | 12 | ||||
-rw-r--r-- | tools/testing/selftests/efivarfs/create-read.c | 38 | ||||
-rw-r--r-- | tools/testing/selftests/efivarfs/efivarfs.sh | 139 | ||||
-rw-r--r-- | tools/testing/selftests/efivarfs/open-unlink.c | 63 |
7 files changed, 302 insertions, 3 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index bc4ad7977438..c8be0fbc5145 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -314,7 +314,6 @@ static int perf_evlist__id_add_fd(struct perf_evlist *evlist, | |||
314 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) | 314 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) |
315 | { | 315 | { |
316 | struct hlist_head *head; | 316 | struct hlist_head *head; |
317 | struct hlist_node *pos; | ||
318 | struct perf_sample_id *sid; | 317 | struct perf_sample_id *sid; |
319 | int hash; | 318 | int hash; |
320 | 319 | ||
@@ -324,7 +323,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) | |||
324 | hash = hash_64(id, PERF_EVLIST__HLIST_BITS); | 323 | hash = hash_64(id, PERF_EVLIST__HLIST_BITS); |
325 | head = &evlist->heads[hash]; | 324 | head = &evlist->heads[hash]; |
326 | 325 | ||
327 | hlist_for_each_entry(sid, pos, head, node) | 326 | hlist_for_each_entry(sid, head, node) |
328 | if (sid->id == id) | 327 | if (sid->id == id) |
329 | return sid->evsel; | 328 | return sid->evsel; |
330 | 329 | ||
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 85baf11e2acd..3cc0ad7ae863 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -1,4 +1,10 @@ | |||
1 | TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug | 1 | TARGETS = breakpoints |
2 | TARGETS += kcmp | ||
3 | TARGETS += mqueue | ||
4 | TARGETS += vm | ||
5 | TARGETS += cpu-hotplug | ||
6 | TARGETS += memory-hotplug | ||
7 | TARGETS += efivarfs | ||
2 | 8 | ||
3 | all: | 9 | all: |
4 | for TARGET in $(TARGETS); do \ | 10 | for TARGET in $(TARGETS); do \ |
diff --git a/tools/testing/selftests/README.txt b/tools/testing/selftests/README.txt new file mode 100644 index 000000000000..5e2faf9c55d3 --- /dev/null +++ b/tools/testing/selftests/README.txt | |||
@@ -0,0 +1,42 @@ | |||
1 | Linux Kernel Selftests | ||
2 | |||
3 | The kernel contains a set of "self tests" under the tools/testing/selftests/ | ||
4 | directory. These are intended to be small unit tests to exercise individual | ||
5 | code paths in the kernel. | ||
6 | |||
7 | Running the selftests | ||
8 | ===================== | ||
9 | |||
10 | To build the tests: | ||
11 | |||
12 | $ make -C tools/testing/selftests | ||
13 | |||
14 | |||
15 | To run the tests: | ||
16 | |||
17 | $ make -C tools/testing/selftests run_tests | ||
18 | |||
19 | - note that some tests will require root privileges. | ||
20 | |||
21 | |||
22 | To run only tests targetted for a single subsystem: | ||
23 | |||
24 | $ make -C tools/testing/selftests TARGETS=cpu-hotplug run_tests | ||
25 | |||
26 | See the top-level tools/testing/selftests/Makefile for the list of all possible | ||
27 | targets. | ||
28 | |||
29 | |||
30 | Contributing new tests | ||
31 | ====================== | ||
32 | |||
33 | In general, the rules for for selftests are | ||
34 | |||
35 | * Do as much as you can if you're not root; | ||
36 | |||
37 | * Don't take too long; | ||
38 | |||
39 | * Don't break the build on any architecture, and | ||
40 | |||
41 | * Don't cause the top-level "make run_tests" to fail if your feature is | ||
42 | unconfigured. | ||
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile new file mode 100644 index 000000000000..29e8c6bc81b0 --- /dev/null +++ b/tools/testing/selftests/efivarfs/Makefile | |||
@@ -0,0 +1,12 @@ | |||
1 | CC = $(CROSS_COMPILE)gcc | ||
2 | CFLAGS = -Wall | ||
3 | |||
4 | test_objs = open-unlink create-read | ||
5 | |||
6 | all: $(test_objs) | ||
7 | |||
8 | run_tests: all | ||
9 | @/bin/bash ./efivarfs.sh || echo "efivarfs selftests: [FAIL]" | ||
10 | |||
11 | clean: | ||
12 | rm -f $(test_objs) | ||
diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c new file mode 100644 index 000000000000..7feef1880968 --- /dev/null +++ b/tools/testing/selftests/efivarfs/create-read.c | |||
@@ -0,0 +1,38 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdint.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <unistd.h> | ||
5 | #include <sys/types.h> | ||
6 | #include <sys/stat.h> | ||
7 | #include <fcntl.h> | ||
8 | #include <errno.h> | ||
9 | #include <string.h> | ||
10 | |||
11 | int main(int argc, char **argv) | ||
12 | { | ||
13 | const char *path; | ||
14 | char buf[4]; | ||
15 | int fd, rc; | ||
16 | |||
17 | if (argc < 2) { | ||
18 | fprintf(stderr, "usage: %s <path>\n", argv[0]); | ||
19 | return EXIT_FAILURE; | ||
20 | } | ||
21 | |||
22 | path = argv[1]; | ||
23 | |||
24 | /* create a test variable */ | ||
25 | fd = open(path, O_RDWR | O_CREAT, 0600); | ||
26 | if (fd < 0) { | ||
27 | perror("open(O_WRONLY)"); | ||
28 | return EXIT_FAILURE; | ||
29 | } | ||
30 | |||
31 | rc = read(fd, buf, sizeof(buf)); | ||
32 | if (rc != 0) { | ||
33 | fprintf(stderr, "Reading a new var should return EOF\n"); | ||
34 | return EXIT_FAILURE; | ||
35 | } | ||
36 | |||
37 | return EXIT_SUCCESS; | ||
38 | } | ||
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh new file mode 100644 index 000000000000..880cdd5dc63f --- /dev/null +++ b/tools/testing/selftests/efivarfs/efivarfs.sh | |||
@@ -0,0 +1,139 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | efivarfs_mount=/sys/firmware/efi/efivars | ||
4 | test_guid=210be57c-9849-4fc7-a635-e6382d1aec27 | ||
5 | |||
6 | check_prereqs() | ||
7 | { | ||
8 | local msg="skip all tests:" | ||
9 | |||
10 | if [ $UID != 0 ]; then | ||
11 | echo $msg must be run as root >&2 | ||
12 | exit 0 | ||
13 | fi | ||
14 | |||
15 | if ! grep -q "^\S\+ $efivarfs_mount efivarfs" /proc/mounts; then | ||
16 | echo $msg efivarfs is not mounted on $efivarfs_mount >&2 | ||
17 | exit 0 | ||
18 | fi | ||
19 | } | ||
20 | |||
21 | run_test() | ||
22 | { | ||
23 | local test="$1" | ||
24 | |||
25 | echo "--------------------" | ||
26 | echo "running $test" | ||
27 | echo "--------------------" | ||
28 | |||
29 | if [ "$(type -t $test)" = 'function' ]; then | ||
30 | ( $test ) | ||
31 | else | ||
32 | ( ./$test ) | ||
33 | fi | ||
34 | |||
35 | if [ $? -ne 0 ]; then | ||
36 | echo " [FAIL]" | ||
37 | rc=1 | ||
38 | else | ||
39 | echo " [PASS]" | ||
40 | fi | ||
41 | } | ||
42 | |||
43 | test_create() | ||
44 | { | ||
45 | local attrs='\x07\x00\x00\x00' | ||
46 | local file=$efivarfs_mount/$FUNCNAME-$test_guid | ||
47 | |||
48 | printf "$attrs\x00" > $file | ||
49 | |||
50 | if [ ! -e $file ]; then | ||
51 | echo "$file couldn't be created" >&2 | ||
52 | exit 1 | ||
53 | fi | ||
54 | |||
55 | if [ $(stat -c %s $file) -ne 5 ]; then | ||
56 | echo "$file has invalid size" >&2 | ||
57 | exit 1 | ||
58 | fi | ||
59 | } | ||
60 | |||
61 | test_create_empty() | ||
62 | { | ||
63 | local file=$efivarfs_mount/$FUNCNAME-$test_guid | ||
64 | |||
65 | : > $file | ||
66 | |||
67 | if [ ! -e $file ]; then | ||
68 | echo "$file can not be created without writing" >&2 | ||
69 | exit 1 | ||
70 | fi | ||
71 | } | ||
72 | |||
73 | test_create_read() | ||
74 | { | ||
75 | local file=$efivarfs_mount/$FUNCNAME-$test_guid | ||
76 | ./create-read $file | ||
77 | } | ||
78 | |||
79 | test_delete() | ||
80 | { | ||
81 | local attrs='\x07\x00\x00\x00' | ||
82 | local file=$efivarfs_mount/$FUNCNAME-$test_guid | ||
83 | |||
84 | printf "$attrs\x00" > $file | ||
85 | |||
86 | if [ ! -e $file ]; then | ||
87 | echo "$file couldn't be created" >&2 | ||
88 | exit 1 | ||
89 | fi | ||
90 | |||
91 | rm $file | ||
92 | |||
93 | if [ -e $file ]; then | ||
94 | echo "$file couldn't be deleted" >&2 | ||
95 | exit 1 | ||
96 | fi | ||
97 | |||
98 | } | ||
99 | |||
100 | # test that we can remove a variable by issuing a write with only | ||
101 | # attributes specified | ||
102 | test_zero_size_delete() | ||
103 | { | ||
104 | local attrs='\x07\x00\x00\x00' | ||
105 | local file=$efivarfs_mount/$FUNCNAME-$test_guid | ||
106 | |||
107 | printf "$attrs\x00" > $file | ||
108 | |||
109 | if [ ! -e $file ]; then | ||
110 | echo "$file does not exist" >&2 | ||
111 | exit 1 | ||
112 | fi | ||
113 | |||
114 | printf "$attrs" > $file | ||
115 | |||
116 | if [ -e $file ]; then | ||
117 | echo "$file should have been deleted" >&2 | ||
118 | exit 1 | ||
119 | fi | ||
120 | } | ||
121 | |||
122 | test_open_unlink() | ||
123 | { | ||
124 | local file=$efivarfs_mount/$FUNCNAME-$test_guid | ||
125 | ./open-unlink $file | ||
126 | } | ||
127 | |||
128 | check_prereqs | ||
129 | |||
130 | rc=0 | ||
131 | |||
132 | run_test test_create | ||
133 | run_test test_create_empty | ||
134 | run_test test_create_read | ||
135 | run_test test_delete | ||
136 | run_test test_zero_size_delete | ||
137 | run_test test_open_unlink | ||
138 | |||
139 | exit $rc | ||
diff --git a/tools/testing/selftests/efivarfs/open-unlink.c b/tools/testing/selftests/efivarfs/open-unlink.c new file mode 100644 index 000000000000..8c0764407b3c --- /dev/null +++ b/tools/testing/selftests/efivarfs/open-unlink.c | |||
@@ -0,0 +1,63 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdint.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <unistd.h> | ||
5 | #include <sys/types.h> | ||
6 | #include <sys/stat.h> | ||
7 | #include <fcntl.h> | ||
8 | |||
9 | int main(int argc, char **argv) | ||
10 | { | ||
11 | const char *path; | ||
12 | char buf[5]; | ||
13 | int fd, rc; | ||
14 | |||
15 | if (argc < 2) { | ||
16 | fprintf(stderr, "usage: %s <path>\n", argv[0]); | ||
17 | return EXIT_FAILURE; | ||
18 | } | ||
19 | |||
20 | path = argv[1]; | ||
21 | |||
22 | /* attributes: EFI_VARIABLE_NON_VOLATILE | | ||
23 | * EFI_VARIABLE_BOOTSERVICE_ACCESS | | ||
24 | * EFI_VARIABLE_RUNTIME_ACCESS | ||
25 | */ | ||
26 | *(uint32_t *)buf = 0x7; | ||
27 | buf[4] = 0; | ||
28 | |||
29 | /* create a test variable */ | ||
30 | fd = open(path, O_WRONLY | O_CREAT); | ||
31 | if (fd < 0) { | ||
32 | perror("open(O_WRONLY)"); | ||
33 | return EXIT_FAILURE; | ||
34 | } | ||
35 | |||
36 | rc = write(fd, buf, sizeof(buf)); | ||
37 | if (rc != sizeof(buf)) { | ||
38 | perror("write"); | ||
39 | return EXIT_FAILURE; | ||
40 | } | ||
41 | |||
42 | close(fd); | ||
43 | |||
44 | fd = open(path, O_RDONLY); | ||
45 | if (fd < 0) { | ||
46 | perror("open"); | ||
47 | return EXIT_FAILURE; | ||
48 | } | ||
49 | |||
50 | if (unlink(path) < 0) { | ||
51 | perror("unlink"); | ||
52 | return EXIT_FAILURE; | ||
53 | } | ||
54 | |||
55 | rc = read(fd, buf, sizeof(buf)); | ||
56 | if (rc > 0) { | ||
57 | fprintf(stderr, "reading from an unlinked variable " | ||
58 | "shouldn't be possible\n"); | ||
59 | return EXIT_FAILURE; | ||
60 | } | ||
61 | |||
62 | return EXIT_SUCCESS; | ||
63 | } | ||