Author: Raphael Isemann Date: 2026-09-07T10:16:37+01:00 New Revision: 038e968a7ec08ba7d9a262059f8fab91853656ea
URL: https://github.com/llvm/llvm-project/commit/038e968a7ec08ba7d9a262059f8fab91853656ea DIFF: https://github.com/llvm/llvm-project/commit/038e968a7ec08ba7d9a262059f8fab91853656ea.diff LOG: [lldb][test] Rewrite Watchpoint/SetErrorCases as API test (#221563) This test is randomly failing on macOS bots with this error: ``` error: Command requires a process which is currently stopped. ``` There is no test logic in shell tests that can diagnose what is going on with the process, so this patch rewrites this test as an API test where we have better error handling. Added: lldb/test/API/commands/watchpoints/watchpoint_set_errors/Makefile lldb/test/API/commands/watchpoints/watchpoint_set_errors/TestWatchpointSetErrors.py lldb/test/API/commands/watchpoints/watchpoint_set_errors/main.c Modified: Removed: lldb/test/Shell/Watchpoint/Inputs/main.cpp lldb/test/Shell/Watchpoint/SetErrorCases.test ################################################################################ diff --git a/lldb/test/API/commands/watchpoints/watchpoint_set_errors/Makefile b/lldb/test/API/commands/watchpoints/watchpoint_set_errors/Makefile new file mode 100644 index 0000000000000..10495940055b6 --- /dev/null +++ b/lldb/test/API/commands/watchpoints/watchpoint_set_errors/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/commands/watchpoints/watchpoint_set_errors/TestWatchpointSetErrors.py b/lldb/test/API/commands/watchpoints/watchpoint_set_errors/TestWatchpointSetErrors.py new file mode 100644 index 0000000000000..024df106a70a2 --- /dev/null +++ b/lldb/test/API/commands/watchpoints/watchpoint_set_errors/TestWatchpointSetErrors.py @@ -0,0 +1,61 @@ +""" +Test the error messages emitted by invalid 'watchpoint set' invocations. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class WatchpointSetErrorsTestCase(TestBase): + NO_DEBUG_INFO_TESTCASE = True + + def test_set_without_subcommand(self): + """'watchpoint set' without a subcommand prints its help.""" + self.build_and_run() + self.expect( + "watchpoint set", + substrs=[ + "Commands for setting a watchpoint.", + "The following subcommands are supported:", + "Set a watchpoint on an address by supplying an expression.", + "Set a watchpoint on a variable.", + ], + ) + + def test_variable_without_argument(self): + """'watchpoint set variable' requires a variable name.""" + self.build_and_run() + self.expect( + "watchpoint set variable -w read_write", + error=True, + substrs=["error: required argument missing"], + ) + + def test_expression_without_argument(self): + """'watchpoint set expression' requires an expression.""" + self.build_and_run() + self.expect( + "watchpoint set expression -w write --", + error=True, + substrs=["error: expression evaluation of address to watch failed"], + ) + + def test_expression_not_an_address(self): + """'watchpoint set expression' rejects a non-address expression.""" + self.build_and_run() + self.expect( + "watchpoint set expression MyAggregateDataType", + error=True, + substrs=["error: expression did not evaluate to an address"], + ) + + def test_negative_size(self): + """'watchpoint set' rejects a negative --size value.""" + self.build_and_run() + self.expect( + "watchpoint set variable -s -128", + error=True, + substrs=["error: invalid --size option value"], + ) diff --git a/lldb/test/API/commands/watchpoints/watchpoint_set_errors/main.c b/lldb/test/API/commands/watchpoints/watchpoint_set_errors/main.c new file mode 100644 index 0000000000000..f669d620442bc --- /dev/null +++ b/lldb/test/API/commands/watchpoints/watchpoint_set_errors/main.c @@ -0,0 +1,9 @@ +int main(int argc, char const *argv[]) { + struct { + int a; + int b; + int c; + } MyAggregateDataType = {1, 2, 3}; + + return MyAggregateDataType.a; // break here +} diff --git a/lldb/test/Shell/Watchpoint/Inputs/main.cpp b/lldb/test/Shell/Watchpoint/Inputs/main.cpp deleted file mode 100644 index 9bc5724b9c88c..0000000000000 --- a/lldb/test/Shell/Watchpoint/Inputs/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include <stdio.h> - -int main (int argc, char const *argv[]) -{ - struct { - int a; - int b; - int c; - } MyAggregateDataType; - - printf ("Set break point at this line.\n"); - return 0; -} diff --git a/lldb/test/Shell/Watchpoint/SetErrorCases.test b/lldb/test/Shell/Watchpoint/SetErrorCases.test deleted file mode 100644 index 6020186b9e3f5..0000000000000 --- a/lldb/test/Shell/Watchpoint/SetErrorCases.test +++ /dev/null @@ -1,28 +0,0 @@ -# RUN: %clangxx_host %p/Inputs/main.cpp -g -o %t.out -# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -s %s %t.out 2>&1 | FileCheck %s - -settings show interpreter.stop-command-source-on-error -# CHECK: interpreter.stop-command-source-on-error (boolean) = false - -b main.cpp:11 -run -# CHECK: stopped -# CHECK-NEXT: stop reason = breakpoint - -watchpoint set -# CHECK: Commands for setting a watchpoint. -# CHECK: The following subcommands are supported: -# CHECK: Set a watchpoint on an address by supplying an expression. -# CHECK: Set a watchpoint on a variable. - -watchpoint set variable -w read_write -# CHECK: error: required argument missing - -watchpoint set expression -w write -- -# CHECK: error: expression evaluation of address to watch failed - -watchpoint set expression MyAggregateDataType -# CHECK: error: expression did not evaluate to an address - -watchpoint set variable -s -128 -# CHECK: error: invalid --size option value _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
