9cd6565558
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>
26 lines
368 B
C
26 lines
368 B
C
#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;
|
|
}
|