Add test flags.
This commit is contained in:
parent
2ac453aeba
commit
26e52f4bc4
16
test/ctest.h
16
test/ctest.h
|
@ -356,7 +356,7 @@ static void sighandler(int signum)
|
|||
}
|
||||
#endif
|
||||
|
||||
int ctest_main(int argc, char *argv[])
|
||||
int ctest_main(char * input_suitname, char * input_testname)
|
||||
{
|
||||
static int total = 0;
|
||||
static int num_ok = 0;
|
||||
|
@ -369,16 +369,16 @@ int ctest_main(int argc, char *argv[])
|
|||
signal(SIGSEGV, sighandler);
|
||||
#endif
|
||||
|
||||
if (argc == 2) {
|
||||
suite_name = argv[1];
|
||||
|
||||
if (input_suitname != NULL && input_testname != NULL) {
|
||||
suite_name = input_suitname;
|
||||
test_name = input_testname;
|
||||
filter = suite_test_filter;
|
||||
}else if(input_suitname != NULL) {
|
||||
suite_name = input_suitname;
|
||||
filter = suite_filter;
|
||||
}
|
||||
|
||||
if (argc == 3) {
|
||||
suite_name = argv[1];
|
||||
test_name = argv[2];
|
||||
filter = suite_test_filter;
|
||||
}
|
||||
|
||||
color_output = isatty(1);
|
||||
uint64_t t1 = getCurrentTime();
|
||||
|
|
|
@ -37,12 +37,13 @@ CTEST_TEARDOWN(check_result_z) {
|
|||
|
||||
int main(int argc, char ** argv){
|
||||
|
||||
int tmp_argc=1;
|
||||
char ** tmp_argv=NULL;
|
||||
|
||||
init_input_arg(argc, argv);
|
||||
char * suitname=NULL;
|
||||
char * testname=NULL;
|
||||
|
||||
ctest_main(argc, argv);
|
||||
read_input_flags(argc, argv, &suitname, &testname);
|
||||
|
||||
ctest_main(suitname, testname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ typedef struct{
|
|||
VML_INT start;
|
||||
VML_INT end;
|
||||
VML_INT step;
|
||||
char suitname[1024];
|
||||
char testname[1024];
|
||||
} input_arg_t;
|
||||
|
||||
CTEST_DATA(check_result_s) {
|
||||
|
@ -61,7 +63,7 @@ CTEST_DATA(check_result_z) {
|
|||
|
||||
void * vml_test_memory_alloc(size_t size);
|
||||
void vml_test_memory_free(void * ptr);
|
||||
input_arg_t * get_input_arg();
|
||||
//input_arg_t * get_input_arg();
|
||||
|
||||
void init_test_parameter(perf_arg_t ** p, int iscomplex, int isdouble);
|
||||
void free_test_parameter(perf_arg_t ** p);
|
||||
|
|
|
@ -32,26 +32,69 @@ void vml_test_memory_free(void * ptr)
|
|||
free(ptr);
|
||||
}
|
||||
|
||||
void print_help()
|
||||
void print_help(char * name)
|
||||
{
|
||||
printf("-d <start> <end> <step>\n");
|
||||
printf(" input data size.\n");
|
||||
printf("-s test_suit\n");
|
||||
printf(" testsuit name\n");
|
||||
printf("OpenVML test usage:\n");
|
||||
printf("%s [-options ..]\n\n", name);
|
||||
printf(" -h\tPrint this message.\n");
|
||||
printf("\n");
|
||||
printf(" -d\t<start> <end> <step>\n");
|
||||
printf(" \tInput data size.\n");
|
||||
printf("\n");
|
||||
printf(" -r\t<testsuit_name> [test_name]\n");
|
||||
printf(" \tRun testsuit filtered by testsuit_name\n");
|
||||
printf(" \tOr, run test filtered by testsuit_name and test_name\n");
|
||||
printf("\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static input_arg_t input_args;
|
||||
|
||||
/*
|
||||
input_arg_t * get_input_arg()
|
||||
{
|
||||
return &input_args;
|
||||
}
|
||||
*/
|
||||
|
||||
void init_input_arg(int argc, char *argv[])
|
||||
void read_input_flags(int argc, char *argv[], char ** suitname, char ** testname)
|
||||
{
|
||||
int i;
|
||||
|
||||
input_args.start=100;
|
||||
input_args.end=200;
|
||||
input_args.step=10;
|
||||
*suitname=NULL;
|
||||
*testname=NULL;
|
||||
|
||||
for(i=1; i<argc; ) {
|
||||
if(argv[i][0] != '-') print_help(argv[0]);
|
||||
|
||||
switch(argv[i++][1]) {
|
||||
case 'h':
|
||||
print_help(argv[0]);
|
||||
break;
|
||||
case 'r':
|
||||
if (argv[i] == NULL) print_help(argv[0]);
|
||||
snprintf(input_args.suitname,1024,"%s", argv[i++]);
|
||||
*suitname=input_args.suitname;
|
||||
if (argv[i] == NULL) continue;
|
||||
if (argv[i][0] == '-') continue;
|
||||
snprintf(input_args.testname,1024,"%s", argv[i++]);
|
||||
*testname=input_args.testname;
|
||||
break;
|
||||
case 'd':
|
||||
if (argv[i] == NULL) print_help(argv[0]);
|
||||
input_args.start=atoi(argv[i++]);
|
||||
if (argv[i] == NULL) print_help(argv[0]);
|
||||
input_args.end=atoi(argv[i++]);
|
||||
if (argv[i] == NULL) print_help(argv[0]);
|
||||
input_args.step=atoi(argv[i++]);
|
||||
break;
|
||||
default:
|
||||
print_help(argv[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_test_parameter(perf_arg_t ** p, int iscomplex, int isdouble)
|
||||
|
|
Loading…
Reference in New Issue