All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] proc: test /proc/self/wchan
@ 2018-02-26 21:20 Alexey Dobriyan
  0 siblings, 0 replies; only message in thread
From: Alexey Dobriyan @ 2018-02-26 21:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

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.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 tools/testing/selftests/Makefile               |    1 +
 tools/testing/selftests/proc/.gitignore        |    1 +
 tools/testing/selftests/proc/Makefile          |    6 ++++++
 tools/testing/selftests/proc/config            |    1 +
 tools/testing/selftests/proc/proc-self-wchan.c |   25 +++++++++++++++++++++++++
 6 files changed, 35 insertions(+)

--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -23,6 +23,7 @@ TARGETS += mqueue
 TARGETS += net
 TARGETS += nsfs
 TARGETS += powerpc
+TARGETS += proc
 TARGETS += pstore
 TARGETS += ptrace
 TARGETS += seccomp
new file mode 100644
--- /dev/null
+++ b/tools/testing/selftests/proc/.gitignore
@@ -0,0 +1 @@
+/proc-self-wchan
new file mode 100644
--- /dev/null
+++ b/tools/testing/selftests/proc/Makefile
@@ -0,0 +1,6 @@
+CFLAGS += -Wall -O2
+
+TEST_GEN_PROGS :=
+TEST_GEN_PROGS += proc-self-wchan
+
+include ../lib.mk
new file mode 100644
--- /dev/null
+++ b/tools/testing/selftests/proc/config
@@ -0,0 +1 @@
+CONFIG_PROC_FS=y
new file mode 100644
--- /dev/null
+++ b/tools/testing/selftests/proc/proc-self-wchan.c
@@ -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;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-26 21:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26 21:20 [PATCH 1/2] proc: test /proc/self/wchan Alexey Dobriyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.