mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-25 02:48:21 +00:00
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>
This commit is contained in:
parent
835b94e05c
commit
9cd6565558
@ -25,6 +25,7 @@ TARGETS += mqueue
|
||||
TARGETS += net
|
||||
TARGETS += nsfs
|
||||
TARGETS += powerpc
|
||||
TARGETS += proc
|
||||
TARGETS += pstore
|
||||
TARGETS += ptrace
|
||||
TARGETS += seccomp
|
||||
|
1
tools/testing/selftests/proc/.gitignore
vendored
Normal file
1
tools/testing/selftests/proc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/proc-self-wchan
|
6
tools/testing/selftests/proc/Makefile
Normal file
6
tools/testing/selftests/proc/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
CFLAGS += -Wall -O2
|
||||
|
||||
TEST_GEN_PROGS :=
|
||||
TEST_GEN_PROGS += proc-self-wchan
|
||||
|
||||
include ../lib.mk
|
1
tools/testing/selftests/proc/config
Normal file
1
tools/testing/selftests/proc/config
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_PROC_FS=y
|
25
tools/testing/selftests/proc/proc-self-wchan.c
Normal file
25
tools/testing/selftests/proc/proc-self-wchan.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char buf[64];
|
||||
int fd;
|
||||
|
||||
fd = open("/proc/self/wchan", O_RDONLY);
|
||||
if (fd == -1) {
|
||||
if (errno == ENOENT)
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf[0] = '\0';
|
||||
if (read(fd, buf, sizeof(buf)) != 1)
|
||||
return 1;
|
||||
if (buf[0] != '0')
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user