Commit c4cdd89b authored by Maxime Perrotin's avatar Maxime Perrotin

Add Demo_Ada_GUI to kazoo regression suite

parent 463b5885
This diff is collapsed.
DataView DEFINITIONS AUTOMATIC TAGS ::= BEGIN
Display-T ::= OCTET STRING (SIZE (1..255))
Action-T ::= CHOICE
{
--display INTEGER (0..255),
display Display-T,
other-action INTEGER (0..1),
housekeeping Destination-T
}
Destination-T ::= ENUMERATED { displayer(0), other-dest(1) }
TC-T ::= SEQUENCE
{
destination Destination-T,
action Action-T DEFAULT display:'48656C6C6F'H
}
TM-T ::= Display-T
HK-T ::= SEQUENCE {
value-to-plot INTEGER (0..16535) DEFAULT 42,
destination Destination-T
}
END
---------------------------------------------------
-- AADL2.0
-- TASTE
-- (c)Ellidiss Technologies
--
---------------------------------------------------
PACKAGE deploymentview::DV::Node1
PUBLIC
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS mypartition
END mypartition;
PROCESS IMPLEMENTATION mypartition.others
END mypartition.others;
END deploymentview::DV::Node1;
PACKAGE deploymentview::DV
PUBLIC
WITH ocarina_processors_x86;
WITH deploymentview::DV::Node1;
WITH Taste;
WITH Deployment;
WITH interfaceview::IV;
WITH TASTE_DV_Properties;
SYSTEM Node1
END Node1;
SYSTEM IMPLEMENTATION Node1.others
SUBCOMPONENTS
IV_mygui : SYSTEM interfaceview::IV::mygui.others {
Taste::coordinates => "1036 964 1318 1257";
Taste::FunctionName => "mygui";
};
IV_router : SYSTEM interfaceview::IV::router.others {
Taste::coordinates => "1462 985 1842 1257";
Taste::FunctionName => "router";
};
IV_displayer : SYSTEM interfaceview::IV::displayer.others {
Taste::coordinates => "1621 1323 2057 1498";
Taste::FunctionName => "displayer";
};
mypartition : PROCESS deploymentview::DV::Node1::mypartition.others {
Taste::coordinates => "849 755 2208 1562";
Deployment::Port_Number => 0;
};
x86_linux32 : PROCESSOR ocarina_processors_x86::x86.linux {
Taste::coordinates => "679 524 2378 1677";
};
PROPERTIES
Taste::APLC_Binding => (reference (mypartition)) APPLIES TO IV_mygui;
Taste::APLC_Binding => (reference (mypartition)) APPLIES TO IV_router;
Taste::APLC_Binding => (reference (mypartition)) APPLIES TO IV_displayer;
Actual_Processor_Binding => (reference (x86_linux32)) APPLIES TO mypartition;
END Node1.others;
SYSTEM deploymentview
END deploymentview;
SYSTEM IMPLEMENTATION deploymentview.others
SUBCOMPONENTS
Node1 : SYSTEM Node1.others {
Taste::coordinates => "467 195 2590 1842";
};
interfaceview : SYSTEM interfaceview::IV::interfaceview.others;
END deploymentview.others;
PROPERTIES
Taste::coordinates => "0 0 2970 2100";
Taste::version => "1.3.17";
Taste::interfaceView => "InterfaceView.aadl";
Taste::HWLibraries => ("~/tool-inst/share/ocarina/AADLv2/ocarina_components.aadl");
END deploymentview::DV;
This diff is collapsed.
KAZOO=../../kazoo
all: c
ada: test-parse-ada
make -C output.ada && \
cp displayer/displayer.adb output.pohic/displayer/Ada/src
cp router/router.adb output.pohic/router/Ada/src
cd output.ada/build && \
ocarina -x main.aadl && \
make -f Makefile.taste
c: test-parse-c # Polyorb_HI_C output
cp displayer/displayer.adb output.pohic/displayer/Ada/src
cp router/router.adb output.pohic/router/Ada/src
make -C output.pohic
test-parse-ada: clean-ada
$(KAZOO) --gw \
-o output.ada \
--glue \
--debug
test-parse-c: clean-c
$(KAZOO) -p --gw \
-o output.pohic \
--glue
buildsupport_pohic:
buildsupport -o output.buildsupport.pohic -p --aadlv2 --glue -i InterfaceView.aadl -c DeploymentView.aadl -d DataView.aadl ../common/ocarina_components.aadl ../common/TASTE_IV_Properties.aadl ../common/TASTE_DV_Properties.aadl
buildsupport_pohiada:
buildsupport -o output.buildsupport.ada --aadlv2 --glue -i InterfaceView.aadl -c DeploymentView.aadl -d DataView.aadl ../common/ocarina_components.aadl ../common/TASTE_IV_Properties.aadl ../common/TASTE_DV_Properties.aadl
gdb: clean
gdb --args $(KAZOO) --gw \
-o output.pohic \
--glue \
--debug
clean-ada:
rm -rf output.ada
clean-c:
rm -rf output.pohic
skeletons:
$(KAZOO) -p --gw --glue -o code && make -C code dataview
clean-skeletons:
rm -rf code
clean: clean-ada clean-c clean-skeletons
.PHONY: clean clean-ada clean-c test-parse-ada gdb test-parse-c buildsupport_pohic buildsupport_pohiada c skeletons clean-skeletons
Demo_Ada_GUI
This demo tests a system containing two Ada functions and a GUI.
All the blocks exchange data.
The runtime target is Linux with C runtime
This test is also used to validate the MSC plugin and Python scripts.
Once built, run test.with.python.sh
#!/usr/bin/env python
#
# Automatically generated Python sequence chart (MSC) implementation
import os
import sys
import signal
import Queue
taste_inst = os.popen('taste-config --prefix').readlines()[0].strip()
sys.path.append(taste_inst+'/share/asn1-editor')
from Scenario import Scenario, PollerThread
from PySide.QtCore import QCoreApplication, Qt
from udpcontroller import tasteUDP
# Generated due to "mygui_trace_201604071040.msc"
# From the section: MSCDOCUMENT automade
@Scenario
def Exercise_mygui(queue):
'''mygui processing'''
queue.sendMsg('router_put_tc', '{ action display:"Hello", destination displayer }', lineNo=11)
try:
queue.expectMsg('gui_send_tm', '"Hello"', lineNo=12, timeout=3, ignoreOther=False)
except TypeError as err:
raise
return 0
def runScenario(pipe_in=None, pipe_out=None, udpController=None):
# Queue for getting scenario status
log = Queue.Queue()
if udpController:
mygui = Exercise_mygui(log, name='Scenario')
udpController.slots.append(mygui.msq_q)
mygui.wait()
udpController.slots.remove(mygui.msg_q)
return 0 # mygui.status
else:
# Use old-style message queue
poller = PollerThread()
mygui = Exercise_mygui(log, name='Scenario')
poller.slots.append(mygui.msg_q)
poller.start()
mygui.start()
# Wait and log messages from both scenarii
while True:
try:
scenario, severity, msg = log.get(block=False)
except Queue.Empty:
pass
else:
log.task_done()
try:
# If called from the GUI, send log through pipe
pipe_out.send((scenario, severity, msg))
except AttributeError:
print('[{level}] {name} - {msg}'.format
(level=severity, name=scenario, msg=msg))
if severity == 'ERROR' or msg == 'END':
# Stop execution on first error or completed scenario
ret = 1 if severity == 'ERROR' else 0
try:
pipe_out.send(('All', 'COMMAND', 'END'))
except AttributeError:
mygui.stop()
poller.stop()
return ret
try:
if pipe_out.poll():
cmd = pipe_out.recv()
if cmd == 'STOP':
mygui.stop()
poller.stop()
return 0
except AttributeError:
pass
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)
udpController = None
if '--udp' in sys.argv:
# Create UDP Controller with default IP/Port values (127.0.0.1:7755:7756)
udpController = tasteUDP()
QCoreApplication(sys.argv)
sys.exit(runScenario(udpController))
-- User implementation of the displayer function
-- This file will never be overwritten once edited and modified
-- Only the interface of functions is regenerated (in the .ads file)
--pragma Profile (Ravenscar);
pragma Style_Checks (off);
pragma Warnings (off);
with dataview; use dataview;
with adaasn1rtl; use adaasn1rtl;
with ada.Integer_Text_IO; use ada.Integer_Text_IO;
with ada.Long_Float_Text_IO; use ada.Long_Float_Text_IO;
with system.io; use system.io;
with Interfaces; use Interfaces;
with Ada.Interrupts, Ada.Interrupts.Names;
use Ada.Interrupts, Ada.Interrupts.Names;
package body displayer is
type A_String is access String;
Person : asn1Scctm_t;
S : A_String;
bTmHasArrived : Boolean;
Number : asn1SccHK_T_value_to_plot := 0;
HK : aliased asn1SccHK_T;
-- Add a signal handler: use " pkill -usr1 mypartition " to trigger it
-- it works with both pohic and pohiada
package Sigusr1_Handler is
protected Handler is
procedure Handle;
pragma Interrupt_Handler (Handle);
pragma Attach_Handler (Handle, Sigusr1);
end Handler;
end Sigusr1_Handler;
package body Sigusr1_Handler is
protected body Handler is
procedure Handle is
begin
System.IO.Put_Line ("Got interrupt!");
end Handle;
end Handler;
end Sigusr1_Handler;
procedure Displayer_Put_TC (TC : in out asn1SccTC_T) is
begin
case TC.Action.Kind is
when Display_PRESENT =>
for J in 1 .. TC.Action.Display.Length loop
person.data (J) := TC.Action.Display.Data (J);
end loop;
Person.Length := TC.Action.Display.Length;
if (person.length > 0) then
bTmHasArrived := True;
end if;
when housekeeping_PRESENT =>
HK :=
(Exist => (Value_To_Plot => 1), Value_To_Plot => Number,
Destination => TC.Action.Housekeeping);
HousekeepingTM (HK);
when others =>
null;
end case;
end Displayer_Put_TC;
procedure cyclicdisplayer is
My_TM : aliased asn1Scctm_t;
I : Integer;
begin
System.IO.Put_Line ("cyclicdisplayer");
if bTmHasArrived then
for i in 1 .. Person.Length loop
My_TM.Data (i) := Person.Data (i);
end loop;
My_TM.Length := Person.Length;
router_send_tm (My_TM);
end if;
Number := (Number + 1) mod 16535;
end cyclicdisplayer;
begin
system.io.put_line ("init of displayer done");
person := asn1SccTM_T_Init;
bTmHasArrived := False;
end displayer;
#!/usr/bin/env python
import sys, os, time, pexpect, subprocess
sys.path.append(os.path.abspath(".."))
import commonRegression
timeout = 15
expected = [
["init of displayer done", "init of router done"],
["init of displayer done", "init of router done"],
"cyclicdisplayer",
"cyclicdisplayer"
]
result=commonRegression.test(
["binary.linux.pohiada/binaries/mypartition"],
expected,
timeout)
if 0!=result:
sys.exit(1)
commonRegression.g_child.terminate(force=True)
result=commonRegression.test(
["binary.linux.pohic/binaries/mypartition"],
expected,
timeout)
if 0!=result:
sys.exit(1)
commonRegression.g_child.terminate(force=True)
# Stop here when running under CircleCI - the LXC containers
# don't allow us to modify the mqueue settings, and the
# rest of the tests fail.
if os.getenv("CIRCLECI") is not None:
sys.exit(0)
binaries2 = [
"python Test_TM_TC_with_Demo_Ada.py"
]
expected2 = [
"Invoking TC",
'{ destination displayer , action display: "abc1" }',
"Received Telemetry: gui_send_tm",
"Parameter tm:",
"abc1",
"Received Telemetry: gui_send_tm",
"Parameter tm:",
"abc1"
]
def VerifyTM(binary):
print "Verifying TMs sent by", binary
p = None
try:
p = subprocess.Popen(binary, stdout=subprocess.PIPE)
if p == None:
sys.exit(1)
except:
sys.exit(1)
os.system("cp Test_TM_TC_with_Demo_Ada.py binary.linux.pohiada/GlueAndBuild/gluemygui/python/")
os.chdir("binary.linux.pohiada/GlueAndBuild/gluemygui/python")
result2=commonRegression.test(binaries2, expected2, timeout)
p.kill()
p.wait()
os.chdir("../../../../")
if 0!=result2:
sys.exit(1)
VerifyTM("binary.linux.pohiada/binaries/mypartition")
VerifyTM("binary.linux.pohic/binaries/mypartition")
-- User implementation of the router function
-- This file will never be overwritten once edited and modified
-- Only the interface of functions is regenerated (in the .ads file)
pragma style_checks (off);
pragma warnings (off);
with adaasn1rtl;
use adaasn1rtl;
with dataview;
use dataview;
with system.io;
package body router is
---------------------------------------------------------
-- Provided interface "router_put_tc"
---------------------------------------------------------
procedure router_put_tc(tc: in out asn1SccTC_T) is
begin
displayer_put_tc(tc);
end router_put_tc;
---------------------------------------------------------
-- Provided interface "router_send_tm"
---------------------------------------------------------
procedure router_send_tm(tm: in out asn1SccTM_T) is
begin
gui_send_tm(tm);
end router_send_tm;
begin
system.io.put_line ("init of router done");
end router;
#!/bin/bash
if [ ! -d output.pohic/binaries/ ] ; then
echo Build first - invoke make
exit 1
fi
echo Run
echo " " export ASSERT_IGNORE_GUI_ERRORS=1
echo from another shell, and hit ENTER - Stop the test with Ctrl-C
read ANS
cp Test_TM_TC_Demo_Ada_GUI_2.py output.pohic/binaries/mygui_GUI/
# Test C version
cd output.pohic/binaries/mygui_GUI/
../mypartition &
python Test_TM_TC_Demo_Ada_GUI_2.py
pkill mypartition
cd -
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