]> git.saurik.com Git - apple/xnu.git/blob - tools/tests/perf_index/perfindex-compile.c
xnu-6153.141.1.tar.gz
[apple/xnu.git] / tools / tests / perf_index / perfindex-compile.c
1 #include "perf_index.h"
2 #include "fail.h"
3 #include <stdio.h>
4 #include <stdlib.h>
5
6 static const char *src_dst = "/tmp/perf_index_compile_code";
7 static const char *src_root = "/Network/Servers/xs1/release/Software/Zin/Projects/xnu/xnu-2050.7.9";
8
9 DECL_SETUP {
10 char* cmd;
11 int retval;
12 const char *src = src_root;
13 if (test_argc >= 1) {
14 src = (char*)test_argv[0];
15 }
16
17 retval = asprintf(&cmd, "ditto \"%s\" \"%s\"", src, src_dst);
18 VERIFY(retval > 0, "asprintf failed");
19
20 retval = system(cmd);
21 VERIFY(retval == 0, "ditto command failed");
22
23 free(cmd);
24
25 return PERFINDEX_SUCCESS;
26 }
27
28 DECL_TEST {
29 char* cmd;
30 int retval;
31
32 if (thread_id != 0) {
33 return 0;
34 }
35
36 retval = asprintf(&cmd, "make -C \"%s\" MAKEJOBS=-j%d", src_dst, num_threads);
37 VERIFY(retval > 0, "asprintf failed");
38
39 retval = system(cmd);
40 VERIFY(retval == 0, "make command failed");
41
42 return PERFINDEX_SUCCESS;
43 }
44
45 DECL_CLEANUP {
46 char* cmd;
47 int retval;
48
49 retval = asprintf(&cmd, "rm -rf \"%s\"", src_dst);
50 VERIFY(retval > 0, "asprintf failed");
51
52 retval = system(cmd);
53 VERIFY(retval == 0, "rm command failed");
54
55 return PERFINDEX_SUCCESS;
56 }