def test_should_run_inside_gdb(self): gdb.GDB_RUN_BINARY_NAMES_EXPR = ['foo'] self.assertTrue(process.should_run_inside_gdb('foo')) self.assertTrue(process.should_run_inside_gdb('/usr/bin/foo')) self.assertFalse(process.should_run_inside_gdb('/usr/bin/fooz')) gdb.GDB_RUN_BINARY_NAMES_EXPR.append('foo:main') self.assertTrue(process.should_run_inside_gdb('foo')) self.assertFalse(process.should_run_inside_gdb('bar')) gdb.GDB_RUN_BINARY_NAMES_EXPR.append('bar:main.c:5') self.assertTrue(process.should_run_inside_gdb('bar')) self.assertFalse(process.should_run_inside_gdb('baz')) 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 ' "))