Change in osmo-ttcn3-hacks[master]: library/VTY: fix prompt matching in f_vty_wait_for_prompt()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sun Oct 28 13:03:29 UTC 2018


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/11489


Change subject: library/VTY: fix prompt matching in f_vty_wait_for_prompt()
......................................................................

library/VTY: fix prompt matching in f_vty_wait_for_prompt()

Matching the prompt by a sequence of any alphanumeric characters
(i.e. '\w+') is a bad idea, because it can led to false-positive
matching results, for example:

  - '\w+> ' matches the following:
    * 'OsmoBlaBla> ',
    * 'Switching default route from <none> to foobar'.

Let's avoid using such implicit patterns, and replace the '\w+'
by mp_prompt_prefix, that basically contains the process name.

Change-Id: I8a0e3fcfb0c4e5854b7b1e39296052e679c63c73
Related: OS#3675
---
M library/Osmocom_VTY_Functions.ttcn
1 file changed, 6 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/89/11489/1

diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn
index b822645..b56b792 100644
--- a/library/Osmocom_VTY_Functions.ttcn
+++ b/library/Osmocom_VTY_Functions.ttcn
@@ -9,6 +9,9 @@
 	const charstring VTY_ENABLE_SUFFIX := "# ";
 	const charstring VTY_CFG_SUFFIX := "(*)";
 
+	template charstring t_vty_prompt_view   := pattern mp_prompt_prefix & "> ";
+	template charstring t_vty_prompt_enable := pattern mp_prompt_prefix & "\# ";
+	template charstring t_vty_prompt_config := pattern mp_prompt_prefix & "(*)\# ";
 	template charstring t_vty_unknown := pattern "*% Unknown command.";
 
 	/* configure prompts in TELNETasp module */
@@ -51,9 +54,9 @@
 
 		T.start;
 		alt {
-			[] pt.receive(pattern "\w+" & VTY_VIEW_SUFFIX) { };
-			[] pt.receive(pattern "\w+\# ") { };
-			[] pt.receive(pattern "\w+" & VTY_CFG_SUFFIX) { };
+			[] pt.receive(t_vty_prompt_view)   {  };
+			[] pt.receive(t_vty_prompt_enable) {  };
+			[] pt.receive(t_vty_prompt_config) {  };
 			[] pt.receive(t_vty_unknown) {
 				testcase.stop(fail, "VTY: Unknown Command");
 				};

-- 
To view, visit https://gerrit.osmocom.org/11489
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a0e3fcfb0c4e5854b7b1e39296052e679c63c73
Gerrit-Change-Number: 11489
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181028/857c26b5/attachment.htm>


More information about the gerrit-log mailing list