forked from ttcn3/osmo-ttcn3-hacks
Test.ttcn: Add support for telnet interaction on VTY
This commit is contained in:
parent
b622a3dcc2
commit
9a907b37b5
|
@ -0,0 +1,20 @@
|
||||||
|
[LOGGING]
|
||||||
|
|
||||||
|
[MODULE_PARAMETERS]
|
||||||
|
|
||||||
|
[TESTPORT_PARAMETERS]
|
||||||
|
*.BSCVTY.CTRL_MODE := "client"
|
||||||
|
*.BSCVTY.CTRL_HOSTNAME := "127.0.0.1"
|
||||||
|
*.BSCVTY.CTRL_PORTNUM := "4242"
|
||||||
|
*.BSCVTY.CTRL_LOGIN_SKIPPED := "yes"
|
||||||
|
*.BSCVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"
|
||||||
|
*.BSCVTY.CTRL_READMODE := "buffered"
|
||||||
|
*.BSCVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
|
||||||
|
*.BSCVTY.PROMPT1 := "OpenBSC> "
|
||||||
|
#*.BSCVTY.PROMPT2 := "OpenBSC# "
|
||||||
|
#*.BSCVTY.REGEX_PROMPT1 := "^OpenBSC.*$"
|
||||||
|
|
||||||
|
|
||||||
|
[MAIN_CONTROLLER]
|
||||||
|
|
||||||
|
[EXECUTE]
|
|
@ -3,6 +3,7 @@ module Test {
|
||||||
import from GSMTAP_Types all;
|
import from GSMTAP_Types all;
|
||||||
import from GSMTAP_PortType all;
|
import from GSMTAP_PortType all;
|
||||||
import from IPL4_GSMTAP_CtrlFunct all;
|
import from IPL4_GSMTAP_CtrlFunct all;
|
||||||
|
import from TELNETasp_PortType all;
|
||||||
|
|
||||||
const octetstring si1 := '5506198fb38000000000000000000000000000e504002b'O;
|
const octetstring si1 := '5506198fb38000000000000000000000000000e504002b'O;
|
||||||
const octetstring si2 := '59061a00000000000000000000000000000000ffe50400'O;
|
const octetstring si2 := '59061a00000000000000000000000000000000ffe50400'O;
|
||||||
|
@ -11,6 +12,7 @@ module Test {
|
||||||
|
|
||||||
type component dummy_CT {
|
type component dummy_CT {
|
||||||
port GSMTAP_PT GSMTAP;
|
port GSMTAP_PT GSMTAP;
|
||||||
|
port TELNETasp_PT BSCVTY;
|
||||||
};
|
};
|
||||||
|
|
||||||
testcase TC_si1() runs on dummy_CT {
|
testcase TC_si1() runs on dummy_CT {
|
||||||
|
@ -73,8 +75,89 @@ module Test {
|
||||||
log("SI: ", dec_SystemInformation(rf.msg.payload));
|
log("SI: ", dec_SystemInformation(rf.msg.payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* permitted prompts on VTY */
|
||||||
|
const charstring NORMAL_PROMPT := "OpenBSC> ";
|
||||||
|
const charstring ENABLE_PROMPT := "OpenBSC# ";
|
||||||
|
const charstring CONFIG_PROMPT := "OpenBSC(*)\#";
|
||||||
|
|
||||||
|
const ASP_TelnetDynamicConfig vty_prompt[3] := {
|
||||||
|
{
|
||||||
|
prompt := {
|
||||||
|
id := 1,
|
||||||
|
prompt := NORMAL_PROMPT,
|
||||||
|
has_wildcards := false
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
prompt := {
|
||||||
|
id := 2,
|
||||||
|
prompt := ENABLE_PROMPT,
|
||||||
|
has_wildcards := false
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
prompt := {
|
||||||
|
id := 3,
|
||||||
|
prompt := CONFIG_PROMPT,
|
||||||
|
has_wildcards := true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* configure prompts in TELNETasp module */
|
||||||
|
function f_vty_set_prompts(TELNETasp_PT pt) {
|
||||||
|
/* set some configuration that isn't possible to express
|
||||||
|
* in the config file due to syntactic restrictions (Who invents config
|
||||||
|
* files that don't permit regular expressions? */
|
||||||
|
for (var integer i := 0; i < sizeof(vty_prompt); i:= i + 1) {
|
||||||
|
pt.send(vty_prompt[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wait for any of the permitted prompts; buffer + return all intermediate output */
|
||||||
|
function f_vty_wait_for_prompt(TELNETasp_PT pt) return charstring {
|
||||||
|
template charstring config_pattern := pattern CONFIG_PROMPT;
|
||||||
|
var charstring rx, buf := "";
|
||||||
|
timer T := 2.0;
|
||||||
|
|
||||||
|
T.start;
|
||||||
|
alt {
|
||||||
|
[] pt.receive(NORMAL_PROMPT) { };
|
||||||
|
[] pt.receive(ENABLE_PROMPT) { };
|
||||||
|
[] pt.receive(config_pattern) { };
|
||||||
|
[] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
|
||||||
|
[] T.timeout { setverdict(fail); return ""};
|
||||||
|
}
|
||||||
|
T.stop;
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send a VTY command and obtain response until prompt is received */
|
||||||
|
function f_vty_transceive(TELNETasp_PT pt, charstring tx) return charstring {
|
||||||
|
pt.send(tx);
|
||||||
|
return f_vty_wait_for_prompt(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enter the'confiugration' mode of the VTY */
|
||||||
|
function f_vty_enter_config(TELNETasp_PT pt) {
|
||||||
|
f_vty_transceive(pt, "enable");
|
||||||
|
f_vty_transceive(pt, "configure terminal")
|
||||||
|
}
|
||||||
|
|
||||||
|
testcase TC_telnet() runs on dummy_CT {
|
||||||
|
|
||||||
|
map(self:BSCVTY, system:BSCVTY);
|
||||||
|
f_vty_set_prompts(BSCVTY)
|
||||||
|
|
||||||
|
f_vty_transceive(BSCVTY, "show network")
|
||||||
|
f_vty_enter_config(BSCVTY)
|
||||||
|
f_vty_transceive(BSCVTY, "network")
|
||||||
|
f_vty_transceive(BSCVTY, "bts 0")
|
||||||
|
}
|
||||||
|
|
||||||
control {
|
control {
|
||||||
execute(TC_si1());
|
execute(TC_si1());
|
||||||
execute(TC_gsmtap());
|
execute(TC_gsmtap());
|
||||||
|
execute(TC_telnet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,3 +23,6 @@ DIR=$BASEDIR/titan.TestPorts.IPL4asp/src
|
||||||
FILES="IPL4asp_Functions.ttcn IPL4asp_PT.cc IPL4asp_PT.hh IPL4asp_PortType.ttcn IPL4asp_Types.ttcn IPL4asp_discovery.cc IPL4asp_protocol_L234.hh"
|
FILES="IPL4asp_Functions.ttcn IPL4asp_PT.cc IPL4asp_PT.hh IPL4asp_PortType.ttcn IPL4asp_Types.ttcn IPL4asp_discovery.cc IPL4asp_protocol_L234.hh"
|
||||||
gen_links $DIR $FILES
|
gen_links $DIR $FILES
|
||||||
|
|
||||||
|
DIR=$BASEDIR/titan.TestPorts.TELNETasp/src
|
||||||
|
FILES="TELNETasp_PT.cc TELNETasp_PT.hh TELNETasp_PortType.ttcn"
|
||||||
|
gen_links $DIR $FILES
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
FILES="*.ttcn IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc IPL4_GSMTAP_CtrlFunctDef.cc"
|
FILES="*.ttcn IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc IPL4_GSMTAP_CtrlFunctDef.cc TELNETasp_PT.cc"
|
||||||
|
|
||||||
ttcn3_makefilegen -f Test.ttcn $FILES
|
ttcn3_makefilegen -f Test.ttcn $FILES
|
||||||
sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
|
sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
|
||||||
|
|
Loading…
Reference in New Issue