Commit f5a48259 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add test case (system without CIF comments)

parent 58fad042
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) orchestrator.pr system_structure.pr
test-parse:
$(OPENGEODE) orchestrator.pr system_structure.pr --check
test-ada: orchestrator.ali dataview-uniq.o | test_ada.o
$(GNATBIND) -n orchestrator.ali
$(GNATLINK) -o test_ada test_ada.o orchestrator.ali -lgnat
./test_ada
test-llvm: orchestrator.o
test-python:
$(OPENGEODE) orchestrator.pr system_structure.pr --shared
$(ASN1SCC) -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
$(GNATMAKE) -O$(O) -c *.adb
$(GNATBIND) -n -Lliborchestrator orchestrator
$(GNATMAKE) -c b~orchestrator.adb
$(CC) -shared -o liborchestrator.so b~orchestrator.o orchestrator.o taste_basictypes.o adaasn1rtl.o -lgnat
python -c "from ctypes import *; test=CDLL('./liborchestrator.so'); test.liborchestratorinit()"
coverage:
coverage run -p $(OPENGEODE) orchestrator.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
TASTE-Peek-id ::= INTEGER (0..4294967295)
TASTE-Peek-id-list ::= SEQUENCE (SIZE (1..10)) OF TASTE-Peek-id
VariableString ::= OCTET STRING (SIZE (1..10))
FixedString ::= OCTET STRING (SIZE (5))
SeqBool ::= SEQUENCE (SIZE(1..5)) OF BOOLEAN
SeqBoolFix ::= SEQUENCE (SIZE(2)) OF BOOLEAN
SeqEnum ::= SEQUENCE (SIZE(1..5)) OF ENUMERATED { hello2, world2 }
SeqEnumFix ::= SEQUENCE (SIZE(2)) OF ENUMERATED { hello, world }
MyEnum ::= ENUMERATED {a, b, c, d, eE}
MyChoice ::= CHOICE {c1 BOOLEAN, cDe2 BOOLEAN}
SeqOpt ::= SEQUENCE { a BOOLEAN OPTIONAL , b BOOLEAN, c SEQUENCE { a BOOLEAN } OPTIONAL, d OCTET STRING (SIZE (0..10)) OPTIONAL}
SeqNonOpt ::= SEQUENCE { a BOOLEAN }
END
PROCESS orchestrator
COMMENT 'Hello';
/* CIF TEXT (0, 94), (398, 293) */
dcl seq tastE_Peek_id_list;
dcl fixed FixedString := 'Hello';
dcl variable VariableString := 'Hello';
dcl seqboolean SeqBool := { true, false };
dcl seqbool2 SeqBoolFix := { true, false };
dcl seqen SeqEnum := { hello2, world2};
dcl seqen2 SeqEnumFix := { hello, world };
dcl myenum MyEnum := a;
dcl check tasTE_Peek_id;
dcl choice Mychoice;
dcl opt SeqOpt := { A TRUE, b FALSE }; -- test optional fields
/* CIF ENDTEXT */
PROCEDURE emptyproc;
ENDPROCEDURE;
PROCEDURE numProc;
START;
DECISION num(myenum);
else:
ENDDECISION;
DECISION num(myenum);
else:
ENDDECISION;
RETURN ;
ENDPROCEDURE;
START;
TASK opt := { B TRUE }
COMMENT 'Test optional fields';
DECISION num(myenum);
(0):
else:
ENDDECISION;
DECISION num(myenum);
(0):
else:
ENDDECISION;
DECISION 'informal'
COMMENT 'Informal decision -
check that it is ignored
by the code generator';
('a'):
('2'):
ENDDECISION;
TASK seqboolean := {true, false},
seqboolean := not {true, false};
TASK for x in seqen:
call writeln(num(x));
call writeln(num(myenum));
call writeln(num(myenum));
endfor
COMMENT 'Check that num is not
declared twice';
TASK for x in seqen2:
call writeln(num(x));
endfor;
TASK for x in seqboolean:
call writeln(x);
endfor
COMMENT 'FOR with a basic type';
TASK seqboolean := not seqboolean
COMMENT 'check NOT on a SEQUENCE of BOOLEAN';
TASK for x in seqboolean:
call writeln(x);
endfor;
TASK fixed := 'hello';
TASK variable := 'HELLO';
CALL writeln(variable // '!!!');
CALL writeln(variable // variable // variable);
TASK seq := {1};
TASK seq := {1} // {2} // {3};
TASK seq := seq // {2} // {1};
DECISION any;
('a'):
('b'):
ENDDECISION;
DECISION myenum
COMMENT 'Check case insensitivity';
(a):
(B):
(c):
(d):
(Ee):
ENDDECISION;
DECISION present(choice)
COMMENT 'Check case insensitivity';
(cde2):
ELSE:
ENDDECISION;
NEXTSTATE Wait_for_GUI;
STATE Third;
INPUT pulse(myenum);
NEXTSTATE Wait_for_gui;
ENDSTATE;
STATE AnotherState;
INPUT pulse(myenum);
NEXTSTATE Third;
ENDSTATE;
STATE Wait_for_GUI;
INPUT pulse(myenum);
CALL writeln('Got PULSE', num(myenum));
OUTPUT telemetry(myenum);
NEXTSTATE AnotherState;
ENDSTATE;
ENDPROCESS orchestrator;
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM orchestrator;
SIGNAL pulse(myenum);
SIGNAL telemetry(myenum);
CHANNEL c
FROM ENV TO orchestrator WITH pulse;
FROM orchestrator TO ENV WITH telemetry;
ENDCHANNEL;
BLOCK orchestrator;
SIGNALROUTE r
FROM ENV TO orchestrator WITH pulse;
FROM orchestrator TO ENV WITH telemetry;
CONNECT c and r;
PROCESS orchestrator REFERENCED;
ENDBLOCK;
ENDSYSTEM;
#include <math.h>
#include <stdio.h>
#include "dataview-uniq.h"
extern void adainit();
void orchestrator_RI_telemetry(void *_){}
void orchestrator_RI_S_SET_GNC_LV_SIM_CONTEXT_FOR_NEXT_MAJOR_CYCLE(void *_){}
void orchestrator_RI_Scheduler(void *_){}
void orchestrator_RI_VESAT_Simulation_Step(void *_){}
void orchestrator_RI_plot(void *_) {}
void orchestrator_RI_S_JUMP_TO_NEXT_MAJOR_CYCLE() {}
void orchestrator_RI_S_GET_GNC_LV_SIM_INPUTS_FOR_NEXT_MAJOR_CYCLE(void *_){}
int main()
{
printf("[C Code] Running test\n");
adainit();
return 0;
}
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