1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#define _GNU_SOURCE
17#include <errno.h>
18#include <inttypes.h>
19#include <libgen.h>
20#include <pthread.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <unistd.h>
25
26#include "utils.h"
27#include "tm.h"
28
29static char *path;
30
31static int test_exec(void)
32{
33 SKIP_IF(!have_htm());
34
35 asm __volatile__(
36 "tbegin.;"
37 "blt 1f; "
38 "tsuspend.;"
39 "1: ;"
40 : : : "memory");
41
42 execl(path, "tm-exec", "--child", NULL);
43
44
45 perror("execl() failed");
46 return 1;
47}
48
49static int after_exec(void)
50{
51 asm __volatile__(
52 "tbegin.;"
53 "blt 1f;"
54 "tsuspend.;"
55 "1: ;"
56 : : : "memory");
57
58 FAIL_IF(failure_is_nesting());
59 return 0;
60}
61
62int main(int argc, char *argv[])
63{
64 path = argv[0];
65
66 if (argc > 1 && strcmp(argv[1], "--child") == 0)
67 return after_exec();
68
69 return test_harness(test_exec, "tm_exec");
70}
71