static int run_all_test_suites(/*@notnull@*/ test_runner * runner) /*@globals fileSystem, internalState @*/ /*@modifies fileSystem, internalState, runner, runner->buffer, runner->suite_number, runner->suites->suite, runner->stats @*/ { const char * summary1; const char * summary2; printf("Running all the tests...\n\n"); for(runner->suite_number = 0; runner->suite_number < runner->suites->count; runner->suite_number++){ /*@-boundsread@*/ test_suite * suite = runner->suites->suite[runner->suite_number]; /*@=boundsread@*/ run_test_suite(runner, suite); if(!suite->is_requirement){ switch(suite->status){ case STATUS_PASSED: runner->stats.suites.passed++; /*@switchbreak@*/ break; case STATUS_WARNING: runner->stats.suites.warnings++; /*@switchbreak@*/ break; default: /* STATUS_FAILED */ runner->stats.suites.failed++; } runner->stats.tests.passed += suite->stats.passed; runner->stats.tests.warnings += suite->stats.warnings; runner->stats.tests.failed += suite->stats.failed; } } calculate_total(&runner->stats.requirements); calculate_total(&runner->stats.tests); calculate_total(&runner->stats.suites); /* delete temporary files */ (void)remove(runner->out); (void)remove(runner->err); if(runner->report != NULL){ printf("\n\nGenerating report...\n"); generate_report(runner); printf("\tTest report created.\n"); open_report(runner); } if(runner->stats.suites.failed > 0){ summary1 = "Some of the tests failed."; }else if(runner->stats.suites.warnings > 0){ summary1 = "Some *non-critical* test didn't pass."; }else{ summary1 = "All tests passed successfully."; } if(runner->stats.suites.failed == 0 && runner->stats.suites.warnings == 0){ summary2 = ""; }else if(runner->stats.requirements.total == 0){ summary2 = "\n\tPlease verify platform requirements."; }else if(runner->stats.requirements.failed > 0 || runner->stats.requirements.warnings > 0){ summary2 = "\n\tIt could be related to some error on **platform requirements**."; }else{ summary2 = "\n\tPlease report it at: http://code.google.com/p/exceptions4c/"; } printf("\n%s%s\n\n", summary1, summary2); return(EXIT_SUCCESS); }
/** * Generate a test matrix for tabu search over TEA1, varying Tabu Search parameters * \param arcg number of input arguments * \param argv input argument string */ int main(int argc,char** argv){ input_options *options; full_test_input_options *test_options; cipher_cont *cipher=NULL; output_report *report; int lock=TRUE; unsigned long long tabu_list_length=0; unsigned long long tabu_iterations=0; unsigned long long tabu_max_decrease=0; unsigned long long change_move_limit=0; float key_eval_percent=0; if((test_options=MALLOC(full_test_input_options))==NULL){ fprintf(stderr,"ERROR: FAILED TO ALLOCATE MEMORY\n"); exit(1); } /* * parse input parameters */ if(argc>1){ parse_full_test_arguments(argc,argv,test_options); if(test_options->have_input==FALSE){ fprintf(stderr,"ERROR: NO INPUT FILE"); return(1); } } else{ print_full_test_options(argv[0]); return(1); } if(test_options->max_tabu_list_length==0){ test_options->max_tabu_list_length=TS_LIS_MAX; } if(test_options->max_tabu_iterations==0){ test_options->max_tabu_iterations=TS_ITER_MAX; } if(test_options->max_tabu_max_decrease==0){ test_options->max_tabu_max_decrease=TS_MAX_DEC_MAX; } if(test_options->max_change_move_limit==0){ test_options->max_change_move_limit=TS_CHM_MAX; } if(test_options->init_tabu_list_length==0){ test_options->init_tabu_list_length=TS_INIT_LIST; } if(test_options->init_tabu_iterations==0){ test_options->init_tabu_iterations=TS_INIT_ITER; } if(test_options->init_tabu_max_decrease==0){ test_options->init_tabu_max_decrease=TS_INIT_MAX_DEC; } if(test_options->init_change_move_limit==0){ test_options->init_change_move_limit=TS_INIT_CHM; } if(test_options->var_tabu_list_length==0){ test_options->var_tabu_list_length=TS_LIST_INCREMENT; } if(test_options->var_tabu_iterations==0){ test_options->var_tabu_iterations=TS_ITER_INCREMENT; } if(test_options->var_tabu_max_decrease==0){ test_options->var_tabu_max_decrease=TS_MAX_DEC_INCREMENT; } if(test_options->var_change_move_limit==0){ test_options->var_change_move_limit=TS_CHM_INCREMENT; } if(test_options->min_key_eval_percent==0){ test_options->min_key_eval_percent=(float)(TS_INIT_PERCENT); test_options->min_key_eval_percent=test_options->min_key_eval_percent/100; } if(test_options->var_key_eval_percent==0){ test_options->var_key_eval_percent=(float)(TS_PERCENT_INCREMENT); test_options->var_key_eval_percent=test_options->var_key_eval_percent/100; } options=convert_full_test_opt_to_gen(test_options); /* create report*/ report=open_report(options); report_use_test_matrix(report); /* read input from file */ cipher=read_input(test_options->inputfile); /* tabu serach parameters asignation */ tabu_iterations=test_options->min_key_eval_percent; tabu_list_length=test_options->init_tabu_list_length; tabu_max_decrease=test_options->init_tabu_max_decrease; key_eval_percent=test_options->min_key_eval_percent; change_move_limit=test_options->init_change_move_limit; printf("init test matrix\n"); print_mold_test_matrix(stdout); if(options->save_output) print_mold_test_matrix(report->report_file); /* iterative test matrix */ while(lock){ /* tabu search parameters refactory*/ options->tabu_list_length=tabu_list_length; /* tabu list lenght (DEFAULT 0) */ options->tabu_iterations=tabu_iterations; /* tabu iterations (DEFAULT 0) */ options->tabu_max_decrease=tabu_max_decrease; /* tabu performance max decrease (DEFAULT 0) */ options->key_eval_percent=key_eval_percent; /* percer for evaluation key */ options->change_move_limit=change_move_limit; /* perform tabu search */ tabusearch(cipher,options,report); /* use iteration test */ if(tabu_iterations<=test_options->max_tabu_iterations+1){ /* use list lenght test */ if(tabu_list_length<=test_options->max_tabu_list_length){ /* use key percent test */ if(key_eval_percent<=1){ /* use performance decreace test */ if(tabu_max_decrease<test_options->max_tabu_max_decrease){ /* use change movement limit test */ if(change_move_limit<test_options->max_change_move_limit){ change_move_limit+=test_options->var_change_move_limit; } else{ change_move_limit=test_options->init_change_move_limit; tabu_max_decrease+=test_options->var_tabu_max_decrease; } } else{ tabu_max_decrease=test_options->init_tabu_max_decrease; change_move_limit=test_options->init_change_move_limit; key_eval_percent+=test_options->var_key_eval_percent; } }else{ tabu_list_length+=test_options->var_tabu_list_length; key_eval_percent=test_options->min_key_eval_percent; tabu_max_decrease=test_options->init_tabu_max_decrease; change_move_limit=test_options->init_change_move_limit; } } else{ tabu_iterations+=test_options->var_tabu_iterations; tabu_list_length=test_options->init_tabu_list_length; tabu_max_decrease=test_options->init_tabu_max_decrease; key_eval_percent=test_options->min_key_eval_percent; change_move_limit=test_options->init_change_move_limit; } } else{ lock=FALSE; } } printf("end test matrix\n"); /* end program */ close_report(report); free((char *)options); free((char *)test_options); free((char *)report); free((char *)cipher); return(0); }