summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-08-04 11:19:55 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-20 14:32:44 +0000
commit8270698e589f14239b4942a42b27132af497410b (patch)
treeea10c53f412c229980ea24a6faf8572295b92f75 /test
parentd63ba9739b77bece9e0be136dd256c89ce2fd688 (diff)
downloadchrome-ec-8270698e589f14239b4942a42b27132af497410b.tar.gz
system: fix system_get_scratchpad API
The current API for system_get_scratchpad mixes the status and the value being read. Update the signature to allow both. BRANCH=none BUG=b:195481980 TEST=make testall && zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I3a5f5ad523d507c53a5d474806f58afafb82e70c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3074828 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/kb_scan.c4
-rw-r--r--test/scratchpad.c4
-rw-r--r--test/system.c27
-rw-r--r--test/utils.c5
4 files changed, 26 insertions, 14 deletions
diff --git a/test/kb_scan.c b/test/kb_scan.c
index b3b42813e4..a43808c0c1 100644
--- a/test/kb_scan.c
+++ b/test/kb_scan.c
@@ -557,7 +557,9 @@ static int test_check_boot_down(void)
void test_init(void)
{
- uint32_t state = system_get_scratchpad();
+ uint32_t state;
+
+ system_get_scratchpad(&state);
if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) {
/* Power-F3-ESC */
diff --git a/test/scratchpad.c b/test/scratchpad.c
index eeae7fcb93..1bea76f7a1 100644
--- a/test/scratchpad.c
+++ b/test/scratchpad.c
@@ -15,13 +15,13 @@ test_static int test_scratchpad(void)
int rv;
uint32_t scratch;
- scratch = system_get_scratchpad();
+ TEST_EQ(system_get_scratchpad(&scratch), EC_SUCCESS, "%d");
TEST_EQ(scratch, 0, "%d");
rv = system_set_scratchpad(1);
TEST_EQ(rv, EC_SUCCESS, "%d");
- scratch = system_get_scratchpad();
+ TEST_EQ(system_get_scratchpad(&scratch), EC_SUCCESS, "%d");
TEST_EQ(scratch, 1, "%d");
return EC_SUCCESS;
diff --git a/test/system.c b/test/system.c
index 6874708cc7..79383b82d9 100644
--- a/test/system.c
+++ b/test/system.c
@@ -29,9 +29,9 @@ static int test_reboot_on_shutdown(void)
params.cmd = EC_REBOOT_COLD;
params.flags = EC_REBOOT_FLAG_ON_AP_SHUTDOWN;
- TEST_ASSERT(test_send_host_command(
- EC_CMD_REBOOT_EC, 0, &params,
- sizeof(params), NULL, 0) == EC_SUCCESS);
+ TEST_EQ(test_send_host_command(EC_CMD_REBOOT_EC, 0, &params,
+ sizeof(params), NULL, 0),
+ EC_SUCCESS, "%d");
system_set_scratchpad(TEST_STATE_STEP_2);
test_chipset_off();
@@ -54,16 +54,16 @@ static int test_cancel_reboot(void)
params.cmd = EC_REBOOT_COLD;
params.flags = EC_REBOOT_FLAG_ON_AP_SHUTDOWN;
- TEST_ASSERT(test_send_host_command(
- EC_CMD_REBOOT_EC, 0, &params,
- sizeof(params), NULL, 0) == EC_SUCCESS);
+ TEST_EQ(test_send_host_command(EC_CMD_REBOOT_EC, 0, &params,
+ sizeof(params), NULL, 0),
+ EC_SUCCESS, "%d");
params.cmd = EC_REBOOT_CANCEL;
params.flags = 0;
- TEST_ASSERT(test_send_host_command(
- EC_CMD_REBOOT_EC, 0, &params,
- sizeof(params), NULL, 0) == EC_SUCCESS);
+ TEST_EQ(test_send_host_command(EC_CMD_REBOOT_EC, 0, &params,
+ sizeof(params), NULL, 0),
+ EC_SUCCESS, "%d");
test_chipset_off();
msleep(30);
@@ -94,7 +94,14 @@ static void fail_and_clean_up(void)
void run_test(int argc, char **argv)
{
- uint32_t state = system_get_scratchpad();
+ uint32_t state = 0;
+
+ /* The return value isn't checked here on purpose. The scratchpad file
+ * may exist from a previous run or it may be in a clean state. A
+ * previous run of this test should reset the scratchpad value to 0
+ * regardless of the final result.
+ */
+ system_get_scratchpad(&state);
test_reset();
diff --git a/test/utils.c b/test/utils.c
index 9402e92740..ede0c807ed 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -270,8 +270,11 @@ static int test_shared_mem(void)
static int test_scratchpad(void)
{
+ uint32_t scratchpad_value;
+
system_set_scratchpad(0xfeed);
- TEST_ASSERT(system_get_scratchpad() == 0xfeed);
+ TEST_EQ(system_get_scratchpad(&scratchpad_value), EC_SUCCESS, "%d");
+ TEST_EQ(scratchpad_value, 0xfeed, "%d");
return EC_SUCCESS;
}