<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Hello Ferruh,<br>
<br>
> But I guess it won't catch this issue, as it uses full flow commands.<br>
> This issue is related to the testpmd command parsing code. I wonder if<br>
> we can find a way to verify testpmd parsing code?<br>
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
What if flow command validation program breaks a tested command into tokens and then pass each token followed by the TAB key to the controlled testpmd process ?</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
There are 3 possible outputs for the token + TAB sequence:</div>
<ol start="1" data-editing-info="{"orderedStyleType":1,"unorderedStyleType":2}" data-listchain="__List_Chain_837" style="margin-top: 0px; margin-bottom: 0px; list-style-type: decimal;">
<li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">a valid token will trigger meaningful testpmd help ouput that can be matched.<br>
</span></li><li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">invalid token output will fail [1].<br>
</span></li><li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
invalid token will crash the controlled testpmd process.</div>
</li></ol>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
I've compiled a small programm to test that idea.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Please check it out.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Regards,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Gregory.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="background-color: rgb(255, 255, 255);">
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
commit e4a27c2c2892cfd408b473b18192b30927e4281c</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
Author: Gregory Etelson <getelson@nvidia.com></div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
Date: Sat Mar 23 11:38:44 2024 +0200</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
<br>
</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
validate testpmd flow command</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
<br>
</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(0, 0, 128);">
diff --git a/Cargo.toml b/Cargo.toml</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
new file mode 100644</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
index 0000000..3498868</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(0, 0, 128);">
--- /dev/null</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(0, 0, 128);">
+++ b/Cargo.toml</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
@@ -0,0 +1,12 @@</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+[package]</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+name = "testpmd-validate"</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+version = "0.1.0"</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+edition = "2021"</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+rust-version = "1.76.0"</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+[dependencies]</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ssh2 = { version = "0.9.4", features = ["vendored-openssl"] }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+time = "0.3.34"</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+regex = "1.10.4"</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(0, 0, 128);">
diff --git a/src/main.rs b/src/main.rs</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
new file mode 100644</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
index 0000000..90dfdac</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(0, 0, 128);">
--- /dev/null</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(0, 0, 128);">
+++ b/src/main.rs</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(59, 59, 59);">
@@ -0,0 +1,128 @@</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+use std::io::{Read, Write};</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+use std::{io, thread, time};</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+use std::path::Path;</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+use std::ops::Add;</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+use std::time::{SystemTime};</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+use ssh2::{Channel, Error, ExtendedData, Session};</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+use regex::{RegexSet};</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+fn continue_after_error(err:&io::Error) -> bool {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ match err.kind() {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ io::ErrorKind::WouldBlock => return true,</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ _ => return false,</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+}</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+fn wrap_ssh<F, T>(mut func:F) -> T</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ where F: FnMut() -> Result<T, Error> {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ loop {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ match func() {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ Ok(val) => { return val },</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ Err(ssh_err) => {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let io_err = io::Error::from(ssh_err);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ if !continue_after_error(&io_err) {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ panic!("ssh2 error: {:?}", io_err);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+}</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+fn rsh_write(channel:&mut Channel, buf:&str) {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ match channel.write(buf.as_bytes()) {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ Ok(_) => (),</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ Err(e) => panic!("write failure: {:?}", e)</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+}</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+const RSH_READ_MAX_DURATION:time::Duration = time::Duration::from_millis(350);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+const RSH_READ_IDLE_TIMEOUT:time::Duration = time::Duration::from_millis(10);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+fn rsh_read(channel:&mut Channel) -> String {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let mut end = SystemTime::now().add(RSH_READ_MAX_DURATION);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let mut output = String::new();</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ loop {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let mut buffer: [u8; 1024] = [0; 1024];</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ match channel.read(&mut buffer) {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ Ok(0) => { return output }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ Ok(_) => {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let aux = String::from_utf8(buffer.into()).unwrap();</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ // println!("{aux}");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ output.push_str(&aux);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ end = SystemTime::now().add(RSH_READ_MAX_DURATION);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ Err(err) => {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ if !continue_after_error(&err) { panic!("read error {:?}", err) }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ if SystemTime::now().gt(&end) { break; }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ thread::sleep(RSH_READ_IDLE_TIMEOUT);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ output</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+}</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+const TESTPMD_PATH:&str = "/tmp/build/app";</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+const TESTPMD_CMD:&str = "dpdk-testpmd -a 0000:01:00.0 -- -i";</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+const TOKEN_PATTERN:[&str; 2] = [</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ r#"(?m)\[.*\]:"#,</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ r#"(?m)\[RETURN]"#,</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+];</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+const CTRL_C:[u8;1] = [0x3];</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+fn rsh_connect(hostname:&str) -> Channel {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let stream = std::net::TcpStream::connect(format!("{}:22", hostname)).unwrap();</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ stream.set_nonblocking(true).unwrap();</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let mut session = Session::new().unwrap();</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let private_key = Path::new("/home/garik/.ssh/id_rsa");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ session.set_blocking(false);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ session.set_tcp_stream(stream);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ wrap_ssh(|| session.handshake());</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ wrap_ssh(|| session.userauth_pubkey_file("root", None, &private_key, None));</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let mut ch = wrap_ssh(|| session.channel_session());</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ wrap_ssh(|| ch.handle_extended_data(ExtendedData::Merge));</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ wrap_ssh(|| ch.request_pty("vt100", None, None));</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ ch</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+}</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+fn validate_flow_command(command:&str, ch:&mut Channel) {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let rset = RegexSet::new(TOKEN_PATTERN).unwrap();</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let delay = time::Duration::from_millis(300);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!("validate: {command}");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ for token in command.split_whitespace() {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let candid = format!("{token} \t");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ rsh_write(ch, &candid);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ print!("validate token \'{token}\' ");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ thread::sleep(delay);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let output = rsh_read(ch);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ if rset.is_match(&output) {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!(" ok");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ } else {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!("failed");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!(">>>>>>>>>>>>>>>>>>");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!("{output}");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!("<<<<<<<<<<<<<<<<<<");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ break;</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ }</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let _ = ch.write(&CTRL_C);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+}</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+fn main() {</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let mut ch = rsh_connect("10.237.157.85");</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let command = format!("{}/{}", TESTPMD_PATH, TESTPMD_CMD);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ wrap_ssh(|| ch.exec(&command));</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ thread::sleep(time::Duration::from_secs(1));</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!("{}", rsh_read(&mut ch));</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let good_flow = "flow create 0 ingress group 0 priority 0 pattern eth / end actions drop / end";</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ let bad_flow = "flow create 0 ingress group 0 priority 0 pattern eth/ end actions drop / end";</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ validate_flow_command(good_flow, &mut ch);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ validate_flow_command(bad_flow, &mut ch);</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ wrap_ssh(|| ch.close());</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+ println!("EOF {:?}", ch.exit_status());</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 10pt; color: rgb(9, 134, 88);">
+}</div>
<div style="line-height: 19px; white-space: pre; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; color: rgb(59, 59, 59);">
<br>
</div>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
</body>
</html>