<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/21367">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty: log failed vty command<br><br>Add a log label argument to f_vty_wait_for_prompt(), and feed the sent<br>command from f_vty_transceive*(), so that the failure verdict already<br>lists the vty command that caused the failure.<br><br>A common error is to issue insufficient 'exit' commands, so that I often<br>think the newly added VTY command failed, even though it is a subsequent<br>command causing the failure. I want to shorten the "time-to-aha" there.<br><br>Change-Id: Icfd739db150d86e9256a224f12dc979dcd77879f<br>---<br>M library/Osmocom_VTY_Functions.ttcn<br>1 file changed, 6 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn</span><br><span>index 82aff6b..042f244 100644</span><br><span>--- a/library/Osmocom_VTY_Functions.ttcn</span><br><span>+++ b/library/Osmocom_VTY_Functions.ttcn</span><br><span>@@ -56,7 +56,7 @@</span><br><span>  }</span><br><span> </span><br><span>        /* wait for any of the permitted prompts; buffer + return all intermediate output */</span><br><span style="color: hsl(0, 100%, 40%);">-    function f_vty_wait_for_prompt(TELNETasp_PT pt, boolean strict := true) return charstring {</span><br><span style="color: hsl(120, 100%, 40%);">+   function f_vty_wait_for_prompt(TELNETasp_PT pt, boolean strict := true, charstring log_label := "(?)") return charstring {</span><br><span>                 var charstring rx, buf := "";</span><br><span>              var integer fd;</span><br><span>              timer T := 2.0;</span><br><span>@@ -68,10 +68,10 @@</span><br><span>                        [] pt.receive(pattern "[\w-]+\(*\)\# ") { };</span><br><span>                       [] pt.receive(t_vty_unknown) -> value rx {</span><br><span>                                if (strict) {</span><br><span style="color: hsl(0, 100%, 40%);">-                                   setverdict(fail, "VTY: Unknown Command");</span><br><span style="color: hsl(120, 100%, 40%);">+                                   setverdict(fail, "VTY: Unknown Command: " & log_label);</span><br><span>                                        mtc.stop;</span><br><span>                            } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                                        log("VTY: Unknown Command (ignored)");</span><br><span style="color: hsl(120, 100%, 40%);">+                                      log("VTY: Unknown Command (ignored): " & log_label);</span><br><span>                                   buf := buf & rx;</span><br><span>                                         repeat;</span><br><span>                              }</span><br><span>@@ -79,14 +79,14 @@</span><br><span>                      [] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };</span><br><span>                  [] pt.receive(integer:?) -> value fd {</span><br><span>                            if (fd == -1) {</span><br><span style="color: hsl(0, 100%, 40%);">-                                 setverdict(fail, "VTY Telnet Connection Failure");</span><br><span style="color: hsl(120, 100%, 40%);">+                                  setverdict(fail, "VTY Telnet Connection Failure: " & log_label);</span><br><span>                                       mtc.stop;</span><br><span>                            } else {</span><br><span>                                     repeat; /* telnet connection succeeded */</span><br><span>                            }</span><br><span>                    }</span><br><span>                    [] T.timeout {</span><br><span style="color: hsl(0, 100%, 40%);">-                          setverdict(fail, "VTY Timeout for prompt");</span><br><span style="color: hsl(120, 100%, 40%);">+                         setverdict(fail, "VTY Timeout for prompt: " & log_label);</span><br><span>                              mtc.stop;</span><br><span>                            };</span><br><span>           }</span><br><span>@@ -97,7 +97,7 @@</span><br><span>        /* send a VTY command and obtain response until prompt is received */</span><br><span>        function f_vty_transceive_ret(TELNETasp_PT pt, charstring tx, boolean strict := true) return charstring {</span><br><span>            pt.send(tx);</span><br><span style="color: hsl(0, 100%, 40%);">-            return f_vty_wait_for_prompt(pt, strict);</span><br><span style="color: hsl(120, 100%, 40%);">+             return f_vty_wait_for_prompt(pt, strict, tx);</span><br><span>        }</span><br><span> </span><br><span>        /* send a VTY command and obtain response until prompt is received */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/21367">change 21367</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/21367"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ttcn3-hacks </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Icfd739db150d86e9256a224f12dc979dcd77879f </div>
<div style="display:none"> Gerrit-Change-Number: 21367 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>