Linux 4.19.133
[linux/fpc-iii.git] / tools / testing / selftests / powerpc / tm / tm-fork.c
blob8d48579b7778c3c55277eb68e4965056815af43b
1 /*
2 * Copyright 2015, Michael Neuling, IBM Corp.
3 * Licensed under GPLv2.
5 * Edited: Rashmica Gupta, Nov 2015
7 * This test does a fork syscall inside a transaction. Basic sniff test
8 * to see if we can enter the kernel during a transaction.
9 */
11 #include <errno.h>
12 #include <inttypes.h>
13 #include <pthread.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
18 #include "utils.h"
19 #include "tm.h"
21 int test_fork(void)
23 SKIP_IF(!have_htm());
25 asm __volatile__(
26 "tbegin.;"
27 "blt 1f; "
28 "li 0, 2;" /* fork syscall */
29 "sc ;"
30 "tend.;"
31 "1: ;"
32 : : : "memory", "r0");
33 /* If we reach here, we've passed. Otherwise we've probably crashed
34 * the kernel */
36 return 0;
39 int main(int argc, char *argv[])
41 return test_harness(test_fork, "tm_fork");