Commit 991344f4 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Update test case for model checking

parent 475dbe04
......@@ -28,6 +28,7 @@ package body Properties is
Event : in out asn1sccObservable_Event;
Id : out Natural;
Success : out Boolean) is
Observer_State_Status : asn1SccObserver_State_Kind;
begin
Id := 0;
-- Restore the state of the observer, and execute it
......@@ -35,13 +36,14 @@ package body Properties is
-- Put_Line ("[OBS] Context set to: " & GSER.Image (My_Observer.Ctxt));
-- Set the observer's monitors
My_Observer.Observe (Full_State.User_State, Event);
Observer_State_Status := My_Observer.Observe (Full_State.User_State, Event);
-- Read the modified state from the observer
Event := My_Observer.Event;
Full_State.User_state := My_Observer.St;
Full_State.My_Observer_State := My_Observer.Ctxt;
-- Simple stop condition:
Success := (My_Observer.Ctxt.State = My_Observer_Datamodel.asn1SccEnd_Success);
Success := (Observer_State_Status = asn1SccError_State);
-- My_Observer.Ctxt.State = My_Observer_Datamodel.asn1SccEnd_Success);
if Success then
Put_Line ("Stop condition found");
end if;
......
......@@ -86,6 +86,14 @@ BEGIN
env, another-function, orchestrator, simulator-gui
}
-- Current observer state flag (used by model checkers)
Observer-State-Kind ::= ENUMERATED {
regular-state,
error-state,
ignore-state,
success-state
}
-- Event related to the execution of a PI or call of a RI in the functional code
Function-Event ::= CHOICE {
another-function Another-Function-Event,
......@@ -132,7 +140,7 @@ IMPORTS
T-Null, T-Int, T-SeqOf FROM Iterators-Types
T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean, T-Null-Record FROM TASTE-BasicTypes;
Orchestrator-States ::= ENUMERATED {all-done, step-2, wait}
Orchestrator-States ::= ENUMERATED {step-2, wait, all-done}
Orchestrator-Context ::= SEQUENCE {
state Orchestrator-States,
......
......@@ -29,7 +29,7 @@ foo;
connect c and r;
/* CIF PROCESS (259, 87), (150, 75) */
process my_observer;
/* CIF TEXT (0, 57), (256, 216) */
/* CIF TEXT (0, 57), (256, 248) */
monitor st System_State;
monitor event Observable_Event;
......@@ -41,8 +41,11 @@ foo;
renames st.another_function.param1;
dcl p1 T_Int;
successstates good;
errorstates corrupted;
/* CIF ENDTEXT */
/* CIF procedure (161, 457), (106, 35) */
/* CIF procedure (149, 457), (106, 35) */
procedure Discard_Event;
/* CIF START (182, 39), (70, 35) */
START;
......@@ -51,163 +54,145 @@ foo;
/* CIF return (199, 149), (35, 35) */
return ;
endprocedure;
/* CIF procedure (2145, 152), (70, 35) */
/* CIF procedure (274, 120), (70, 35) */
procedure observe;
/* CIF TEXT (285, 48), (313, 120) */
/* CIF TEXT (288, 48), (337, 136) */
-- this procedure could be generated automatically,
-- and be read-only.
fpar in/out model System_State,
in/out last_event Observable_Event;
returns Observer_State_Kind;
dcl curr_status Observer_State_Kind := regular_state;
/* CIF ENDTEXT */
/* CIF START (609, 153), (70, 35) */
/* CIF START (782, 118), (70, 35) */
START;
/* CIF task (575, 208), (137, 40) */
/* CIF task (748, 173), (137, 40) */
task st := model,
Event := Last_Event;
/* CIF PROCEDURECALL (490, 268), (308, 35) */
/* CIF PROCEDURECALL (663, 233), (308, 35) */
call writeln('[observer] Event: ', present(event));
/* CIF decision (587, 323), (113, 50) */
/* CIF decision (760, 288), (113, 50) */
decision present(event);
/* CIF ANSWER (97, 393), (93, 24) */
/* CIF ANSWER (259, 358), (93, 24) */
(input_event):
/* CIF PROCEDURECALL (0, 437), (289, 35) */
/* CIF PROCEDURECALL (162, 402), (289, 35) */
call writeln('FROM: ', event.input_event.source);
/* CIF PROCEDURECALL (0, 492), (289, 35) */
/* CIF PROCEDURECALL (162, 457), (289, 35) */
call writeln('TO: ', event.input_event.dest);
/* CIF ANSWER (393, 393), (103, 24) */
/* CIF ANSWER (555, 358), (103, 24) */
(output_event):
/* CIF PROCEDURECALL (300, 437), (290, 35) */
/* CIF PROCEDURECALL (462, 402), (290, 35) */
call writeln('FROM: ', event.output_event.source);
/* CIF PROCEDURECALL (300, 492), (289, 35) */
/* CIF PROCEDURECALL (463, 457), (289, 35) */
call writeln('TO: ', event.output_event.dest);
/* CIF ANSWER (629, 393), (114, 24) */
/* CIF ANSWER (791, 358), (114, 24) */
(system_startup):
/* CIF PROCEDURECALL (601, 437), (169, 35) */
/* CIF PROCEDURECALL (764, 402), (169, 35) */
call writeln('system startup');
/* CIF ANSWER (827, 393), (78, 24) */
/* CIF ANSWER (989, 358), (78, 24) */
(no_event):
/* CIF PROCEDURECALL (781, 437), (169, 35) */
/* CIF PROCEDURECALL (944, 402), (169, 35) */
call writeln('no_event');
/* CIF ANSWER (984, 393), (123, 24) */
/* CIF ANSWER (1146, 358), (123, 24) */
(unhandled_input):
/* CIF PROCEDURECALL (974, 437), (142, 35) */
/* CIF PROCEDURECALL (1137, 402), (142, 35) */
call writeln('Lost input');
enddecision;
/* CIF return (626, 543), (35, 35) */
return ;
/* CIF return (799, 508), (35, 35) */
return call observer_status;
endprocedure;
/* CIF START (589, 96), (70, 35) */
/* CIF START (556, 96), (70, 35) */
START;
/* CIF NEXTSTATE (582, 151), (83, 35) */
/* CIF NEXTSTATE (549, 151), (83, 35) */
NEXTSTATE first_state;
/* CIF state (1169, 237), (97, 40) */
/* CIF state (864, 245), (97, 40) */
state fourth_state;
/* CIF provided (1121, 297), (193, 79) */
/* CIF provided (816, 305), (193, 79) */
provided output do_something(p)
from orchestrator
to another_function
/* CIF comment (1337, 308), (146, 56) */
/* CIF comment (1032, 316), (146, 56) */
comment 'intercept the output
and modify the value
of the parameter';
/* CIF decision (1182, 396), (70, 50) */
/* CIF decision (877, 404), (70, 50) */
decision p = 42;
/* CIF ANSWER (1117, 466), (70, 24) */
/* CIF ANSWER (812, 474), (70, 24) */
(true):
/* CIF task (1117, 510), (70, 35) */
/* CIF task (812, 518), (70, 35) */
task p := 99;
/* CIF NEXTSTATE (1109, 565), (85, 35) */
/* CIF NEXTSTATE (804, 573), (85, 35) */
NEXTSTATE fifth_state;
/* CIF ANSWER (1217, 466), (70, 24) */
/* CIF ANSWER (912, 474), (70, 24) */
(false):
/* CIF NEXTSTATE (1205, 510), (92, 35) */
NEXTSTATE unexpected;
/* CIF NEXTSTATE (900, 518), (92, 35) */
NEXTSTATE corrupted;
enddecision;
endstate;
/* CIF state (1371, 90), (88, 35) */
/* CIF state (868, 98), (88, 35) */
state third_state;
/* CIF input (1495, 147), (70, 35) */
input Foo (pr);
/* CIF output (1495, 202), (70, 35) */
output foo (pr);
/* CIF NEXTSTATE (1495, 252), (70, 35) */
NEXTSTATE -;
/* CIF provided (1132, 145), (173, 72) */
/* CIF provided (827, 153), (173, 72) */
provided output paramesstogui
from orchestrator;
/* CIF NEXTSTATE (1169, 237), (97, 40) */
/* CIF NEXTSTATE (864, 245), (97, 40) */
NEXTSTATE fourth_state;
endstate;
/* CIF state (1808, 437), (87, 35) */
/* CIF state (1208, 430), (87, 35) */
state sixth_state;
/* CIF provided (1792, 492), (121, 50) */
provided actual_val = 100;
/* CIF NEXTSTATE (1804, 562), (95, 35) */
NEXTSTATE end_success;
/* CIF provided (1192, 485), (121, 50) */
provided actual_val = 99;
/* CIF NEXTSTATE (1204, 555), (95, 35) */
NEXTSTATE corrupted;
endstate;
/* CIF state (1826, 88), (145, 57) */
/* CIF state (1226, 131), (145, 57) */
state fifth_state;
/* CIF provided (1806, 165), (184, 68) */
/* CIF provided (1206, 208), (184, 68) */
provided input do_something(val)
to another_function
/* CIF comment (2013, 163), (134, 72) */
comment 'intercept the input
before execution
(=post-output)
alter it again';
/* CIF decision (1848, 253), (99, 68) */
decision val = 99;
/* CIF ANSWER (1821, 343), (62, 24) */
(true):
/* CIF task (1805, 387), (93, 35) */
task val := val + 1;
/* CIF NEXTSTATE (1808, 437), (87, 35) */
to another_function;
/* CIF decision (1248, 296), (99, 68) */
decision val;
/* CIF ANSWER (1221, 386), (62, 24) */
(/= 42):
/* CIF NEXTSTATE (1208, 430), (87, 35) */
NEXTSTATE sixth_state;
/* CIF ANSWER (1937, 343), (70, 24) */
(false):
/* CIF NEXTSTATE (1925, 387), (92, 35) */
NEXTSTATE unexpected;
/* CIF ANSWER (1337, 386), (70, 24) */
else:
/* CIF NEXTSTATE (1325, 430), (92, 35) */
NEXTSTATE Good;
enddecision;
endstate;
/* CIF state (242, 314), (92, 35) */
state unexpected;
/* CIF state (230, 314), (92, 35) */
state corrupted;
endstate;
/* CIF state (266, 262), (95, 35) */
state end_success;
state good;
endstate;
/* CIF state (403, 394), (101, 34) */
/* CIF state (540, 392), (101, 34) */
state second_state;
/* CIF provided (335, 449), (239, 45) */
/* CIF provided (472, 447), (239, 45) */
provided st.orchestrator.magic_number = 42;
/* CIF NEXTSTATE (404, 514), (101, 35) */
/* CIF NEXTSTATE (541, 512), (101, 35) */
NEXTSTATE third_state;
endstate;
/* CIF state (404, 284), (101, 35) */
/* CIF state (541, 282), (101, 35) */
state Wait_count;
/* CIF provided (412, 339), (85, 35) */
provided count = 3
/* CIF comment (521, 336), (136, 56) */
comment 'Called immediately
if true';
/* CIF NEXTSTATE (403, 394), (101, 34) */
/* CIF provided (549, 337), (85, 35) */
provided count = 3;
/* CIF NEXTSTATE (540, 392), (101, 34) */
NEXTSTATE second_state;
endstate;
/* CIF state (582, 151), (83, 35) */
/* CIF state (549, 151), (83, 35) */
state first_state;
/* CIF provided (385, 208), (139, 56) */
/* CIF provided (522, 206), (139, 56) */
provided input pulse
to orchestrator
/* CIF comment (551, 216), (111, 40) */
/* CIF comment (688, 214), (111, 40) */
comment 'Called AFTER
the input';
/* CIF NEXTSTATE (404, 284), (101, 35) */
/* CIF NEXTSTATE (541, 282), (101, 35) */
NEXTSTATE Wait_count;
/* CIF provided (672, 206), (148, 40) */
provided unhandled input
pulse to orchestrator;
/* CIF NEXTSTATE (712, 266), (70, 35) */
NEXTSTATE -;
endstate;
endprocess my_observer;
endblock;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment