Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
9cd65655 835b94e0

+34
+1
tools/testing/selftests/Makefile
··· 25 25 TARGETS += net 26 26 TARGETS += nsfs 27 27 TARGETS += powerpc 28 + TARGETS += proc 28 29 TARGETS += pstore 29 30 TARGETS += ptrace 30 31 TARGETS += seccomp
+1
tools/testing/selftests/proc/.gitignore
··· 1 + /proc-self-wchan
+6
tools/testing/selftests/proc/Makefile
··· 1 + CFLAGS += -Wall -O2 2 + 3 + TEST_GEN_PROGS := 4 + TEST_GEN_PROGS += proc-self-wchan 5 + 6 + include ../lib.mk
+1
tools/testing/selftests/proc/config
··· 1 + CONFIG_PROC_FS=y
+25
tools/testing/selftests/proc/proc-self-wchan.c
··· 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 + }