blob: 8e05a4e987d1c8c7f773b28eed0063ab51ec4c49 [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom 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());
}
}