| 1 | % (c) 2014-2019 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
| 2 | % Heinrich Heine Universitaet Duesseldorf | |
| 3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
| 4 | ||
| 5 | ||
| 6 | :- module(prologTasks,[prologTaskStart/3, prologTaskStep/3, prologTaskAbort/1, prologTaskFinish/1]). | |
| 7 | ||
| 8 | :- use_module(error_manager). | |
| 9 | :- use_module(tools_strings,[ajoin/2]). | |
| 10 | :- use_module(library(lists)). | |
| 11 | ||
| 12 | ||
| 13 | ||
| 14 | :- use_module(module_information,[module_info/2]). | |
| 15 | :- module_info(group,tcltk). | |
| 16 | :- module_info(description,'This module provides the interface to the Tcl/Tk tree_inspector.'). | |
| 17 | ||
| 18 | :- dynamic task_step/3. | |
| 19 | ||
| 20 | prologTaskStart(test,'Test Task',1000) :- !. | |
| 21 | prologTaskStart(Category,CatMsg,Length) :- | |
| 22 | get_category_name(Category,CatMsg), | |
| 23 | retractall(task_step(Category,_,_)), | |
| 24 | % collect all task steps: | |
| 25 | findall(task_step(Category,Prolog,Msg),get_task_steps(Category,Prolog,Msg),Tasks), | |
| 26 | %print(task_steps(Category,Tasks)),nl, | |
| 27 | length(Tasks,Length), | |
| 28 | maplist(assert,Tasks),nl. | |
| 29 | ||
| 30 | ||
| 31 | prologTaskStep(test,Nr,NewMsg) :- !, | |
| 32 | ajoin(['Running ', Nr],NewMsg). | |
| 33 | prologTaskStep(Category,Nr,NewMsg) :- %print(step(Nr)),nl, | |
| 34 | retract(task_step(Category,PrologCode,Msg)), | |
| 35 | % print(calling(PrologCode)),nl, | |
| 36 | statistics(walltime,[Start,_]), | |
| 37 | call(PrologCode), | |
| 38 | statistics(walltime,[Stop,_]), | |
| 39 | T is Stop-Start, | |
| 40 | % print(done(Msg)),nl, | |
| 41 | (get_task_info(Category,Nr,Info) | |
| 42 | -> ajoin(['Step ', Nr, ': ', Msg, ' [', Info, '] (', T, ' ms)'],NewMsg) | |
| 43 | ; ajoin(['Step ', Nr, ': ', Msg, ' (', T, ' ms)'],NewMsg) | |
| 44 | ). | |
| 45 | % TO DO: optionally return other stats : nr of test-cases, nr of feasible/infeasbile ops | |
| 46 | ||
| 47 | ||
| 48 | prologTaskAbort(Category) :- retract(task_step(Category,_PrologCode,Msg)), | |
| 49 | %add_internal_error('Pending task: ',task_step(Category,PrologCode,Msg)), | |
| 50 | print(aborting(Msg)),nl, | |
| 51 | fail. | |
| 52 | prologTaskAbort(_). | |
| 53 | ||
| 54 | % prologTaskFinish will also be called in case of Abort | |
| 55 | ||
| 56 | prologTaskFinish(cbc_tests(_EventSel,_TargetPredicateStr,_MaxLength,_Filename,_Final)) :- !, | |
| 57 | sap:cbc_gen_test_cases_finish_tasks. | |
| 58 | prologTaskFinish(_). | |
| 59 | ||
| 60 | :- use_module(sap,[get_counter_info/4]). | |
| 61 | :- use_module(sap). | |
| 62 | :- use_module(enabling_analysis,[cbc_enable_analysis_cache/4,feasible_operation_cache/2,init_or_op/1]). | |
| 63 | :- use_module(bmachine, [b_top_level_operation/1]). | |
| 64 | :- use_module(state_space, [operation_name_not_yet_covered/1]). | |
| 65 | ||
| 66 | ||
| 67 | ||
| 68 | get_category_name(feasibility,'Feasibility Analysis'). | |
| 69 | get_category_name(enabling(_),'Enabling Analysis'). | |
| 70 | get_category_name(cbc_tests(_,_,_,_,_),'CBC Testcase Generation'). | |
| 71 | ||
| 72 | get_task_info(cbc_tests(_,_,_,_,_),Nr,Info) :- | |
| 73 | N1 is Nr+1, | |
| 74 | get_counter_info(N1,Paths,Tests,Timeouts), | |
| 75 | sap:cbc_get_nr_uncovered_events(Unc), | |
| 76 | ajoin(['Uncovered: ',Unc, ', Paths: ',Paths,', Tests: ',Tests,', Timeouts: ',Timeouts],Info). | |
| 77 | ||
| 78 | % maybe we should move this to the corresponding modules, which register their tasks | |
| 79 | get_task_steps(feasibility,PrologCode,Msg) :- | |
| 80 | b_top_level_operation(OpName), | |
| 81 | operation_name_not_yet_covered(OpName), | |
| 82 | \+ feasible_operation_cache(OpName,_), % not yet computed | |
| 83 | PrologCode = enabling_analysis:feasible_operation(OpName,_), % will compute the cache | |
| 84 | ajoin(['feasibility of ',OpName],Msg). | |
| 85 | get_task_steps(enabling(ExtraTimeOut),PrologCode,Msg) :- %print(get_task(ExtraTimeOut)),nl, | |
| 86 | init_or_op(OpName), %print(op(OpName)),nl, | |
| 87 | \+ cbc_enable_analysis_cache(OpName,_,_,ExtraTimeOut), % not yet computed | |
| 88 | PrologCode = findall(1,enabling_analysis:cbc_enable_analysis(OpName,_,_,ExtraTimeOut),_), | |
| 89 | ajoin(['enabling of ',OpName],Msg). | |
| 90 | get_task_steps(cbc_tests(EventSel,TargetPredicateStr,MaxLength,Filename,Final),PrologCode,Msg) :- | |
| 91 | sap:cbc_gen_test_cases_task_step(EventSel,TargetPredicateStr,MaxLength,Filename, Final, Depth, PrologCode), | |
| 92 | ajoin(['cbc_tests for depth ',Depth],Msg). | |
| 93 |