f_vty_transceive: allow to ignore unknown vty commands
When a new test uses a VTY configuration that may not yet be available in the
'latest' build, it can be useful to ignore the "Unknown VTY Command" error.
To be used by f_init() for multiple MSCs, setting a default 'allow-attach' flag
per MSC implicitly -- such vty config is not yet supported in the latest build.
Change-Id: I284c42e10c0cb282c8410db87959b471867edef6
diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn
index 823d79f..4cf37c4 100644
--- a/library/Osmocom_VTY_Functions.ttcn
+++ b/library/Osmocom_VTY_Functions.ttcn
@@ -56,7 +56,7 @@
}
/* wait for any of the permitted prompts; buffer + return all intermediate output */
- function f_vty_wait_for_prompt(TELNETasp_PT pt) return charstring {
+ function f_vty_wait_for_prompt(TELNETasp_PT pt, boolean strict := true) return charstring {
var charstring rx, buf := "";
var integer fd;
timer T := 2.0;
@@ -67,7 +67,11 @@
[] pt.receive(pattern "[\w-]+\# ") { };
[] pt.receive(pattern "[\w-]+\(*\)\# ") { };
[] pt.receive(t_vty_unknown) {
- testcase.stop(fail, "VTY: Unknown Command");
+ if (strict) {
+ testcase.stop(fail, "VTY: Unknown Command");
+ } else {
+ log("VTY: Unknown Command (ignored)");
+ }
};
[] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
[] pt.receive(integer:?) -> value fd {
@@ -88,14 +92,14 @@
}
/* send a VTY command and obtain response until prompt is received */
- function f_vty_transceive_ret(TELNETasp_PT pt, charstring tx) return charstring {
+ function f_vty_transceive_ret(TELNETasp_PT pt, charstring tx, boolean strict := true) return charstring {
pt.send(tx);
- return f_vty_wait_for_prompt(pt);
+ return f_vty_wait_for_prompt(pt, strict);
}
/* send a VTY command and obtain response until prompt is received */
- function f_vty_transceive(TELNETasp_PT pt, charstring tx) {
- var charstring unused := f_vty_transceive_ret(pt, tx);
+ function f_vty_transceive(TELNETasp_PT pt, charstring tx, boolean strict := true) {
+ var charstring unused := f_vty_transceive_ret(pt, tx, strict);
}
type integer BtsNr (0..255);