blob: 47d4c3e6df6ee109e8bba1c2efbb367baadd1adf [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2017 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Lenard Nagy
* version R1A
******************************************************************************/
module SerialPortTests {
import from SerialPortTypes all;
const charstring str := "hello world\n";
type component SPSend {
port SerialPort SerialPort1;
timer t_short;
}
type component SPReceive {
port SerialPort SerialPort2;
timer t_short;
}
type component SP {
}
function f_send() runs on SPSend {
map(self:SerialPort1, system:SerialPort1);
log("Sending charstring: %s", str);
SerialPort1.send(str);
timer t; t.start(6.0); t.timeout;
unmap(self:SerialPort1, system:SerialPort1);
}
function f_receive() runs on SPReceive {
map(self:SerialPort2, system:SerialPort2);
log("Waiting for input...")
var charstring os_incoming;
t_short.start(6.0);
alt {
[] SerialPort2.receive(charstring:?) -> value os_incoming {
if (os_incoming == str) {
setverdict(pass,"message received on port: ", os_incoming);
} else {
log(os_incoming);
repeat;
//setverdict(fail,"message differs: %s", os_incoming);
}
}
[] t_short.timeout {
log("Timeout while waiting for input");
setverdict(inconc);
}
}
unmap(self:SerialPort2, system:SerialPort2);
}
testcase TC_SerialPortTestSend() runs on SP {
log("Starting SerialPort port tests");
var SPReceive c_receiver;
var SPSend c_sender;
c_receiver := SPReceive.create;
c_sender := SPSend.create;
c_receiver.start(f_receive());
c_sender.start( f_send());
timer t; t.start(6.0); t.timeout;
c_receiver.stop;
c_sender.stop;
}
control {
execute(TC_SerialPortTestSend());
}
}