remsim: Move PIPEasp generic helper code to library/PIPEasp_Templates.ttcn

This way code can be used and extended for other testsuites.

Change-Id: I4a5ededbd958c87537f84155092b6a6cd715865a
This commit is contained in:
Pau Espin 2024-05-15 14:36:53 +02:00
parent a2812ec0da
commit 5badb2191d
3 changed files with 30 additions and 22 deletions

View File

@ -0,0 +1,27 @@
module PIPEasp_Templates {
import from PIPEasp_PortType all;
import from PIPEasp_Types all;
template (value) ASP_PExecuteBackground ts_ExecBg(charstring cmd) := {
command := cmd
}
template (present) ASP_PStdout tr_Stdout(template (present) charstring line) := {
stdout := line
}
template (present) ASP_PStderr tr_Stderr(template (present) charstring line) := {
stderr := line
}
template (value) ASP_PStdin ts_Stdin(template (value) charstring line) := {
stdin :=line
}
/* Ignore output from stderr: */
altstep as_ignore_stderr(PIPEasp_PT pt) {
[] pt.receive(tr_Stderr(?)) { repeat; }
}
}

View File

@ -20,6 +20,7 @@ import from Misc_Helpers all;
/* the PIPEasp port allows us to interact with osmo-remsim-client-shell via stdin/stdout */
import from PIPEasp_PortType all;
import from PIPEasp_Types all;
import from PIPEasp_Templates all;
import from RSPRO all;
import from RSPRO_Types all;
@ -196,34 +197,13 @@ testcase TC_bank_disconnect_reconnect() runs on client_test_CT {
* Tests interacting with local remsim-bankd-client via PIPE port
***********************************************************************/
template (value) ASP_PExecuteBackground ts_ExecBg(charstring cmd) := {
command := cmd
}
template (present) ASP_PStdout tr_Stdout(template (present) charstring line) := {
stdout := line
}
template (present) ASP_PStderr tr_Stderr(template (present) charstring line) := {
stderr := line
}
template (value) ASP_PStdin ts_Stdin(template (value) charstring line) := {
stdin :=line
}
/* osmo-remsim-client logs to stderr, so we need to ignore that log output */
private altstep as_ignore_stderr() runs on client_test_CT {
[] PIPE.receive(tr_Stderr(?)) { repeat; }
}
/* start a local osmo-remsim-client as sub-process and attach it to PIPE port */
private function f_init_client_pipe(ClientSlot cs) runs on client_test_CT {
var charstring cmdline := mp_client_shell_cmd & " -i 127.0.0.1";
map(self:PIPE, system:PIPE);
PIPE.send(ts_ExecBg(cmdline & " -c " & int2str(cs.clientId)
& " -n " & int2str(cs.slotNr)));
activate(as_ignore_stderr());
activate(as_ignore_stderr(PIPE));
}
/* pretty-print an octet string as series of ASCII encoded hex bytes with spaces */

View File

@ -39,6 +39,7 @@ gen_links $DIR $FILES
DIR=../library
FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn Osmocom_Types.ttcn "
FILES+="PIPEasp_Templates.ttcn "
FILES+="IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp IPA_CodecPort.ttcn " #RSL_Types.ttcn RSL_Emulation.ttcn "
FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
FILES+="Native_Functions.ttcn Native_FunctionDefs.cc "