diff --git a/tests/conftest.py b/tests/conftest.py index c1eb26e00a43..0c5cdda970d6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -123,7 +123,14 @@ def destroy(self): ensure_system("ip netns delete %s" % self.nsname) def runcmd(self, cmd): - return os.system("ip netns exec %s %s" % (self.nsname, cmd)) + try: + out = subprocess.check_output("ip netns exec %s %s" % (self.nsname, cmd), stderr=subprocess.STDOUT, shell=True) + except subprocess.CalledProcessError as e: + print "------rc={} for cmd: {}------".format(e.returncode, e.cmd) + print e.output.rstrip() + print "------" + return e.returncode + return 0 def runcmd_async(self, cmd): return subprocess.Popen("ip netns exec %s %s" % (self.nsname, cmd), shell=True) @@ -294,6 +301,11 @@ def runcmd(self, cmd): except AttributeError: exitcode = 0 out = res + if exitcode != 0: + print "-----rc={} for cmd {}-----".format(exitcode, cmd) + print out.rstrip() + print "-----" + return (exitcode, out) def copy_file(self, path, filename):