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