Move VTY utility functions to new Osmocom_VTY_Functions module
... so it can be reused from other Testsuites/modules
diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn
new file mode 100644
index 0000000..1215e0d
--- /dev/null
+++ b/library/Osmocom_VTY_Functions.ttcn
@@ -0,0 +1,103 @@
+module Osmocom_VTY_Functions {
+ import from TELNETasp_PortType all;
+
+ /* permitted prompts on VTY */
+ const charstring NORMAL_PROMPT := "OpenBSC> ";
+ const charstring ENABLE_PROMPT := "OpenBSC# ";
+ const charstring CONFIG_PROMPT := "OpenBSC(*)\#";
+ template charstring t_vty_unknown := pattern "*% Unknown command.";
+
+ 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(t_vty_unknown) { testcase.stop(fail, "VTY: Unknown Command") };
+ [] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
+ [] T.timeout { setverdict(fail, "VTY Timeout for prompt"); return ""};
+ }
+ T.stop;
+ return buf;
+ }
+
+ /* send a VTY command and obtain response until prompt is received */
+ function f_vty_transceive_ret(TELNETasp_PT pt, charstring tx) return charstring {
+ pt.send(tx);
+ return f_vty_wait_for_prompt(pt);
+ }
+
+ /* send a VTY command and obtain response until prompt is received */
+ function f_vty_transceive(TELNETasp_PT pt, charstring tx) {
+ f_vty_transceive_ret(pt, tx);
+ }
+
+ type integer BtsNr (0..255);
+ type integer BtsTrxNr (0..255);
+ type integer BtsTimeslotNr (0..7);
+
+ type charstring BtsGprsMode ("none", "gprs", "egrps");
+
+ /* enter the'confiugration' mode of the VTY */
+ function f_vty_enter_config(TELNETasp_PT pt) {
+ f_vty_transceive(pt, "configure terminal")
+ }
+
+ function f_vty_enter_cfg_network(TELNETasp_PT pt) {
+ f_vty_enter_config(pt);
+ f_vty_transceive(pt, "network")
+ }
+
+ function f_vty_enter_cfg_bts(TELNETasp_PT pt, BtsNr bts := 0) {
+ f_vty_enter_cfg_network(pt);
+ f_vty_transceive(pt, "bts " & int2str(bts));
+ }
+
+ function f_vty_enter_cfg_trx(TELNETasp_PT pt, BtsNr bts := 0, BtsTrxNr trx := 0) {
+ f_vty_enter_cfg_bts(pt, bts);
+ f_vty_transceive(pt, "trx " & int2str(trx));
+ }
+
+ function f_vty_enter_cfg_ts(TELNETasp_PT pt, BtsNr bts := 0, BtsTrxNr trx := 0, BtsTimeslotNr ts) {
+ f_vty_enter_cfg_trx(pt, bts, trx);
+ f_vty_transceive(pt, "timeslot " & int2str(ts));
+ }
+
+}
diff --git a/sysinfo/Test.ttcn b/sysinfo/Test.ttcn
index b9bb62d..4b65b3e 100644
--- a/sysinfo/Test.ttcn
+++ b/sysinfo/Test.ttcn
@@ -6,6 +6,7 @@
import from GSMTAP_PortType all;
import from IPL4_GSMTAP_CtrlFunct all;
import from TELNETasp_PortType all;
+ import from Osmocom_VTY_Functions all;
const octetstring si1 := '5506198fb38000000000000000000000000000e504002b'O;
const octetstring si2 := '59061a00000000000000000000000000000000ffe50400'O;
@@ -648,105 +649,6 @@
f_vty_si_resend(BSCVTY, 0);
}
- /* permitted prompts on VTY */
- const charstring NORMAL_PROMPT := "OpenBSC> ";
- const charstring ENABLE_PROMPT := "OpenBSC# ";
- const charstring CONFIG_PROMPT := "OpenBSC(*)\#";
- template charstring t_vty_unknown := pattern "*% Unknown command.";
-
- 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(t_vty_unknown) { testcase.stop(fail, "VTY: Unknown Command") };
- [] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
- [] T.timeout { setverdict(fail, "VTY Timeout for prompt"); return ""};
- }
- T.stop;
- return buf;
- }
-
- /* send a VTY command and obtain response until prompt is received */
- function f_vty_transceive_ret(TELNETasp_PT pt, charstring tx) return charstring {
- pt.send(tx);
- return f_vty_wait_for_prompt(pt);
- }
-
- /* send a VTY command and obtain response until prompt is received */
- function f_vty_transceive(TELNETasp_PT pt, charstring tx) {
- f_vty_transceive_ret(pt, tx);
- }
-
- type integer BtsNr (0..255);
- type integer BtsTrxNr (0..255);
- type integer BtsTimeslotNr (0..7);
-
- type charstring BtsGprsMode ("none", "gprs", "egrps");
-
- /* enter the'confiugration' mode of the VTY */
- function f_vty_enter_config(TELNETasp_PT pt) {
- f_vty_transceive(pt, "configure terminal")
- }
-
- function f_vty_enter_cfg_network(TELNETasp_PT pt) {
- f_vty_enter_config(pt);
- f_vty_transceive(pt, "network")
- }
-
- function f_vty_enter_cfg_bts(TELNETasp_PT pt, BtsNr bts := 0) {
- f_vty_enter_cfg_network(pt);
- f_vty_transceive(pt, "bts " & int2str(bts));
- }
-
- function f_vty_enter_cfg_trx(TELNETasp_PT pt, BtsNr bts := 0, BtsTrxNr trx := 0) {
- f_vty_enter_cfg_bts(pt, bts);
- f_vty_transceive(pt, "trx " & int2str(trx));
- }
-
- function f_vty_enter_cfg_ts(TELNETasp_PT pt, BtsNr bts := 0, BtsTrxNr trx := 0, BtsTimeslotNr ts) {
- f_vty_enter_cfg_trx(pt, bts, trx);
- f_vty_transceive(pt, "timeslot " & int2str(ts));
- }
-
function f_vty_si_static(TELNETasp_PT pt, BtsNr bts, charstring si, octetstring bytes) {
f_vty_enter_cfg_bts(pt, bts);
f_vty_transceive(pt, "system-information " & si & " mode static");
diff --git a/sysinfo/gen_links.sh b/sysinfo/gen_links.sh
index b719b06..4679dd8 100755
--- a/sysinfo/gen_links.sh
+++ b/sysinfo/gen_links.sh
@@ -28,6 +28,6 @@
gen_links $DIR $FILES
DIR=../library
-FILES="GSMTAP_PortType.ttcn GSMTAP_Types.ttcn GSM_SystemInformation.ttcn GSM_Types.ttcn IPL4_GSMTAP_CtrlFunct.ttcn IPL4_GSMTAP_CtrlFunctDef.cc Osmocom_Types.ttcn General_Types.ttcn"
+FILES="GSMTAP_PortType.ttcn GSMTAP_Types.ttcn GSM_SystemInformation.ttcn GSM_Types.ttcn IPL4_GSMTAP_CtrlFunct.ttcn IPL4_GSMTAP_CtrlFunctDef.cc Osmocom_Types.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn"
gen_links $DIR $FILES