This revision was automatically updated to reflect the committed changes.
Closed by commit rGb53d44b17a16: dotest.py: Add option to pass extra lldb 
settings to dotest (authored by aprantl).

Changed prior to commit:
  https://reviews.llvm.org/D72662?vs=237803&id=238072#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72662/new/

https://reviews.llvm.org/D72662

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py


Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -116,6 +116,14 @@
         type=int,
         help='Override the DWARF version.')
     group.add_argument(
+        '--setting',
+        metavar='SETTING=VALUE',
+        dest='settings',
+        type=str,
+        nargs=1,
+        action='append',
+        help='Run "setting set SETTING VALUE" before executing any test.')
+    group.add_argument(
         '-s',
         metavar='name',
         help='Specify the name of the dir created to store the session files 
of tests with errored or failed status. If not specified, the test driver uses 
the timestamp as the session dir name')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -343,6 +343,14 @@
         # that explicitly require no debug info.
         os.environ['CFLAGS'] = '-gdwarf-{}'.format(configuration.dwarf_version)
 
+    if args.settings:
+        for setting in args.settings:
+            if not len(setting) == 1 or not setting[0].count('='):
+                logging.error('"%s" is not a setting in the form "key=value"',
+                              setting[0])
+                sys.exit(-1)
+            configuration.settings.append(setting[0].split('=', 1))
+
     if args.d:
         sys.stdout.write(
             "Suspending the process %d to wait for debugger to attach...\n" %
@@ -765,17 +773,15 @@
             raise
 
 
-def disabledynamics():
+def setSetting(setting, value):
     import lldb
     ci = lldb.DBG.GetCommandInterpreter()
     res = lldb.SBCommandReturnObject()
-    ci.HandleCommand(
-        "setting set target.prefer-dynamic-value no-dynamic-values",
-        res,
-        False)
+    cmd = 'setting set %s %s'%(setting, value)
+    print(cmd)
+    ci.HandleCommand(cmd, res, False)
     if not res.Succeeded():
-        raise Exception('disabling dynamic type support failed')
-
+        raise Exception('failed to run "%s"'%cmd)
 
 # ======================================== #
 #                                          #
@@ -1060,8 +1066,9 @@
     # Now that we have loaded all the test cases, run the whole test suite.
     #
 
-    # Disable default dynamic types for testing purposes
-    disabledynamics()
+    # Set any user-overridden settings.
+    for key, value in configuration.settings:
+        setSetting(key, value)
 
     # Install the control-c handler.
     unittest2.signals.installHandler()
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -48,6 +48,10 @@
 # The overriden dwarf verison.
 dwarf_version = 0
 
+# Any overridden settings.
+# Always disable default dynamic types for testing purposes.
+settings = [('target.prefer-dynamic-value', 'no-dynamic-values')]
+
 # Path to the FileCheck testing tool. Not optional.
 filecheck = None
 


Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -116,6 +116,14 @@
         type=int,
         help='Override the DWARF version.')
     group.add_argument(
+        '--setting',
+        metavar='SETTING=VALUE',
+        dest='settings',
+        type=str,
+        nargs=1,
+        action='append',
+        help='Run "setting set SETTING VALUE" before executing any test.')
+    group.add_argument(
         '-s',
         metavar='name',
         help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -343,6 +343,14 @@
         # that explicitly require no debug info.
         os.environ['CFLAGS'] = '-gdwarf-{}'.format(configuration.dwarf_version)
 
+    if args.settings:
+        for setting in args.settings:
+            if not len(setting) == 1 or not setting[0].count('='):
+                logging.error('"%s" is not a setting in the form "key=value"',
+                              setting[0])
+                sys.exit(-1)
+            configuration.settings.append(setting[0].split('=', 1))
+
     if args.d:
         sys.stdout.write(
             "Suspending the process %d to wait for debugger to attach...\n" %
@@ -765,17 +773,15 @@
             raise
 
 
-def disabledynamics():
+def setSetting(setting, value):
     import lldb
     ci = lldb.DBG.GetCommandInterpreter()
     res = lldb.SBCommandReturnObject()
-    ci.HandleCommand(
-        "setting set target.prefer-dynamic-value no-dynamic-values",
-        res,
-        False)
+    cmd = 'setting set %s %s'%(setting, value)
+    print(cmd)
+    ci.HandleCommand(cmd, res, False)
     if not res.Succeeded():
-        raise Exception('disabling dynamic type support failed')
-
+        raise Exception('failed to run "%s"'%cmd)
 
 # ======================================== #
 #                                          #
@@ -1060,8 +1066,9 @@
     # Now that we have loaded all the test cases, run the whole test suite.
     #
 
-    # Disable default dynamic types for testing purposes
-    disabledynamics()
+    # Set any user-overridden settings.
+    for key, value in configuration.settings:
+        setSetting(key, value)
 
     # Install the control-c handler.
     unittest2.signals.installHandler()
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -48,6 +48,10 @@
 # The overriden dwarf verison.
 dwarf_version = 0
 
+# Any overridden settings.
+# Always disable default dynamic types for testing purposes.
+settings = [('target.prefer-dynamic-value', 'no-dynamic-values')]
+
 # Path to the FileCheck testing tool. Not optional.
 filecheck = None
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to