summaryrefslogtreecommitdiff
path: root/test/scratchpad.c
blob: c023f1dc72866758912bb621f6efc466b0a8e055 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Copyright 2020 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "system.h"
#include "test_util.h"

/**
 * The first time this test runs, it should pass. After rebooting, the test
 * should fail because the scratchpad register is set to 1.
 */
test_static int test_scratchpad(void)
{
	int rv;
	uint32_t scratch;

	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");

	TEST_EQ(system_get_scratchpad(&scratch), EC_SUCCESS, "%d");
	TEST_EQ(scratch, 1, "%d");

	return EC_SUCCESS;
}

void run_test(int argc, const char **argv)
{
	RUN_TEST(test_scratchpad);
	test_print_result();
}