Skip to content

Commit 9cd6565

Browse files
Alexey Dobriyantorvalds
authored andcommitted
proc: test /proc/self/wchan
This patch starts testing /proc. Many more tests to come (I promise). Read from /proc/self/wchan should always return "0" as current is in TASK_RUNNING state while reading /proc/self/wchan. Link: http://lkml.kernel.org/r/20180226212006.GA742@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 835b94e commit 9cd6565

5 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎tools/testing/selftests/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ TARGETS += mqueue
2525
TARGETS += net
2626
TARGETS += nsfs
2727
TARGETS += powerpc
28+
TARGETS += proc
2829
TARGETS += pstore
2930
TARGETS += ptrace
3031
TARGETS += seccomp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/proc-self-wchan
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CFLAGS += -Wall -O2
2+
3+
TEST_GEN_PROGS :=
4+
TEST_GEN_PROGS += proc-self-wchan
5+
6+
include ../lib.mk
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_PROC_FS=y
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <sys/types.h>
2+
#include <sys/stat.h>
3+
#include <fcntl.h>
4+
#include <errno.h>
5+
#include <unistd.h>
6+
7+
int main(void)
8+
{
9+
char buf[64];
10+
int fd;
11+
12+
fd = open("/proc/self/wchan", O_RDONLY);
13+
if (fd == -1) {
14+
if (errno == ENOENT)
15+
return 2;
16+
return 1;
17+
}
18+
19+
buf[0] = '\0';
20+
if (read(fd, buf, sizeof(buf)) != 1)
21+
return 1;
22+
if (buf[0] != '0')
23+
return 1;
24+
return 0;
25+
}

0 commit comments

Comments
 (0)