[gnome-battery-bench] Ability to force stop a test run
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-battery-bench] Ability to force stop a test run
- Date: Wed, 8 Mar 2017 14:04:10 +0000 (UTC)
commit 8ea9fcf59101e3ec2e3a844010e90d3e8b64961f
Author: Christian Kellner <gicmo gnome org>
Date: Tue Mar 7 17:34:06 2017 +0100
Ability to force stop a test run
This will stop the player and skip the playing of the epilogue; the
idea is to use this in emergency situations, e.g. when we are going
to sleep or really running out of battery soon.
src/test-runner.c | 38 ++++++++++++++++++++++++++++++++++++++
src/test-runner.h | 1 +
2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/test-runner.c b/src/test-runner.c
index cd9fa02..3289c8e 100644
--- a/src/test-runner.c
+++ b/src/test-runner.c
@@ -16,6 +16,7 @@ struct _GbbTestRunner {
GbbTestPhase phase;
gboolean stop_requested;
+ gboolean force_stop;
};
struct _GbbTestRunnerClass {
@@ -65,6 +66,12 @@ static void
on_player_finished(GbbEventPlayer *player,
GbbTestRunner *runner)
{
+ if (runner->force_stop) {
+ runner->force_stop = FALSE;
+ runner_set_stopped(runner);
+ return;
+ }
+
if (runner->phase == GBB_TEST_PHASE_PROLOGUE) {
runner_set_phase(runner, GBB_TEST_PHASE_WAITING);
@@ -226,3 +233,34 @@ gbb_test_runner_stop(GbbTestRunner *runner)
runner->stop_requested = TRUE;
}
}
+
+void
+gbb_test_runner_force_stop(GbbTestRunner *runner)
+{
+ switch (runner->phase) {
+ case GBB_TEST_PHASE_STOPPED:
+ /* Nothing to do here */
+ return;
+
+ case GBB_TEST_PHASE_PROLOGUE:
+ case GBB_TEST_PHASE_RUNNING:
+ case GBB_TEST_PHASE_EPILOGUE:
+ /* Player is active in these phases, needs to
+ * be stopped. */
+ gbb_event_player_stop(runner->player);
+ runner_set_phase(runner, GBB_TEST_PHASE_STOPPING);
+
+ /* FALLTHROUGH to set runner->force_stop */
+ case GBB_TEST_PHASE_STOPPING:
+ /* We are stopping the player already,
+ * but we must not play the epilogue */
+ runner->force_stop = TRUE;
+ break;
+
+ case GBB_TEST_PHASE_WAITING:
+ /* No active player, transition directly to the
+ * STOPPED phase. */
+ runner_set_phase(runner, GBB_TEST_PHASE_STOPPED);
+ break;
+ }
+}
diff --git a/src/test-runner.h b/src/test-runner.h
index 53e78a6..32fda21 100644
--- a/src/test-runner.h
+++ b/src/test-runner.h
@@ -42,6 +42,7 @@ GbbTestRun *gbb_test_runner_get_run(GbbTestRunner *runner);
void gbb_test_runner_start(GbbTestRunner *runner);
void gbb_test_runner_stop (GbbTestRunner *runner);
+void gbb_test_runner_force_stop(GbbTestRunner *runner);
#endif /* __TEST_RUNNER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]