summaryrefslogtreecommitdiff
path: root/virt-manager
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2019-06-05 13:19:44 -0400
committerCole Robinson <crobinso@redhat.com>2019-06-05 16:28:05 -0400
commitd2462367ee84cba0f5a7cded8931b287b7842533 (patch)
treeb30b710d9b7dcb0ba7896c2a84cbb097bb6850a9 /virt-manager
parentd65f54dc9d2052a5d6eaeca31297ee235c2777e9 (diff)
downloadvirt-manager-d2462367ee84cba0f5a7cded8931b287b7842533.tar.gz
virt-manager: Add --test-options
Will take a string of comma separated options which we can use to tweak app behavior, for testing. Convert the existing --test-* options to use the same abstraction internally. This will make it easier to add new test options in the future
Diffstat (limited to 'virt-manager')
-rwxr-xr-xvirt-manager52
1 files changed, 43 insertions, 9 deletions
diff --git a/virt-manager b/virt-manager
index 46838838..8a5b9e17 100755
--- a/virt-manager
+++ b/virt-manager
@@ -145,6 +145,10 @@ def parse_commandline():
parser.add_argument("--test-leak-debug",
help=argparse.SUPPRESS, action="store_true")
+ # comma separated string of options to tweak app behavior,
+ # for manual and automated testing config
+ parser.add_argument("--test-options", help=argparse.SUPPRESS)
+
parser.add_argument("-c", "--connect", dest="uri",
help="Connect to hypervisor at URI", metavar="URI")
parser.add_argument("--debug", action="store_true",
@@ -169,6 +173,31 @@ def parse_commandline():
return parser.parse_known_args()
+class CLITestOptionsClass:
+ """
+ Helper class for parsing and tracking --test-* options
+ """
+ def __init__(self, test_options_str):
+ opts = []
+ if test_options_str:
+ opts = test_options_str.split(",")
+
+ def _get(optname):
+ if optname not in opts:
+ return False
+ opts.remove(optname)
+ return True
+
+ self.first_run = _get("first-run")
+ self.leak_debug = _get("leak-debug")
+ self.old_poll = _get("old-poll")
+ self.no_events = _get("no-events")
+
+ if opts:
+ print("Unknown --test-options keys: %s" % opts)
+ sys.exit(1)
+
+
def main():
(options, leftovers) = parse_commandline()
@@ -186,9 +215,19 @@ def main():
mainloop=(options.trace_libvirt == "mainloop"),
regex=None)
+ CLITestOptions = CLITestOptionsClass(options.test_options)
+ if options.test_first_run:
+ CLITestOptions.first_run = True
+ if options.test_leak_debug:
+ CLITestOptions.leak_debug = True
+ if options.test_no_events:
+ CLITestOptions.no_events = True
+ if options.test_old_poll:
+ CLITestOptions.old_poll = True
+
# With F27 gnome+wayland we need to set these before GTK import
os.environ["GSETTINGS_SCHEMA_DIR"] = CLIConfig.gsettings_dir
- if options.test_first_run:
+ if CLITestOptions.first_run:
os.environ["GSETTINGS_BACKEND"] = "memory"
# Now we've got basic environment up & running we can fork
@@ -219,16 +258,14 @@ def main():
Gtk.get_minor_version(),
Gtk.get_micro_version())
- config = virtManager.config.vmmConfig.get_instance(CLIConfig,
- options.test_first_run)
- config.test_leak_debug = options.test_leak_debug
-
if not util.local_libvirt_version() >= 6000:
# We need this version for threaded virConnect access
_show_startup_error(
_("virt-manager requires libvirt 0.6.0 or later."), "")
return
+ # Prime the vmmConfig cache
+ virtManager.config.vmmConfig.get_instance(CLIConfig, CLITestOptions)
# Add our icon dir to icon theme
icon_theme = Gtk.IconTheme.get_default()
@@ -238,11 +275,8 @@ def main():
Gtk.Window.set_default_icon_name("virt-manager")
- import virtManager.connection
- virtManager.connection.FORCE_DISABLE_EVENTS = bool(options.test_no_events)
-
import virtinst.pollhelpers
- virtinst.pollhelpers.FORCE_OLD_POLL = bool(options.test_old_poll)
+ virtinst.pollhelpers.FORCE_OLD_POLL = CLITestOptions.old_poll
show_window = None
domain = None