diff --git a/lldb/packages/Python/lldbsuite/test/commands/target/basic/TestTargetCommand.py b/lldb/packages/Python/lldbsuite/test/commands/target/basic/TestTargetCommand.py index 81d7804b85f2..95df78eef12a 100644 --- a/lldb/packages/Python/lldbsuite/test/commands/target/basic/TestTargetCommand.py +++ b/lldb/packages/Python/lldbsuite/test/commands/target/basic/TestTargetCommand.py @@ -245,6 +245,7 @@ class targetCommandTestCase(TestBase): # It will find all the global and static variables in the current # compile unit. self.expect("target variable", + ordered=False, substrs=['my_global_char', 'my_static_int', 'my_global_str', diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py b/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py index a471058b3b45..04b874942acb 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py +++ b/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py @@ -79,6 +79,7 @@ class GlobalVariablesTestCase(TestBase): self.expect( "frame variable --show-types --scope --show-globals --no-args", VARIABLES_DISPLAYED_CORRECTLY, + ordered=False, substrs=[ 'STATIC: (const char *) g_func_static_cstr', '"g_func_static_cstr"', diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 602749c80fa8..fe4b198e93ce 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2261,6 +2261,7 @@ FileCheck output: substrs=None, trace=False, error=False, + ordered=True, matching=True, exe=True, inHistory=False): @@ -2273,6 +2274,10 @@ FileCheck output: 'startstr', matches the substrings contained in 'substrs', and regexp matches the patterns contained in 'patterns'. + When matching is true and ordered is true, which are both the default, + the strings in the substrs array have to appear in the command output + in the order in which they appear in the array. + If the keyword argument error is set to True, it signifies that the API client is expecting the command to fail. In this case, the error stream from running the command is retrieved and compared against the golden @@ -2341,8 +2346,11 @@ FileCheck output: # Look for sub strings, if specified. keepgoing = matched if matching else not matched if substrs and keepgoing: + start = 0 for substr in substrs: - matched = output.find(substr) != -1 + index = output[start:].find(substr) + start = start + index if ordered and matching else 0 + matched = index != -1 with recording(self, trace) as sbuf: print("%s sub string: %s" % (heading, substr), file=sbuf) print("Matched" if matched else "Not matched", file=sbuf)