aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing')
-rwxr-xr-xtools/testing/ktest/ktest.pl2
-rw-r--r--tools/testing/selftests/Makefile1
-rw-r--r--tools/testing/selftests/cpu-hotplug/Makefile2
-rw-r--r--tools/testing/selftests/kcmp/.gitignore2
-rw-r--r--tools/testing/selftests/kcmp/Makefile3
-rw-r--r--tools/testing/selftests/memory-hotplug/Makefile2
-rw-r--r--tools/testing/selftests/net/psock_tpacket.c59
-rw-r--r--tools/testing/selftests/timers/Makefile8
-rw-r--r--tools/testing/selftests/timers/posix_timers.c221
-rw-r--r--tools/testing/selftests/vm/.gitignore4
-rw-r--r--tools/testing/selftests/vm/Makefile7
-rw-r--r--tools/testing/selftests/vm/hugetlbfstest.c84
-rw-r--r--tools/testing/selftests/vm/run_vmtests16
13 files changed, 364 insertions, 47 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 0d7fd8b51544..999eab1bc64f 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1796,7 +1796,7 @@ sub monitor {
1796 # We already booted into the kernel we are testing, 1796 # We already booted into the kernel we are testing,
1797 # but now we booted into another kernel? 1797 # but now we booted into another kernel?
1798 # Consider this a triple fault. 1798 # Consider this a triple fault.
1799 doprint "Aleady booted in Linux kernel $version, but now\n"; 1799 doprint "Already booted in Linux kernel $version, but now\n";
1800 doprint "we booted into Linux kernel $1.\n"; 1800 doprint "we booted into Linux kernel $1.\n";
1801 doprint "Assuming that this is a triple fault.\n"; 1801 doprint "Assuming that this is a triple fault.\n";
1802 doprint "To disable this: set DETECT_TRIPLE_FAULT to 0\n"; 1802 doprint "To disable this: set DETECT_TRIPLE_FAULT to 0\n";
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 0a63658065f0..4cb14cae3791 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -6,6 +6,7 @@ TARGETS += memory-hotplug
6TARGETS += mqueue 6TARGETS += mqueue
7TARGETS += net 7TARGETS += net
8TARGETS += ptrace 8TARGETS += ptrace
9TARGETS += timers
9TARGETS += vm 10TARGETS += vm
10 11
11all: 12all:
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
index 12657a5e4bf9..ae5faf9aade2 100644
--- a/tools/testing/selftests/cpu-hotplug/Makefile
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -1,6 +1,6 @@
1all: 1all:
2 2
3run_tests: 3run_tests:
4 @./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]" 4 @/bin/sh ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]"
5 5
6clean: 6clean:
diff --git a/tools/testing/selftests/kcmp/.gitignore b/tools/testing/selftests/kcmp/.gitignore
new file mode 100644
index 000000000000..5a9b3732b2de
--- /dev/null
+++ b/tools/testing/selftests/kcmp/.gitignore
@@ -0,0 +1,2 @@
1kcmp_test
2kcmp-test-file
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 56eb5523dbb8..d7d6bbeeff2f 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -25,5 +25,4 @@ run_tests: all
25 @./kcmp_test || echo "kcmp_test: [FAIL]" 25 @./kcmp_test || echo "kcmp_test: [FAIL]"
26 26
27clean: 27clean:
28 rm -fr ./run_test 28 $(RM) kcmp_test kcmp-test-file
29 rm -fr ./test-file
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index 0f49c3f5f58d..350bfeda3aa8 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -1,6 +1,6 @@
1all: 1all:
2 2
3run_tests: 3run_tests:
4 @./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]" 4 @/bin/sh ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
5 5
6clean: 6clean:
diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
index c41b58640a05..24adf709bd9d 100644
--- a/tools/testing/selftests/net/psock_tpacket.c
+++ b/tools/testing/selftests/net/psock_tpacket.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright 2013 Red Hat, Inc. 2 * Copyright 2013 Red Hat, Inc.
3 * Author: Daniel Borkmann <dborkman@redhat.com> 3 * Author: Daniel Borkmann <dborkman@redhat.com>
4 * Chetan Loke <loke.chetan@gmail.com> (TPACKET_V3 usage example)
4 * 5 *
5 * A basic test of packet socket's TPACKET_V1/TPACKET_V2/TPACKET_V3 behavior. 6 * A basic test of packet socket's TPACKET_V1/TPACKET_V2/TPACKET_V3 behavior.
6 * 7 *
@@ -71,18 +72,8 @@
71# define __align_tpacket(x) __attribute__((aligned(TPACKET_ALIGN(x)))) 72# define __align_tpacket(x) __attribute__((aligned(TPACKET_ALIGN(x))))
72#endif 73#endif
73 74
74#define BLOCK_STATUS(x) ((x)->h1.block_status)
75#define BLOCK_NUM_PKTS(x) ((x)->h1.num_pkts)
76#define BLOCK_O2FP(x) ((x)->h1.offset_to_first_pkt)
77#define BLOCK_LEN(x) ((x)->h1.blk_len)
78#define BLOCK_SNUM(x) ((x)->h1.seq_num)
79#define BLOCK_O2PRIV(x) ((x)->offset_to_priv)
80#define BLOCK_PRIV(x) ((void *) ((uint8_t *) (x) + BLOCK_O2PRIV(x)))
81#define BLOCK_HDR_LEN (ALIGN_8(sizeof(struct block_desc)))
82#define ALIGN_8(x) (((x) + 8 - 1) & ~(8 - 1))
83#define BLOCK_PLUS_PRIV(sz_pri) (BLOCK_HDR_LEN + ALIGN_8((sz_pri)))
84
85#define NUM_PACKETS 100 75#define NUM_PACKETS 100
76#define ALIGN_8(x) (((x) + 8 - 1) & ~(8 - 1))
86 77
87struct ring { 78struct ring {
88 struct iovec *rd; 79 struct iovec *rd;
@@ -476,41 +467,30 @@ static uint64_t __v3_prev_block_seq_num = 0;
476 467
477void __v3_test_block_seq_num(struct block_desc *pbd) 468void __v3_test_block_seq_num(struct block_desc *pbd)
478{ 469{
479 if (__v3_prev_block_seq_num + 1 != BLOCK_SNUM(pbd)) { 470 if (__v3_prev_block_seq_num + 1 != pbd->h1.seq_num) {
480 fprintf(stderr, "\nprev_block_seq_num:%"PRIu64", expected " 471 fprintf(stderr, "\nprev_block_seq_num:%"PRIu64", expected "
481 "seq:%"PRIu64" != actual seq:%"PRIu64"\n", 472 "seq:%"PRIu64" != actual seq:%"PRIu64"\n",
482 __v3_prev_block_seq_num, __v3_prev_block_seq_num + 1, 473 __v3_prev_block_seq_num, __v3_prev_block_seq_num + 1,
483 (uint64_t) BLOCK_SNUM(pbd)); 474 (uint64_t) pbd->h1.seq_num);
484 exit(1); 475 exit(1);
485 } 476 }
486 477
487 __v3_prev_block_seq_num = BLOCK_SNUM(pbd); 478 __v3_prev_block_seq_num = pbd->h1.seq_num;
488} 479}
489 480
490static void __v3_test_block_len(struct block_desc *pbd, uint32_t bytes, int block_num) 481static void __v3_test_block_len(struct block_desc *pbd, uint32_t bytes, int block_num)
491{ 482{
492 if (BLOCK_NUM_PKTS(pbd)) { 483 if (pbd->h1.num_pkts && bytes != pbd->h1.blk_len) {
493 if (bytes != BLOCK_LEN(pbd)) { 484 fprintf(stderr, "\nblock:%u with %upackets, expected "
494 fprintf(stderr, "\nblock:%u with %upackets, expected " 485 "len:%u != actual len:%u\n", block_num,
495 "len:%u != actual len:%u\n", block_num, 486 pbd->h1.num_pkts, bytes, pbd->h1.blk_len);
496 BLOCK_NUM_PKTS(pbd), bytes, BLOCK_LEN(pbd)); 487 exit(1);
497 exit(1);
498 }
499 } else {
500 if (BLOCK_LEN(pbd) != BLOCK_PLUS_PRIV(13)) {
501 fprintf(stderr, "\nblock:%u, expected len:%lu != "
502 "actual len:%u\n", block_num, BLOCK_HDR_LEN,
503 BLOCK_LEN(pbd));
504 exit(1);
505 }
506 } 488 }
507} 489}
508 490
509static void __v3_test_block_header(struct block_desc *pbd, const int block_num) 491static void __v3_test_block_header(struct block_desc *pbd, const int block_num)
510{ 492{
511 uint32_t block_status = BLOCK_STATUS(pbd); 493 if ((pbd->h1.block_status & TP_STATUS_USER) == 0) {
512
513 if ((block_status & TP_STATUS_USER) == 0) {
514 fprintf(stderr, "\nblock %u: not in TP_STATUS_USER\n", block_num); 494 fprintf(stderr, "\nblock %u: not in TP_STATUS_USER\n", block_num);
515 exit(1); 495 exit(1);
516 } 496 }
@@ -520,14 +500,15 @@ static void __v3_test_block_header(struct block_desc *pbd, const int block_num)
520 500
521static void __v3_walk_block(struct block_desc *pbd, const int block_num) 501static void __v3_walk_block(struct block_desc *pbd, const int block_num)
522{ 502{
523 int num_pkts = BLOCK_NUM_PKTS(pbd), i; 503 int num_pkts = pbd->h1.num_pkts, i;
524 unsigned long bytes = 0; 504 unsigned long bytes = 0, bytes_with_padding = ALIGN_8(sizeof(*pbd));
525 unsigned long bytes_with_padding = BLOCK_PLUS_PRIV(13);
526 struct tpacket3_hdr *ppd; 505 struct tpacket3_hdr *ppd;
527 506
528 __v3_test_block_header(pbd, block_num); 507 __v3_test_block_header(pbd, block_num);
529 508
530 ppd = (struct tpacket3_hdr *) ((uint8_t *) pbd + BLOCK_O2FP(pbd)); 509 ppd = (struct tpacket3_hdr *) ((uint8_t *) pbd +
510 pbd->h1.offset_to_first_pkt);
511
531 for (i = 0; i < num_pkts; ++i) { 512 for (i = 0; i < num_pkts; ++i) {
532 bytes += ppd->tp_snaplen; 513 bytes += ppd->tp_snaplen;
533 514
@@ -551,7 +532,7 @@ static void __v3_walk_block(struct block_desc *pbd, const int block_num)
551 532
552void __v3_flush_block(struct block_desc *pbd) 533void __v3_flush_block(struct block_desc *pbd)
553{ 534{
554 BLOCK_STATUS(pbd) = TP_STATUS_KERNEL; 535 pbd->h1.block_status = TP_STATUS_KERNEL;
555 __sync_synchronize(); 536 __sync_synchronize();
556} 537}
557 538
@@ -577,7 +558,7 @@ static void walk_v3_rx(int sock, struct ring *ring)
577 while (total_packets < NUM_PACKETS * 2) { 558 while (total_packets < NUM_PACKETS * 2) {
578 pbd = (struct block_desc *) ring->rd[block_num].iov_base; 559 pbd = (struct block_desc *) ring->rd[block_num].iov_base;
579 560
580 while ((BLOCK_STATUS(pbd) & TP_STATUS_USER) == 0) 561 while ((pbd->h1.block_status & TP_STATUS_USER) == 0)
581 poll(&pfd, 1, 1); 562 poll(&pfd, 1, 1);
582 563
583 __v3_walk_block(pbd, block_num); 564 __v3_walk_block(pbd, block_num);
@@ -624,8 +605,8 @@ static void __v1_v2_fill(struct ring *ring, unsigned int blocks)
624static void __v3_fill(struct ring *ring, unsigned int blocks) 605static void __v3_fill(struct ring *ring, unsigned int blocks)
625{ 606{
626 ring->req3.tp_retire_blk_tov = 64; 607 ring->req3.tp_retire_blk_tov = 64;
627 ring->req3.tp_sizeof_priv = 13; 608 ring->req3.tp_sizeof_priv = 0;
628 ring->req3.tp_feature_req_word |= TP_FT_REQ_FILL_RXHASH; 609 ring->req3.tp_feature_req_word = TP_FT_REQ_FILL_RXHASH;
629 610
630 ring->req3.tp_block_size = getpagesize() << 2; 611 ring->req3.tp_block_size = getpagesize() << 2;
631 ring->req3.tp_frame_size = TPACKET_ALIGNMENT << 7; 612 ring->req3.tp_frame_size = TPACKET_ALIGNMENT << 7;
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
new file mode 100644
index 000000000000..eb2859f4ad21
--- /dev/null
+++ b/tools/testing/selftests/timers/Makefile
@@ -0,0 +1,8 @@
1all:
2 gcc posix_timers.c -o posix_timers -lrt
3
4run_tests: all
5 ./posix_timers
6
7clean:
8 rm -f ./posix_timers
diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c
new file mode 100644
index 000000000000..4fa655d68a81
--- /dev/null
+++ b/tools/testing/selftests/timers/posix_timers.c
@@ -0,0 +1,221 @@
1/*
2 * Copyright (C) 2013 Red Hat, Inc., Frederic Weisbecker <fweisbec@redhat.com>
3 *
4 * Licensed under the terms of the GNU GPL License version 2
5 *
6 * Selftests for a few posix timers interface.
7 *
8 * Kernel loop code stolen from Steven Rostedt <srostedt@redhat.com>
9 */
10
11#include <sys/time.h>
12#include <stdio.h>
13#include <signal.h>
14#include <unistd.h>
15#include <time.h>
16#include <pthread.h>
17
18#define DELAY 2
19#define USECS_PER_SEC 1000000
20
21static volatile int done;
22
23/* Busy loop in userspace to elapse ITIMER_VIRTUAL */
24static void user_loop(void)
25{
26 while (!done);
27}
28
29/*
30 * Try to spend as much time as possible in kernelspace
31 * to elapse ITIMER_PROF.
32 */
33static void kernel_loop(void)
34{
35 void *addr = sbrk(0);
36
37 while (!done) {
38 brk(addr + 4096);
39 brk(addr);
40 }
41}
42
43/*
44 * Sleep until ITIMER_REAL expiration.
45 */
46static void idle_loop(void)
47{
48 pause();
49}
50
51static void sig_handler(int nr)
52{
53 done = 1;
54}
55
56/*
57 * Check the expected timer expiration matches the GTOD elapsed delta since
58 * we armed the timer. Keep a 0.5 sec error margin due to various jitter.
59 */
60static int check_diff(struct timeval start, struct timeval end)
61{
62 long long diff;
63
64 diff = end.tv_usec - start.tv_usec;
65 diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC;
66
67 if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
68 printf("Diff too high: %lld..", diff);
69 return -1;
70 }
71
72 return 0;
73}
74
75static int check_itimer(int which)
76{
77 int err;
78 struct timeval start, end;
79 struct itimerval val = {
80 .it_value.tv_sec = DELAY,
81 };
82
83 printf("Check itimer ");
84
85 if (which == ITIMER_VIRTUAL)
86 printf("virtual... ");
87 else if (which == ITIMER_PROF)
88 printf("prof... ");
89 else if (which == ITIMER_REAL)
90 printf("real... ");
91
92 fflush(stdout);
93
94 done = 0;
95
96 if (which == ITIMER_VIRTUAL)
97 signal(SIGVTALRM, sig_handler);
98 else if (which == ITIMER_PROF)
99 signal(SIGPROF, sig_handler);
100 else if (which == ITIMER_REAL)
101 signal(SIGALRM, sig_handler);
102
103 err = gettimeofday(&start, NULL);
104 if (err < 0) {
105 perror("Can't call gettimeofday()\n");
106 return -1;
107 }
108
109 err = setitimer(which, &val, NULL);
110 if (err < 0) {
111 perror("Can't set timer\n");
112 return -1;
113 }
114
115 if (which == ITIMER_VIRTUAL)
116 user_loop();
117 else if (which == ITIMER_PROF)
118 kernel_loop();
119 else if (which == ITIMER_REAL)
120 idle_loop();
121
122 gettimeofday(&end, NULL);
123 if (err < 0) {
124 perror("Can't call gettimeofday()\n");
125 return -1;
126 }
127
128 if (!check_diff(start, end))
129 printf("[OK]\n");
130 else
131 printf("[FAIL]\n");
132
133 return 0;
134}
135
136static int check_timer_create(int which)
137{
138 int err;
139 timer_t id;
140 struct timeval start, end;
141 struct itimerspec val = {
142 .it_value.tv_sec = DELAY,
143 };
144
145 printf("Check timer_create() ");
146 if (which == CLOCK_THREAD_CPUTIME_ID) {
147 printf("per thread... ");
148 } else if (which == CLOCK_PROCESS_CPUTIME_ID) {
149 printf("per process... ");
150 }
151 fflush(stdout);
152
153 done = 0;
154 timer_create(which, NULL, &id);
155 if (err < 0) {
156 perror("Can't create timer\n");
157 return -1;
158 }
159 signal(SIGALRM, sig_handler);
160
161 err = gettimeofday(&start, NULL);
162 if (err < 0) {
163 perror("Can't call gettimeofday()\n");
164 return -1;
165 }
166
167 err = timer_settime(id, 0, &val, NULL);
168 if (err < 0) {
169 perror("Can't set timer\n");
170 return -1;
171 }
172
173 user_loop();
174
175 gettimeofday(&end, NULL);
176 if (err < 0) {
177 perror("Can't call gettimeofday()\n");
178 return -1;
179 }
180
181 if (!check_diff(start, end))
182 printf("[OK]\n");
183 else
184 printf("[FAIL]\n");
185
186 return 0;
187}
188
189int main(int argc, char **argv)
190{
191 int err;
192
193 printf("Testing posix timers. False negative may happen on CPU execution \n");
194 printf("based timers if other threads run on the CPU...\n");
195
196 if (check_itimer(ITIMER_VIRTUAL) < 0)
197 return -1;
198
199 if (check_itimer(ITIMER_PROF) < 0)
200 return -1;
201
202 if (check_itimer(ITIMER_REAL) < 0)
203 return -1;
204
205 if (check_timer_create(CLOCK_THREAD_CPUTIME_ID) < 0)
206 return -1;
207
208 /*
209 * It's unfortunately hard to reliably test a timer expiration
210 * on parallel multithread cputime. We could arm it to expire
211 * on DELAY * nr_threads, with nr_threads busy looping, then wait
212 * the normal DELAY since the time is elapsing nr_threads faster.
213 * But for that we need to ensure we have real physical free CPUs
214 * to ensure true parallelism. So test only one thread until we
215 * find a better solution.
216 */
217 if (check_timer_create(CLOCK_PROCESS_CPUTIME_ID) < 0)
218 return -1;
219
220 return 0;
221}
diff --git a/tools/testing/selftests/vm/.gitignore b/tools/testing/selftests/vm/.gitignore
new file mode 100644
index 000000000000..ff1bb16cec4f
--- /dev/null
+++ b/tools/testing/selftests/vm/.gitignore
@@ -0,0 +1,4 @@
1hugepage-mmap
2hugepage-shm
3map_hugetlb
4thuge-gen
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 436d2e81868b..3f94e1afd6cf 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -2,13 +2,14 @@
2 2
3CC = $(CROSS_COMPILE)gcc 3CC = $(CROSS_COMPILE)gcc
4CFLAGS = -Wall 4CFLAGS = -Wall
5BINARIES = hugepage-mmap hugepage-shm map_hugetlb thuge-gen hugetlbfstest
5 6
6all: hugepage-mmap hugepage-shm map_hugetlb thuge-gen 7all: $(BINARIES)
7%: %.c 8%: %.c
8 $(CC) $(CFLAGS) -o $@ $^ 9 $(CC) $(CFLAGS) -o $@ $^
9 10
10run_tests: all 11run_tests: all
11 @/bin/sh ./run_vmtests || echo "vmtests: [FAIL]" 12 @/bin/sh ./run_vmtests || (echo "vmtests: [FAIL]"; exit 1)
12 13
13clean: 14clean:
14 $(RM) hugepage-mmap hugepage-shm map_hugetlb 15 $(RM) $(BINARIES)
diff --git a/tools/testing/selftests/vm/hugetlbfstest.c b/tools/testing/selftests/vm/hugetlbfstest.c
new file mode 100644
index 000000000000..ea40ff8c2391
--- /dev/null
+++ b/tools/testing/selftests/vm/hugetlbfstest.c
@@ -0,0 +1,84 @@
1#define _GNU_SOURCE
2#include <assert.h>
3#include <fcntl.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <sys/mman.h>
8#include <sys/stat.h>
9#include <sys/types.h>
10#include <unistd.h>
11
12typedef unsigned long long u64;
13
14static size_t length = 1 << 24;
15
16static u64 read_rss(void)
17{
18 char buf[4096], *s = buf;
19 int i, fd;
20 u64 rss;
21
22 fd = open("/proc/self/statm", O_RDONLY);
23 assert(fd > 2);
24 memset(buf, 0, sizeof(buf));
25 read(fd, buf, sizeof(buf) - 1);
26 for (i = 0; i < 1; i++)
27 s = strchr(s, ' ') + 1;
28 rss = strtoull(s, NULL, 10);
29 return rss << 12; /* assumes 4k pagesize */
30}
31
32static void do_mmap(int fd, int extra_flags, int unmap)
33{
34 int *p;
35 int flags = MAP_PRIVATE | MAP_POPULATE | extra_flags;
36 u64 before, after;
37
38 before = read_rss();
39 p = mmap(NULL, length, PROT_READ | PROT_WRITE, flags, fd, 0);
40 assert(p != MAP_FAILED ||
41 !"mmap returned an unexpected error");
42 after = read_rss();
43 assert(llabs(after - before - length) < 0x40000 ||
44 !"rss didn't grow as expected");
45 if (!unmap)
46 return;
47 munmap(p, length);
48 after = read_rss();
49 assert(llabs(after - before) < 0x40000 ||
50 !"rss didn't shrink as expected");
51}
52
53static int open_file(const char *path)
54{
55 int fd, err;
56
57 unlink(path);
58 fd = open(path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL
59 | O_LARGEFILE | O_CLOEXEC, 0600);
60 assert(fd > 2);
61 unlink(path);
62 err = ftruncate(fd, length);
63 assert(!err);
64 return fd;
65}
66
67int main(void)
68{
69 int hugefd, fd;
70
71 fd = open_file("/dev/shm/hugetlbhog");
72 hugefd = open_file("/hugepages/hugetlbhog");
73
74 system("echo 100 > /proc/sys/vm/nr_hugepages");
75 do_mmap(-1, MAP_ANONYMOUS, 1);
76 do_mmap(fd, 0, 1);
77 do_mmap(-1, MAP_ANONYMOUS | MAP_HUGETLB, 1);
78 do_mmap(hugefd, 0, 1);
79 do_mmap(hugefd, MAP_HUGETLB, 1);
80 /* Leak the last one to test do_exit() */
81 do_mmap(-1, MAP_ANONYMOUS | MAP_HUGETLB, 0);
82 printf("oll korrekt.\n");
83 return 0;
84}
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
index 4c53cae6c273..c87b6812300d 100644
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -4,6 +4,7 @@
4#we need 256M, below is the size in kB 4#we need 256M, below is the size in kB
5needmem=262144 5needmem=262144
6mnt=./huge 6mnt=./huge
7exitcode=0
7 8
8#get pagesize and freepages from /proc/meminfo 9#get pagesize and freepages from /proc/meminfo
9while read name size unit; do 10while read name size unit; do
@@ -41,6 +42,7 @@ echo "--------------------"
41./hugepage-mmap 42./hugepage-mmap
42if [ $? -ne 0 ]; then 43if [ $? -ne 0 ]; then
43 echo "[FAIL]" 44 echo "[FAIL]"
45 exitcode=1
44else 46else
45 echo "[PASS]" 47 echo "[PASS]"
46fi 48fi
@@ -55,6 +57,7 @@ echo "--------------------"
55./hugepage-shm 57./hugepage-shm
56if [ $? -ne 0 ]; then 58if [ $? -ne 0 ]; then
57 echo "[FAIL]" 59 echo "[FAIL]"
60 exitcode=1
58else 61else
59 echo "[PASS]" 62 echo "[PASS]"
60fi 63fi
@@ -67,6 +70,18 @@ echo "--------------------"
67./map_hugetlb 70./map_hugetlb
68if [ $? -ne 0 ]; then 71if [ $? -ne 0 ]; then
69 echo "[FAIL]" 72 echo "[FAIL]"
73 exitcode=1
74else
75 echo "[PASS]"
76fi
77
78echo "--------------------"
79echo "running hugetlbfstest"
80echo "--------------------"
81./hugetlbfstest
82if [ $? -ne 0 ]; then
83 echo "[FAIL]"
84 exitcode=1
70else 85else
71 echo "[PASS]" 86 echo "[PASS]"
72fi 87fi
@@ -75,3 +90,4 @@ fi
75umount $mnt 90umount $mnt
76rm -rf $mnt 91rm -rf $mnt
77echo $nr_hugepgs > /proc/sys/vm/nr_hugepages 92echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
93exit $exitcode