selftests/powerpc: Add tests of unmuxed IPC calls
authorMichael Ellerman <mpe@ellerman.id.au>
Wed, 14 Oct 2015 09:48:04 +0000 (20:48 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 15 Oct 2015 09:32:03 +0000 (20:32 +1100)
This is just a simple test which confirms that the individual IPC
syscalls are all available.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
tools/testing/selftests/powerpc/Makefile
tools/testing/selftests/powerpc/syscalls/.gitignore [new file with mode: 0644]
tools/testing/selftests/powerpc/syscalls/Makefile [new file with mode: 0644]
tools/testing/selftests/powerpc/syscalls/ipc.h [new file with mode: 0644]
tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c [new file with mode: 0644]

index 847adf6e8d16b9481b8c483c57fa77cfb378c51a..b120dc11aebe705d2e6fc18b1bf2861d853e2a28 100644 (file)
@@ -12,7 +12,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
 
 export CFLAGS
 
-SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks
+SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks syscalls
 
 endif
 
diff --git a/tools/testing/selftests/powerpc/syscalls/.gitignore b/tools/testing/selftests/powerpc/syscalls/.gitignore
new file mode 100644 (file)
index 0000000..f0f3fcc
--- /dev/null
@@ -0,0 +1 @@
+ipc_unmuxed
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
new file mode 100644 (file)
index 0000000..b35c794
--- /dev/null
@@ -0,0 +1,12 @@
+TEST_PROGS := ipc_unmuxed
+
+CFLAGS += -I../../../../../usr/include
+
+all: $(TEST_PROGS)
+
+$(TEST_PROGS): ../harness.c
+
+include ../../lib.mk
+
+clean:
+       rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/syscalls/ipc.h b/tools/testing/selftests/powerpc/syscalls/ipc.h
new file mode 100644 (file)
index 0000000..fbebc02
--- /dev/null
@@ -0,0 +1,47 @@
+#ifdef __NR_semop
+DO_TEST(semop, __NR_semop)
+#endif
+
+#ifdef __NR_semget
+DO_TEST(semget, __NR_semget)
+#endif
+
+#ifdef __NR_semctl
+DO_TEST(semctl, __NR_semctl)
+#endif
+
+#ifdef __NR_semtimedop
+DO_TEST(semtimedop, __NR_semtimedop)
+#endif
+
+#ifdef __NR_msgsnd
+DO_TEST(msgsnd, __NR_msgsnd)
+#endif
+
+#ifdef __NR_msgrcv
+DO_TEST(msgrcv, __NR_msgrcv)
+#endif
+
+#ifdef __NR_msgget
+DO_TEST(msgget, __NR_msgget)
+#endif
+
+#ifdef __NR_msgctl
+DO_TEST(msgctl, __NR_msgctl)
+#endif
+
+#ifdef __NR_shmat
+DO_TEST(shmat, __NR_shmat)
+#endif
+
+#ifdef __NR_shmdt
+DO_TEST(shmdt, __NR_shmdt)
+#endif
+
+#ifdef __NR_shmget
+DO_TEST(shmget, __NR_shmget)
+#endif
+
+#ifdef __NR_shmctl
+DO_TEST(shmctl, __NR_shmctl)
+#endif
diff --git a/tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c b/tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c
new file mode 100644 (file)
index 0000000..2ac0270
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2015, Michael Ellerman, IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * This test simply tests that certain syscalls are implemented. It doesn't
+ * actually exercise their logic in any way.
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "utils.h"
+
+
+#define DO_TEST(_name, _num)   \
+static int test_##_name(void)                  \
+{                                              \
+       int rc;                                 \
+       printf("Testing " #_name);              \
+       errno = 0;                              \
+       rc = syscall(_num, -1, 0, 0, 0, 0, 0);  \
+       printf("\treturned %d, errno %d\n", rc, errno); \
+       return errno == ENOSYS;                 \
+}
+
+#include "ipc.h"
+#undef DO_TEST
+
+static int ipc_unmuxed(void)
+{
+       int tests_done = 0;
+
+#define DO_TEST(_name, _num)           \
+       FAIL_IF(test_##_name());        \
+       tests_done++;
+
+#include "ipc.h"
+#undef DO_TEST
+
+       /*
+        * If we ran no tests then it means none of the syscall numbers were
+        * defined, possibly because we were built against old headers. But it
+        * means we didn't really test anything, so instead of passing mark it
+        * as a skip to give the user a clue.
+        */
+       SKIP_IF(tests_done == 0);
+
+       return 0;
+}
+
+int main(void)
+{
+       return test_harness(ipc_unmuxed, "ipc_unmuxed");
+}