<div dir="ltr">On 20 November 2015 at 11:42, Lucian Musat <span dir="ltr">&lt;<a href="mailto:george.l.musat@intel.com" target="_blank">george.l.musat@intel.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+    def check_wifi_ip(self):<br>
+        time.sleep(3)<br></blockquote><div><br></div><div>Why a sleep here?  Why none of the other tests?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        # Check ip address by ifconfig command<br>
+        wifi_interface = &quot;nothing&quot;<br>
+        (status, wifi_interface) = self.target.run(&quot;ifconfig | grep &#39;^wlp\|^wlan&#39; | awk &#39;{print $1}&#39;&quot;)<br></blockquote><div><br></div><div>No need to grep and awk, just use a pattern match in awk.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+    def test_check_wifi_capable(self):<br>
+        (status, output) = self.target.run(&#39;cp /proc/config.gz .; gunzip config.gz; cat config | grep CONFIG_IWLWIFI=&#39;)<br></blockquote><div><br></div><div>&quot;gunzip -c&quot; will write to stdout, so this can be replaced with gunzip -c /proc/config.gz | grep -q CONFIG_IWLWIFI=.</div><div>  </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">--- /dev/null<br>
+++ b/meta/lib/oeqa/utils/helper.py<br>
@@ -0,0 +1,62 @@<br>
+#[PROTEXCAT]<br>
+#\License: ALL RIGHTS RESERVED<br>
+#\Author: Wang, Jing &lt;<a href="mailto:jing.j.wang@intel.com">jing.j.wang@intel.com</a>&gt;<br>
</blockquote><div><br></div><div>What&#39;s [PROTEXCAT] mean?  That license isn&#39;t right for something that&#39;s meant to be in oe-core (typically, MIT). </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+def shell_cmd(cmd):<br>
+    &quot;&quot;&quot;Execute shell command till it return&quot;&quot;&quot;<br>
+    cmd_proc = subprocess.Popen(cmd, shell=True)<br>
+    return cmd_proc.wait() if cmd_proc else -1<br>
</blockquote><div><br></div><div>This is just a bad reimplementation of subprocess.call().  Use call().</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+def shell_cmd_timeout(cmd, timeout=0):<br>
+    &quot;&quot;&quot;Execute shell command till timeout&quot;&quot;&quot;<br>
+    cmd_proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)<br>
+    if not cmd_proc:<br>
+        return -1, &#39;&#39;<br></blockquote><div><br></div><div>How is subproccess.Popen() expected to return something that evaluates to false?  This can&#39;t happen.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    t_timeout, tick = timeout, 2<br>
+    ret, output = None, &#39;&#39;<br>
+    while True:<br>
+        time.sleep(tick)<br>
+        output = cmd_proc.communicate()[0]<br>
+        ret = cmd_proc.poll()<br>
+        if ret is not None:<br>
+            break<br>
+<br>
+        if t_timeout &gt; 0:<br>
+            t_timeout -= tick<br>
+<br>
+        if t_timeout &lt;= 0:<br>
+            # timeout, kill command<br>
+            cmd_proc.kill()<br>
+            ret = -99999<br>
+            break<br>
+    return ret, output<br></blockquote><div><br></div><div>sshcontrol has a neater way of doing this.  I&#39;m wondering why we don&#39;t just install expect on the target instead of assuming the host has expect and doing ssh-in-expect.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+def collect_pnp_log(casename, logname, log):<br>
+    &quot;&quot;&quot;collect the result log for pnp part&quot;&quot;&quot;<br>
+    curpath = os.getcwd()<br>
+    if not os.path.exists(casename):<br>
+        os.makedirs(casename)<br>
+<br>
+    logpath = os.path.join(curpath, casename, logname)<br>
+    logtime = time.strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)<br>
+    with open(logpath, &quot;a&quot;) as text_file:<br>
+        text_file.write(&quot;%s %s:%s\n&quot; %(logtime, casename, log))<br><br></blockquote><div>Nothing uses this.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+def get_files_dir():<br>
+    &quot;&quot;&quot;Get directory of supporting files&quot;&quot;&quot;<br>
+    pkgarch = oeRuntimeTest.tc.d.getVar(&#39;MACHINE&#39;, True)<br>
+    deploydir = oeRuntimeTest.tc.d.getVar(&#39;DEPLOY_DIR&#39;, True)<br>
+    return os.path.join(deploydir, &quot;files&quot;, &quot;target&quot;, pkgarch)<br></blockquote><div> </div><div>Or this.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+def get_native_dir():<br>
+    &quot;&quot;&quot;Get directory of native files&quot;&quot;&quot;<br>
+    arch = oeRuntimeTest.tc.d.getVar(&#39;BUILD_ARCH&#39;, True)<br>
+    deploydir = oeRuntimeTest.tc.d.getVar(&#39;DEPLOY_DIR&#39;, True)<br>
+    return os.path.join(deploydir, &quot;files&quot;, &quot;native&quot;, arch)<br></blockquote><div><br></div><div>Or this.</div><div><br></div><div>Ross</div></div></div></div>