xref: /xnu-8020.140.41/tools/tests/perf_index/perfindex-file_write.c (revision 27b03b360a988dfd3dfdf34262bb0042026747cc)
1*27b03b36SApple OSS Distributions #include "perf_index.h"
2*27b03b36SApple OSS Distributions #include "fail.h"
3*27b03b36SApple OSS Distributions #include "test_file_helper.h"
4*27b03b36SApple OSS Distributions #include <stdio.h>
5*27b03b36SApple OSS Distributions #include <sys/param.h>
6*27b03b36SApple OSS Distributions #include <unistd.h>
7*27b03b36SApple OSS Distributions 
8*27b03b36SApple OSS Distributions char tempdir[MAXPATHLEN];
9*27b03b36SApple OSS Distributions 
10*27b03b36SApple OSS Distributions DECL_SETUP {
11*27b03b36SApple OSS Distributions 	char* retval;
12*27b03b36SApple OSS Distributions 
13*27b03b36SApple OSS Distributions 	retval = setup_tempdir(tempdir);
14*27b03b36SApple OSS Distributions 
15*27b03b36SApple OSS Distributions 	VERIFY(retval, "tempdir setup failed");
16*27b03b36SApple OSS Distributions 
17*27b03b36SApple OSS Distributions 	printf("tempdir: %s\n", tempdir);
18*27b03b36SApple OSS Distributions 
19*27b03b36SApple OSS Distributions 	return test_file_write_setup(tempdir, num_threads, length);
20*27b03b36SApple OSS Distributions }
21*27b03b36SApple OSS Distributions 
22*27b03b36SApple OSS Distributions DECL_TEST {
23*27b03b36SApple OSS Distributions 	return test_file_write(tempdir, thread_id, num_threads, length, 0L);
24*27b03b36SApple OSS Distributions }
25*27b03b36SApple OSS Distributions 
26*27b03b36SApple OSS Distributions DECL_CLEANUP {
27*27b03b36SApple OSS Distributions 	int retval;
28*27b03b36SApple OSS Distributions 
29*27b03b36SApple OSS Distributions 	retval = test_file_write_cleanup(tempdir, num_threads, length);
30*27b03b36SApple OSS Distributions 	VERIFY(retval == PERFINDEX_SUCCESS, "test_file_read_cleanup failed");
31*27b03b36SApple OSS Distributions 
32*27b03b36SApple OSS Distributions 	retval = cleanup_tempdir(tempdir);
33*27b03b36SApple OSS Distributions 	VERIFY(retval == 0, "cleanup_tempdir failed");
34*27b03b36SApple OSS Distributions 
35*27b03b36SApple OSS Distributions 	return PERFINDEX_SUCCESS;
36*27b03b36SApple OSS Distributions }
37