From 0038f1e0dfd6738d71e07de60a0240e449d3f787 Mon Sep 17 00:00:00 2001 From: Caveh Jalali Date: Thu, 10 Oct 2019 19:26:23 -0700 Subject: system.c: reset statics for testing this adds a function to reset the state information generated by system_common_pre_init() for testing scenarios that need to call it multiple times. on the EC, main memory (.data + .bss) is reinitialized across sysjumps, so this happens automatically, but we can't really do that from unit tests. so, add a function to reset the relevant static variables to emulate main memory getting reinitialized. BRANCH=none BUG=b:142031466 TEST=make buildall passes Change-Id: I1f65902c21ab6fc17c32388795cfef19c84d8cc8 Signed-off-by: Caveh Jalali Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1855644 Reviewed-by: Jack Rosenthal Reviewed-by: Daisuke Nojiri --- include/system.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/system.h') diff --git a/include/system.h b/include/system.h index 9b6bf0ff48..0d785c6899 100644 --- a/include/system.h +++ b/include/system.h @@ -48,6 +48,13 @@ void system_pre_init(void); */ void system_common_pre_init(void); +/** + * System common re-initialization; called to reset persistent state + * left by system_common_pre_init(). This is useful for testing + * scenarios calling system_common_pre_init() multiple times. + */ +__test_only void system_common_reset_state(void); + /** * Set up flags that should be saved to battery backed RAM. * -- cgit v1.2.1