aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2015-10-14 05:48:04 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2015-10-15 05:32:03 -0400
commit0b824f2e2b6cf87f2f5318f0950d431a286d25df (patch)
tree6683d3dc5f38bb19a7aaff3de21c2db3d82ac35f /tools
parentad987fc8eae7b5f4085c5ad2610b9af12018c38a (diff)
selftests/powerpc: Add tests of unmuxed IPC calls
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/powerpc/Makefile2
-rw-r--r--tools/testing/selftests/powerpc/syscalls/.gitignore1
-rw-r--r--tools/testing/selftests/powerpc/syscalls/Makefile12
-rw-r--r--tools/testing/selftests/powerpc/syscalls/ipc.h47
-rw-r--r--tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c61
5 files changed, 122 insertions, 1 deletions
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 847adf6e8d16..b120dc11aebe 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -12,7 +12,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
12 12
13export CFLAGS 13export CFLAGS
14 14
15SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks 15SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks syscalls
16 16
17endif 17endif
18 18
diff --git a/tools/testing/selftests/powerpc/syscalls/.gitignore b/tools/testing/selftests/powerpc/syscalls/.gitignore
new file mode 100644
index 000000000000..f0f3fcc9d802
--- /dev/null
+++ b/tools/testing/selftests/powerpc/syscalls/.gitignore
@@ -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
index 000000000000..b35c7945bec5
--- /dev/null
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -0,0 +1,12 @@
1TEST_PROGS := ipc_unmuxed
2
3CFLAGS += -I../../../../../usr/include
4
5all: $(TEST_PROGS)
6
7$(TEST_PROGS): ../harness.c
8
9include ../../lib.mk
10
11clean:
12 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
index 000000000000..fbebc022edf6
--- /dev/null
+++ b/tools/testing/selftests/powerpc/syscalls/ipc.h
@@ -0,0 +1,47 @@
1#ifdef __NR_semop
2DO_TEST(semop, __NR_semop)
3#endif
4
5#ifdef __NR_semget
6DO_TEST(semget, __NR_semget)
7#endif
8
9#ifdef __NR_semctl
10DO_TEST(semctl, __NR_semctl)
11#endif
12
13#ifdef __NR_semtimedop
14DO_TEST(semtimedop, __NR_semtimedop)
15#endif
16
17#ifdef __NR_msgsnd
18DO_TEST(msgsnd, __NR_msgsnd)
19#endif
20
21#ifdef __NR_msgrcv
22DO_TEST(msgrcv, __NR_msgrcv)
23#endif
24
25#ifdef __NR_msgget
26DO_TEST(msgget, __NR_msgget)
27#endif
28
29#ifdef __NR_msgctl
30DO_TEST(msgctl, __NR_msgctl)
31#endif
32
33#ifdef __NR_shmat
34DO_TEST(shmat, __NR_shmat)
35#endif
36
37#ifdef __NR_shmdt
38DO_TEST(shmdt, __NR_shmdt)
39#endif
40
41#ifdef __NR_shmget
42DO_TEST(shmget, __NR_shmget)
43#endif
44
45#ifdef __NR_shmctl
46DO_TEST(shmctl, __NR_shmctl)
47#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
index 000000000000..2ac02706f8c8
--- /dev/null
+++ b/tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c
@@ -0,0 +1,61 @@
1/*
2 * Copyright 2015, Michael Ellerman, IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * This test simply tests that certain syscalls are implemented. It doesn't
10 * actually exercise their logic in any way.
11 */
12
13#define _GNU_SOURCE
14#include <errno.h>
15#include <stdio.h>
16#include <unistd.h>
17#include <sys/syscall.h>
18
19#include "utils.h"
20
21
22#define DO_TEST(_name, _num) \
23static int test_##_name(void) \
24{ \
25 int rc; \
26 printf("Testing " #_name); \
27 errno = 0; \
28 rc = syscall(_num, -1, 0, 0, 0, 0, 0); \
29 printf("\treturned %d, errno %d\n", rc, errno); \
30 return errno == ENOSYS; \
31}
32
33#include "ipc.h"
34#undef DO_TEST
35
36static int ipc_unmuxed(void)
37{
38 int tests_done = 0;
39
40#define DO_TEST(_name, _num) \
41 FAIL_IF(test_##_name()); \
42 tests_done++;
43
44#include "ipc.h"
45#undef DO_TEST
46
47 /*
48 * If we ran no tests then it means none of the syscall numbers were
49 * defined, possibly because we were built against old headers. But it
50 * means we didn't really test anything, so instead of passing mark it
51 * as a skip to give the user a clue.
52 */
53 SKIP_IF(tests_done == 0);
54
55 return 0;
56}
57
58int main(void)
59{
60 return test_harness(ipc_unmuxed, "ipc_unmuxed");
61}