提交 0ba51736 编写于 作者: L Lucas Meneghel Rodrigues

Merge pull request #897 from ldoktor/split

avocado.utils.process: Improve detection to run cmd in GDB [v2]
......@@ -864,7 +864,15 @@ def should_run_inside_gdb(cmd):
:param cmd: the command arguments, from where we extract the binary name
"""
if not gdb.GDB_RUN_BINARY_NAMES_EXPR:
return False
try:
args = shlex.split(cmd)
except ValueError:
log.warning("Unable to check whether command '%s' should run inside "
"GDB, fallback to simplified method...", cmd)
args = cmd.split()
cmd_binary_name = os.path.basename(args[0])
for expr in gdb.GDB_RUN_BINARY_NAMES_EXPR:
......
......@@ -33,6 +33,13 @@ class TestGDBProcess(unittest.TestCase):
self.assertTrue(process.should_run_inside_gdb('bar 1 2 3'))
self.assertTrue(process.should_run_inside_gdb('/usr/bin/bar 1 2 3'))
def test_should_run_inside_gdb_malformed_command(self):
gdb.GDB_RUN_BINARY_NAMES_EXPR = ['/bin/virsh']
cmd = """/bin/virsh node-memory-tune --shm-sleep-millisecs ~!@#$%^*()-=[]{}|_+":;'`,>?. """
self.assertTrue(process.should_run_inside_gdb(cmd))
self.assertFalse(process.should_run_inside_gdb("foo bar baz"))
self.assertFalse(process.should_run_inside_gdb("foo ' "))
def test_get_sub_process_klass(self):
gdb.GDB_RUN_BINARY_NAMES_EXPR = []
self.assertIs(process.get_sub_process_klass('/bin/true'),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册