From c30a2f52ce97be9e9bcf955ef260c5f8ac4999e1 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 1 Aug 2016 16:36:14 +0200 Subject: [PATCH] [xharness] Don't run into an infinite loop if failing to run sqlite3. (#515) --- tests/xharness/Simulators.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/xharness/Simulators.cs b/tests/xharness/Simulators.cs index f047d11f38..716d59d4cf 100644 --- a/tests/xharness/Simulators.cs +++ b/tests/xharness/Simulators.cs @@ -158,6 +158,10 @@ namespace xharness watch.Start (); do { + if (failure) { + log.WriteLine ("Failed to edit TCC.db, trying again in 1 second... ", (int) (tcc_edit_timeout - watch.Elapsed.TotalSeconds)); + await Task.Delay (TimeSpan.FromSeconds (1)); + } failure = false; foreach (var bundle_identifier in bundle_identifiers) { var sql = new System.Text.StringBuilder (); @@ -169,16 +173,12 @@ namespace xharness } sql.Append ("\""); var rv = await ProcessHelper.ExecuteCommandAsync ("sqlite3", sql.ToString (), log, TimeSpan.FromSeconds (5)); - if (!rv.Succeeded) + if (!rv.Succeeded) { failure = true; - if (failure) { - if (watch.Elapsed.TotalSeconds > tcc_edit_timeout) - break; - log.WriteLine ("Failed to edit TCC.db, trying again in 1 second... ", (int) (tcc_edit_timeout - watch.Elapsed.TotalSeconds)); - await Task.Delay (TimeSpan.FromSeconds (1)); + break; } } - } while (failure); + } while (failure && watch.Elapsed.TotalSeconds <= tcc_edit_timeout); if (failure) { log.WriteLine ("Failed to edit TCC.db, the test run might hang due to permission request dialogs");