26
#include <llvm-c/Target.h>
28
#include "framework.h"
29
34
#include <string.h>
31
36
#include <unistd.h>
33
#include <llvm-c/Target.h>
35
#include "framework.h"
37
static const char *help_message =
39
static const char* help_message =
38
40
"Usage: %s [-h] [-l --list] [--no-check] [TEST [TEST ...]]\n"
40
42
"Run ACO unit test(s). If TEST is not provided, all tests are run.\n"
50
52
" --no-check Print test output instead of checking it.\n";
52
54
std::map<std::string, TestDef> tests;
55
57
static TestDef current_test;
56
58
static unsigned tests_written = 0;
57
static FILE *checker_stdin = NULL;
58
static char *checker_stdin_data = NULL;
59
static FILE* checker_stdin = NULL;
60
static char* checker_stdin_data = NULL;
59
61
static size_t checker_stdin_size = 0;
61
static char *output_data = NULL;
63
static char* output_data = NULL;
62
64
static size_t output_size = 0;
63
65
static size_t output_offset = 0;
65
67
static char current_variant[64] = {0};
66
static std::set<std::string> *variant_filter = NULL;
68
static std::set<std::string>* variant_filter = NULL;
68
70
bool test_failed = false;
69
71
bool test_skipped = false;
70
72
static char fail_message[256] = {0};
74
77
if (!checker_stdin) {
75
78
/* not entirely correct, but shouldn't matter */
81
84
if (output_offset == output_size && !test_skipped && !test_failed)
84
char *data = output_data + output_offset;
87
char* data = output_data + output_offset;
85
88
uint32_t size = output_size - output_offset;
87
90
fwrite("test", 1, 4, checker_stdin);
88
fwrite(current_test.name, 1, strlen(current_test.name)+1, checker_stdin);
89
fwrite(current_variant, 1, strlen(current_variant)+1, checker_stdin);
90
fwrite(current_test.source_file, 1, strlen(current_test.source_file)+1, checker_stdin);
91
fwrite(current_test.name, 1, strlen(current_test.name) + 1, checker_stdin);
92
fwrite(current_variant, 1, strlen(current_variant) + 1, checker_stdin);
93
fwrite(current_test.source_file, 1, strlen(current_test.source_file) + 1, checker_stdin);
91
94
if (test_failed || test_skipped) {
92
const char *res = test_failed ? "failed" : "skipped";
95
const char* res = test_failed ? "failed" : "skipped";
93
96
fwrite("\x01", 1, 1, checker_stdin);
94
fwrite(res, 1, strlen(res)+1, checker_stdin);
95
fwrite(fail_message, 1, strlen(fail_message)+1, checker_stdin);
97
fwrite(res, 1, strlen(res) + 1, checker_stdin);
98
fwrite(fail_message, 1, strlen(fail_message) + 1, checker_stdin);
97
100
fwrite("\x00", 1, 1, checker_stdin);
183
191
close(stdin_pipe[0]);
184
192
close(stdin_pipe[1]);
186
execlp(ACO_TEST_PYTHON_BIN, ACO_TEST_PYTHON_BIN, ACO_TEST_SOURCE_DIR "/check_output.py", NULL);
194
execlp(ACO_TEST_PYTHON_BIN, ACO_TEST_PYTHON_BIN, ACO_TEST_SOURCE_DIR "/check_output.py",
187
196
fprintf(stderr, "%s: execlp() failed: %s\n", argv[0], strerror(errno));
206
216
return name == pattern;
209
int main(int argc, char **argv)
220
main(int argc, char** argv)
211
222
int print_help = 0;
213
224
int do_check = 1;
214
const struct option opts[] = {
215
{ "help", no_argument, &print_help, 1 },
216
{ "list", no_argument, &do_list, 1 },
217
{ "no-check", no_argument, &do_check, 0 },
225
const struct option opts[] = {{"help", no_argument, &print_help, 1},
226
{"list", no_argument, &do_list, 1},
227
{"no-check", no_argument, &do_check, 0},
222
231
while ((c = getopt_long(argc, argv, "hl", opts, NULL)) != -1) {
233
case 'h': print_help = 1; break;
234
case 'l': do_list = 1; break;
234
fprintf(stderr, "%s: Invalid argument\n", argv[0]);
237
default: fprintf(stderr, "%s: Invalid argument\n", argv[0]); return 99;
263
265
checker_stdin = open_memstream(&checker_stdin_data, &checker_stdin_size);
265
LLVMInitializeAMDGPUTargetInfo();
266
LLVMInitializeAMDGPUTarget();
267
LLVMInitializeAMDGPUTargetMC();
268
LLVMInitializeAMDGPUDisassembler();
267
LLVMInitializeAMDGPUTargetInfo();
268
LLVMInitializeAMDGPUTarget();
269
LLVMInitializeAMDGPUTargetMC();
270
LLVMInitializeAMDGPUDisassembler();