From 07968377b340b8343564c7cb86ac0c5d2a7f6718 Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Tue, 15 Apr 2014 17:30:05 +0200 Subject: [PATCH] ecos: fix golden-run runtime conversion BochsController::getTimerTicksPerSecond() only works reliably when the simulation is already running (e.g., after a restore()). This broke timeout conditions for the very first experiment in a FailBochs instance. Change-Id: Ice5f0aa0c6759f2d9341ad4f21d5c346307b4c12 --- src/core/sal/bochs/BochsController.hpp | 4 ++++ src/experiments/ecos_kernel_test/experiment.cc | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index 4b2e3abf..7d5184e2 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -116,6 +116,10 @@ public: */ void fireInterruptDone(); virtual simtime_t getTimerTicks() { return bx_pc_system.time_ticks(); } + /** + * Only works reliably when the simulation has already begun, e.g., after + * calling simulator.restore(). + */ virtual simtime_t getTimerTicksPerSecond() { return bx_pc_system.time_ticks() / bx_pc_system.time_usec() * 1000000; /* imprecise hack */ } /* ******************************************************************** * BochsController-specific (not implemented in SimulatorController!): diff --git a/src/experiments/ecos_kernel_test/experiment.cc b/src/experiments/ecos_kernel_test/experiment.cc index 79a902c2..d9779af0 100644 --- a/src/experiments/ecos_kernel_test/experiment.cc +++ b/src/experiments/ecos_kernel_test/experiment.cc @@ -507,10 +507,7 @@ bool EcosKernelTestExperiment::faultInjection() { readTraceInfo(goldenrun_instr_counter, goldenrun_runtime_ticks, mem1_low, mem1_high, mem2_low, mem2_high, m_variant, m_benchmark); - // convert to microseconds - goldenrun_runtime = (unsigned) - (goldenrun_runtime_ticks * 1000000.0 / simulator.getTimerTicksPerSecond()); - timeout_runtime = goldenrun_runtime + 1000000/18.2; // + 1 timer tick + if (!readELFSymbols(addr_entry, addr_finish, addr_testdata, addr_testdata_size, addr_test_output, addr_errors_corrected, addr_panic, addr_text_start, addr_text_end, @@ -555,6 +552,12 @@ bool EcosKernelTestExperiment::faultInjection() { log << "restoring state" << endl; simulator.restore(statename); + // convert to microseconds (simulator.getTimerTicksPerSecond() only + // works reliably when simulation has begun) + goldenrun_runtime = (unsigned) + (goldenrun_runtime_ticks * 1000000.0 / simulator.getTimerTicksPerSecond()); + timeout_runtime = goldenrun_runtime + 1000000/18.2; // + 1 timer tick + // the outcome of ecos' test case bool ecos_test_passed = false; bool ecos_test_failed = false;