Commit d0fe4b85 authored by Maxime Perrotin's avatar Maxime Perrotin

Add test case

parent db0741b8
include ../shared.mk
ROOT_MODEL=system_structure.pr
all: test-ada test-llvm
edit:
$(OPENGEODE) challenge.pr system_structure.pr
test-parse:
$(OPENGEODE) challenge.pr system_structure.pr --check
test-qgen-parse:
$(TESTQGEN_PARSE) $(ROOT_MODEL)
test-qgen-ada:
$(TESTQGEN_ADA) $(ROOT_MODEL)
test-qgen-c:
$(TESTQGEN_C) $(ROOT_MODEL)
test-qgen-gt-ada:
$(TESTQGEN_GT_ADA) $(ROOT_MODEL)
test-qgen-gt-c:
$(TESTQGEN_GT_C) $(ROOT_MODEL)
test-ada: dataview-uniq.o | test_ada.o
cp challenge_ri.ada challenge_ri.adb
$(OPENGEODE) challenge.pr system_structure.pr --toAda
mono $(ASN1SCC) -Ada -typePrefix asn1Scc -equal *.asn
gnat make challenge
$(GNATBIND) -n challenge.ali
$(GNATLINK) -o test_ada test_ada.o challenge.ali -lm
./test_ada | diff expected -
test-c: challenge.c test_c.o dataview-uniq.o
$(CC) -include missing.h challenge.c -c -o challenge.o
$(CC) test_c.o challenge.c dataview-uniq.o -lm -o test_c
./test_c | diff expected -
test-llvm: challenge.o dataview-uniq.o | test_llvm.o
$(CC) challenge.o dataview-uniq.o test_llvm.o -o test_llvm -lm
./test_llvm| diff expected -
coverage:
coverage run -p $(OPENGEODE) challenge.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
all:
gprbuild -p -P challenge.gpr # generate Ada code from the SDL model
gprbuild -p -P dataview_ada.gpr # generate Ada code from the ASN.1 model
gprbuild -p -P code/challenge_ada.gpr # build the Ada code
clean:
rm -rf obj code
\ No newline at end of file
project challenge is
for Languages use ("SDL");
for Source_Dirs use (".");
for Object_Dir use "code";
for Source_Files use ("challenge.pr");
package Naming is
for Body_Suffix ("SDL") use ".pr";
end Naming;
package Compiler is
for Driver ("SDL") use "opengeode";
for Object_File_Suffix ("SDL") use ".adb";
for Leading_Required_Switches ("SDL") use ("--toAda");
end Compiler;
end challenge;
\ No newline at end of file
/* CIF PROCESS (150, 150), (150, 75) */
process challenge;
state on;
substructure
in (via_toto);
out (ret0);
state hello;
substructure
/* CIF procedure (892, 436), (73, 35) */
procedure entry;
/* CIF START (178, 136), (70, 35) */
START;
/* CIF PROCEDURECALL (160, 186), (106, 35) */
call writeln('8');
/* CIF PROCEDURECALL (145, 236), (136, 35) */
call writeln('Hello!');
/* CIF return (195, 286), (35, 35) */
return ;
endprocedure;
/* CIF START (349, 133), (70, 35) */
START;
/* CIF NEXTSTATE (312, 183), (144, 35) */
NEXTSTATE wait_in_sub_hello;
/* CIF state (582, 147), (144, 35) */
state wait_in_sub_hello;
endstate;
endsubstructure;
/* CIF TEXT (294, 251), (334, 95) */
dcl myresult T_UInt8 := 4;
-- Use a variable with the same name as a variable
-- in the outer scope, to check that code generators
-- use the proper one
dcl result T_UInt32 := 9;
/* CIF ENDTEXT */
/* CIF procedure (606, 54), (73, 35) */
procedure entry
/* CIF comment (695, 31), (190, 88) */
comment 'Special Entry
procedure - called
automatically upon
entrance to the nested
state';
/* CIF START (191, 78), (70, 35) */
START;
/* CIF PROCEDURECALL (100, 128), (251, 35) */
call writeln('ENTERING NESTED STATE');
/* CIF return (208, 178), (35, 35) */
return ;
endprocedure;
/* CIF procedure (291, 522), (102, 35) */
procedure inner_proc;
/* CIF TEXT (31, 41), (364, 93) */
fpar in toto T_UInt8;
-- Redefine a variable declared in outer scope
dcl result t_Boolean := true;
/* CIF ENDTEXT */
/* CIF START (479, 97), (70, 35) */
START;
/* CIF label (471, 147), (86, 35) */
hey_joe:
/* CIF PROCEDURECALL (457, 197), (113, 35) */
call writeln('10');
/* CIF task (453, 247), (121, 35) */
task result := false;
/* CIF label (473, 297), (82, 35) */
leaving:
/* CIF return (496, 347), (35, 35) */
return ;
endprocedure;
/* CIF procedure (610, 143), (70, 33) */
procedure exit
/* CIF comment (700, 118), (157, 93) */
comment 'Special exit
procedure - called
automatically when
leaving the nested
state';
/* CIF START (163, 119), (70, 35) */
START;
/* CIF PROCEDURECALL (68, 169), (259, 35) */
call writeln('LEAVING the nested state');
/* CIF return (180, 219), (35, 35) */
return ;
endprocedure;
/* CIF START (1240, 7), (89, 35) */
START via_toto ;
/* CIF PROCEDURECALL (1232, 57), (106, 35) */
call writeln('3');
/* CIF return (1267, 107), (35, 35) */
return ret0;
/* CIF START (990, 8), (70, 35) */
START;
/* CIF PROCEDURECALL (972, 58), (106, 35) */
call writeln('7');
/* CIF label (970, 108), (111, 35) */
inside_label:
/* CIF PROCEDURECALL (957, 158), (137, 35) */
call pow(3,3, result);
/* CIF decision (988, 208), (74, 50) */
decision result;
/* CIF ANSWER (913, 278), (92, 24) */
(myresult):
/* CIF ANSWER (1037, 278), (70, 24) */
ELSE:
/* CIF task (1015, 318), (115, 35) */
task myresult := 5;
enddecision;
/* CIF label (981, 369), (88, 35) */
nslabel:
/* CIF NEXTSTATE (990, 419), (70, 35) */
NEXTSTATE hello;
/* CIF label (564, 472), (141, 35) */
connection another_floating:
/* CIF PROCEDURECALL (578, 522), (113, 35) */
call writeln('9');
/* CIF task (577, 572), (115, 35) */
task myresult := 1;
/* CIF PROCEDURECALL (553, 622), (164, 35) */
call inner_proc(myresult);
/* CIF return (617, 672), (35, 35) */
return ;
/* CIF End Label */
endconnection;
/* CIF label (184, 324), (90, 35) */
connection to_label:
/* CIF join (212, 374), (35, 35) */
join another_floating;
/* CIF End Label */
endconnection;
/* CIF state (52, 0), (70, 35) */
state hello;
/* CIF input (52, 61), (70, 35) */
input run;
/* CIF PROCEDURECALL (0, 111), (175, 35) */
call writeln('27 == ', result);
/* CIF PROCEDURECALL (52, 161), (70, 35) */
call toto;
/* CIF task (25, 211), (125, 53) */
task myresult := 88,
result := 33;
/* CIF join (70, 279), (35, 35) */
join to_label;
endstate;
endsubstructure;
/* CIF TEXT (506, 0), (298, 56) */
-- This system tests nested states
dcl result T_uint32 :=0;
/* CIF ENDTEXT */
/* CIF procedure (24, 247), (66, 35) */
procedure toto;
/* CIF TEXT (371, 134), (298, 140) */
-- Declare your variables
-- Syntax: DCL <variable name> <type name>;
dcl i T_Int8 := 1;
/* CIF ENDTEXT */
/* CIF START (178, 86), (70, 35) */
START;
/* CIF decision (178, 136), (70, 50) */
decision i;
/* CIF ANSWER (131, 206), (73, 24) */
(1):
/* CIF task (96, 246), (143, 35) */
task i := (i + 1) mod 127;
/* CIF return (150, 296), (35, 35) */
return ;
/* CIF ANSWER (249, 206), (70, 24) */
ELSE:
/* CIF PROCEDURECALL (249, 246), (70, 35) */
call foo;
/* CIF return (266, 296), (35, 35) */
return ;
enddecision;
endprocedure;
/* CIF procedure (19, 183), (70, 35) */
procedure foo;
/* CIF START (190, 53), (70, 35) */
START;
/* CIF return (207, 103), (35, 35) */
return ;
endprocedure;
/* CIF START (526, 99), (68, 37) */
START;
/* CIF PROCEDURECALL (507, 151), (106, 35) */
call writeln('1');
/* CIF NEXTSTATE (525, 201), (70, 35) */
NEXTSTATE OFF;
/* CIF state (496, 356), (132, 35) */
state on via via_toto
/* CIF comment (694, 369), (219, 33) */
comment 'Enter substate via entry point';
/* CIF connect (527, 411), (70, 35) */
connect ;
/* CIF NEXTSTATE (527, 466), (70, 35) */
NEXTSTATE OFF;
endstate;
/* CIF state (525, 201), (70, 35) */
state OFF;
/* CIF input (527, 256), (70, 35) */
input run;
/* CIF PROCEDURECALL (509, 306), (106, 35) */
call writeln('2');
/* CIF NEXTSTATE (496, 356), (132, 35) */
NEXTSTATE on via via_toto
/* CIF comment (694, 369), (219, 33) */
comment 'Enter substate via entry point';
endstate;
/* CIF state (1000, 72), (65, 35) */
state on;
/* CIF input (1192, 127), (88, 35) */
input any_one;
/* CIF NEXTSTATE (1180, 177), (113, 35) */
NEXTSTATE -;
/* CIF input (1302, 127), (78, 35) */
input go_off;
/* CIF NEXTSTATE (1310, 177), (62, 35) */
NEXTSTATE OFF;
/* CIF connect (1033, 127), (0, 35) */
connect ret0;
/* CIF PROCEDURECALL (980, 177), (106, 35) */
call writeln('4');
/* CIF NEXTSTATE (1000, 227), (67, 35) */
NEXTSTATE Safe;
/* CIF connect (717, 127), (0, 35) */
connect ;
/* CIF PROCEDURECALL (644, 177), (147, 35) */
call writeln('11 (end)');
/* CIF PROCEDURECALL (682, 227), (70, 35) */
call toto;
/* CIF NEXTSTATE (682, 277), (70, 35) */
NEXTSTATE off;
endstate;
/* CIF state (156, 285), (73, 35) */
state Safe;
/* CIF input (101, 340), (70, 35) */
input *;
/* CIF PROCEDURECALL (83, 390), (106, 35) */
call writeln('5');
/* CIF PROCEDURECALL (71, 440), (130, 35) */
call pow(2,2, result);
/* CIF PROCEDURECALL (52, 490), (168, 35) */
call writeln('4 == ', result);
/* CIF NEXTSTATE (101, 540), (70, 35) */
NEXTSTATE -;
/* CIF input (296, 340), (88, 35) */
input any_one;
/* CIF PROCEDURECALL (283, 390), (113, 35) */
call writeln('6');
/* CIF NEXTSTATE (305, 440), (70, 35) */
NEXTSTATE on;
endstate;
endprocess challenge;
\ No newline at end of file
[General]
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0Y\0\0\0\0\0\0\x4Q\0\0\x3\x5\0\0\0\\\0\0\0\x1d\0\0\x4N\0\0\x3\x2\0\0\0\0\0\0\0\0\a\x80)
windowState=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\x1\0\0\x1\x12\0\0\x1\xfb\xfc\x2\0\0\0\x1\xfc\0\0\0<\0\0\x1\xfb\0\0\0\x87\x1\0\0\x1b\xfa\0\0\0\x1\x2\0\0\0\x2\xfb\0\0\0\x1c\0\x64\0\x61\0t\0\x61\0t\0y\0p\0\x65\0s\0_\0\x64\0o\0\x63\0k\x1\0\0\0\0\xff\xff\xff\xff\0\0\0k\0\xff\xff\xff\xfb\0\0\0\x1a\0\x64\0\x61\0t\0\x61\0\x64\0i\0\x63\0t\0_\0\x64\0o\0\x63\0k\x1\0\0\0\0\xff\xff\xff\xff\0\0\0k\0\xff\xff\xff\0\0\0\x3\0\0\x3\xc0\0\0\0\x8c\xfc\x1\0\0\0\x1\xfb\0\0\0\xe\0m\0s\0g\0\x44\0o\0\x63\0k\x1\0\0\0\x33\0\0\x3\xc0\0\0\0\x46\0\a\xff\xff\0\0\x2\xa8\0\0\x1\xfb\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x2\0\0\0\0\0\0\0\x1\0\0\0\x16\0S\0\x44\0L\0 \0T\0o\0o\0l\0\x62\0\x61\0r\x3\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x2\0\0\0\x1\0\0\0\x18\0\x46\0i\0l\0\x65\0 \0T\0o\0o\0l\0\x62\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
BitString ::= BIT STRING (SIZE(32))
OctString ::= OCTET STRING (SIZE(4))
SeqBit ::= SEQUENCE (SIZE(32)) OF BOOLEAN
SeqBit2 ::= SEQUENCE (SIZE(1..32)) OF BOOLEAN
END
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
challenge T-UInt32 ::= 18
bound T-UInt32 ::= 1000000
nb-bit T-UInt32 ::= 20
val-max T-UInt32 ::= 1048575
count-max T-UInt32 ::= 524288
exceed-nb T-UInt32 ::= 48575
CountTab ::= SEQUENCE (SIZE(nb-bit)) OF T-UInt32
END
project DataView_c is
for Languages use ("ASN1");
for Source_Dirs use (".");
for Source_Files use ("dataview-uniq.asn");
for Object_Dir use "code";
package Naming is
for Body_Suffix ("ASN1") use ".asn";
end Naming;
package Compiler is
for Driver ("ASN1") use "asn1.exe";
for Leading_Required_Switches ("ASN1") use ("-c", "-typePrefix", "Asn1Scc");
end Compiler;
end DataView_c;
\ No newline at end of file
1
2
ENTERING NESTED STATE
3
LEAVING the nested state
4
5
4 == 4
6
ENTERING NESTED STATE
7
8
Hello!
27 == 27
9
10
LEAVING the nested state
11 (end)
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM challenge;
PROCEDURE pow COMMENT '#c_predef';
FPAR
IN a T_UInt32,
IN b T_UInt32,
OUT res T_UInt32;
EXTERNAL;
SIGNAL run;
SIGNAL go_off;
SIGNAL any_one;
signal any_two;
CHANNEL c
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
ENDCHANNEL;
BLOCK challenge;
SIGNALROUTE r
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
CONNECT c and r;
PROCESS challenge REFERENCED;
ENDBLOCK;
ENDSYSTEM;
-- Stub generated by OpenGEODE.
-- You can edit this file, it will not be overwritten
package body myfunction_RI is
procedure result_data (titi : in out asn1SccT_Int32) is
procedure Result_Data (Titi : in out asn1SccT_Int32)
with Import, Convention => C, Link_Name => "myfunction_RI_result_data";
begin
Result_Data (Titi);
end Result_Data;
procedure SET_myTimer (Val : in out asn1SccT_UInt32) is
procedure SET_myTimer (Val : in out asn1SccT_UInt32)
with Import, Convention => C, Link_Name => "myfunction_RI_SET_myTimer";
begin
Set_myTimer (Val);
end Set_myTimer;
procedure RESET_myTimer is
procedure RESET_myTimer
with Import, Convention => C, Link_Name => "myfunction_RI_RESET_myTimer";
begin
RESET_myTimer;
end RESET_myTimer;
end myfunction_RI;
Markdown is supported
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