selftests/powerpc: Add test for forking inside transaction
authorRashmica Gupta <rashmicy@gmail.com>
Wed, 23 Dec 2015 05:49:52 +0000 (16:49 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 11 May 2016 11:54:13 +0000 (21:54 +1000)
This test does a fork syscall inside a transaction. Basic sniff test to see
if we can enter the kernel during a transaction.

Signed-off-by: Rashmica Gupta <rashmicy@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
tools/testing/selftests/powerpc/tm/.gitignore
tools/testing/selftests/powerpc/tm/Makefile
tools/testing/selftests/powerpc/tm/tm-fork.c [new file with mode: 0644]

index 737f72c..2db475b 100644 (file)
@@ -1,4 +1,4 @@
-TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack tm-vmxcopy
+TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack tm-vmxcopy tm-fork
 
 all: $(TEST_PROGS)
 
diff --git a/tools/testing/selftests/powerpc/tm/tm-fork.c b/tools/testing/selftests/powerpc/tm/tm-fork.c
new file mode 100644 (file)
index 0000000..8d48579
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015, Michael Neuling, IBM Corp.
+ * Licensed under GPLv2.
+ *
+ * Edited: Rashmica Gupta, Nov 2015
+ *
+ * This test does a fork syscall inside a transaction. Basic sniff test
+ * to see if we can enter the kernel during a transaction.
+ */
+
+#include <errno.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "utils.h"
+#include "tm.h"
+
+int test_fork(void)
+{
+       SKIP_IF(!have_htm());
+
+       asm __volatile__(
+               "tbegin.;"
+               "blt    1f; "
+               "li     0, 2;"  /* fork syscall */
+               "sc  ;"
+               "tend.;"
+               "1: ;"
+               : : : "memory", "r0");
+       /* If we reach here, we've passed.  Otherwise we've probably crashed
+        * the kernel */
+
+       return 0;
+}
+
+int main(int argc, char *argv[])
+{
+       return test_harness(test_fork, "tm_fork");
+}