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