From 1ba523011aa5c7237a70587785c31c0d18a90029 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 22 Sep 2017 18:04:55 +0200 Subject: [PATCH] [xharness] Add support for manually reloading devices/simulators from the html UI. (#2753) This is useful when forgetting to plug in a device before launching the web ui. --- tests/xharness/Jenkins.cs | 14 +++++++++++++- tests/xharness/Simulators.cs | 28 ++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs index 34cc6d9a6f..310244ac54 100644 --- a/tests/xharness/Jenkins.cs +++ b/tests/xharness/Jenkins.cs @@ -932,6 +932,12 @@ namespace xharness } } break; + case "/reload-devices": + GC.KeepAlive (Devices.LoadAsync (DeviceLoadLog, force: true)); + break; + case "/reload-simulators": + GC.KeepAlive (Simulators.LoadAsync (SimulatorLoadLog, force: true)); + break; case "/quit": using (var writer = new StreamWriter (response.OutputStream)) { writer.WriteLine (""); @@ -1196,7 +1202,7 @@ namespace xharness #nav { display: inline-block; - width: 300px; + width: 350px; } #nav > * { @@ -1514,6 +1520,12 @@ function oninitialload ()
  • Ignored tests
  • +
  • Reload + +
  • "); } diff --git a/tests/xharness/Simulators.cs b/tests/xharness/Simulators.cs index 3996cbd1b0..ea8163a517 100644 --- a/tests/xharness/Simulators.cs +++ b/tests/xharness/Simulators.cs @@ -26,10 +26,16 @@ namespace xharness public IEnumerable AvailableDevices => available_devices; public IEnumerable AvailableDevicePairs => available_device_pairs; - public async Task LoadAsync (Log log) + public async Task LoadAsync (Log log, bool force = false) { - if (loaded) - return; + if (loaded) { + if (!force) + return; + supported_runtimes.Reset (); + supported_device_types.Reset (); + available_devices.Reset (); + available_device_pairs.Reset (); + } loaded = true; await Task.Run (async () => @@ -497,10 +503,14 @@ namespace xharness } } - public async Task LoadAsync (Log log, bool extra_data = false, bool removed_locked = false) + public async Task LoadAsync (Log log, bool extra_data = false, bool removed_locked = false, bool force = false) { - if (loaded) - return; + if (loaded) { + if (!force) + return; + connected_devices.Reset (); + } + loaded = true; await Task.Run (async () => @@ -726,6 +736,12 @@ namespace xharness completed.Task.Wait (); } + public void Reset () + { + completed = new TaskCompletionSource (); + list.Clear (); + } + public IEnumerator GetEnumerator () { return new Enumerator (this);