<div dir="ltr">On 20 November 2015 at 11:42, Lucian Musat <span dir="ltr"><<a href="mailto:george.l.musat@intel.com" target="_blank">george.l.musat@intel.com</a>></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 = "nothing"<br>
+ (status, wifi_interface) = self.target.run("ifconfig | grep '^wlp\|^wlan' | awk '{print $1}'")<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('cp /proc/config.gz .; gunzip config.gz; cat config | grep CONFIG_IWLWIFI=')<br></blockquote><div><br></div><div>"gunzip -c" 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 <<a href="mailto:jing.j.wang@intel.com">jing.j.wang@intel.com</a>><br>
</blockquote><div><br></div><div>What's [PROTEXCAT] mean? That license isn't right for something that'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>
+ """Execute shell command till it return"""<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>
+ """Execute shell command till timeout"""<br>
+ cmd_proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)<br>
+ if not cmd_proc:<br>
+ return -1, ''<br></blockquote><div><br></div><div>How is subproccess.Popen() expected to return something that evaluates to false? This can'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, ''<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 > 0:<br>
+ t_timeout -= tick<br>
+<br>
+ if t_timeout <= 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'm wondering why we don'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>
+ """collect the result log for pnp part"""<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("%Y-%m-%d %H:%M:%S")<br>
+ with open(logpath, "a") as text_file:<br>
+ text_file.write("%s %s:%s\n" %(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>
+ """Get directory of supporting files"""<br>
+ pkgarch = oeRuntimeTest.tc.d.getVar('MACHINE', True)<br>
+ deploydir = oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True)<br>
+ return os.path.join(deploydir, "files", "target", 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>
+ """Get directory of native files"""<br>
+ arch = oeRuntimeTest.tc.d.getVar('BUILD_ARCH', True)<br>
+ deploydir = oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True)<br>
+ return os.path.join(deploydir, "files", "native", arch)<br></blockquote><div><br></div><div>Or this.</div><div><br></div><div>Ross</div></div></div></div>