summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-09-01 10:34:14 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-04 20:32:45 +0000
commitf2046ce3dc510b7c5c2673d291d199cae70fb9d1 (patch)
treee5dec022d61134c0993dc60acf548808b93ae752
parent1764246ee90ccac33bc1e9242c030999c9130fbb (diff)
downloadchrome-ec-f2046ce3dc510b7c5c2673d291d199cae70fb9d1.tar.gz
Flush test coverage information before rebooting emulator
If we reboots the emulator without flushing test coverage information, the test coverage report will be incorrect. Let's fix this by flushing it before every reboot. BUG=chrome-os-partner:19235 TEST=Generate test coverage report and check correctness. BRANCH=None Change-Id: I1eb060e419b767f382325bed841366c491ba56b7 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167770 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/host/reboot.c2
-rw-r--r--common/test_util.c11
-rw-r--r--include/test_util.h6
3 files changed, 18 insertions, 1 deletions
diff --git a/chip/host/reboot.c b/chip/host/reboot.c
index dd7c2b2fe2..526276aede 100644
--- a/chip/host/reboot.c
+++ b/chip/host/reboot.c
@@ -10,9 +10,11 @@
#include "host_test.h"
#include "reboot.h"
+#include "test_util.h"
void emulator_reboot(void)
{
char *argv[] = {strdup(__get_prog_name()), NULL};
+ emulator_flush();
execv(__get_prog_name(), argv);
}
diff --git a/common/test_util.c b/common/test_util.c
index c133ac9d24..d944cca4b6 100644
--- a/common/test_util.c
+++ b/common/test_util.c
@@ -21,9 +21,14 @@ test_mockable void run_test(void) { }
#ifdef TEST_COVERAGE
extern void __gcov_flush(void);
-void test_end_hook(int sig)
+void emulator_flush(void)
{
__gcov_flush();
+}
+
+void test_end_hook(int sig)
+{
+ emulator_flush();
exit(0);
}
@@ -32,6 +37,10 @@ void register_test_end_hook(void)
signal(SIGTERM, test_end_hook);
}
#else
+void emulator_flush(void)
+{
+}
+
void register_test_end_hook(void)
{
}
diff --git a/include/test_util.h b/include/test_util.h
index 160d1cab68..fb333deb16 100644
--- a/include/test_util.h
+++ b/include/test_util.h
@@ -107,4 +107,10 @@ void test_capture_console(int enabled);
/* Get captured console output */
const char *test_get_captured_console(void);
+/*
+ * Flush emulator status. Must be called before emulator reboots or
+ * exits.
+ */
+void emulator_flush(void);
+
#endif /* __CROS_EC_TEST_UTIL_H */