summaryrefslogtreecommitdiff
path: root/common/mock/fpsensor_state_mock.c
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2019-09-23 16:04:20 -0700
committerCommit Bot <commit-bot@chromium.org>2020-02-07 21:27:04 +0000
commit1f5cc901ecc4026ebce41d4eeca602875ad7f4b6 (patch)
tree2c726c1f4096353e7dfa748197683b090ff678e5 /common/mock/fpsensor_state_mock.c
parentf74a01dc024fea492d970300c679aa6acaf2cacc (diff)
downloadchrome-ec-1f5cc901ecc4026ebce41d4eeca602875ad7f4b6.tar.gz
fpsensor: Refactor fpsensor tests into separate binaries
Using separate test binaries helps to prevent state from one set of tests accidentally leaking into other tests. Ideally all unit tests should be completely independent. Since there's a lot of global state in the fpsensor code the separate test binaries should help prevent the state from leaking across tests as we continue to add more. Also, by having a 1:1 correspondence between test binaries and test files, it's clearer what file (and functionality) each set of tests is targeting. BRANCH=none BUG=none TEST=make buildall -j Change-Id: I937a5ffebfe61aa711efbbc2467d15d514fcfbae Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1832748 Commit-Queue: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org> Reviewed-by: Yicheng Li <yichengli@chromium.org>
Diffstat (limited to 'common/mock/fpsensor_state_mock.c')
-rw-r--r--common/mock/fpsensor_state_mock.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/mock/fpsensor_state_mock.c b/common/mock/fpsensor_state_mock.c
new file mode 100644
index 0000000000..629b9a90a6
--- /dev/null
+++ b/common/mock/fpsensor_state_mock.c
@@ -0,0 +1,30 @@
+/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+#include "common.h"
+#include "ec_commands.h"
+#include "test_util.h"
+
+const uint8_t default_fake_tpm_seed[] = {
+ 0xd9, 0x71, 0xaf, 0xc4, 0xcd, 0x36, 0xe3, 0x60, 0xf8, 0x5a, 0xa0,
+ 0xa6, 0x2c, 0xb3, 0xf5, 0xe2, 0xeb, 0xb9, 0xd8, 0x2f, 0xb5, 0x78,
+ 0x5c, 0x79, 0x82, 0xce, 0x06, 0x3f, 0xcc, 0x23, 0xb9, 0xe7,
+};
+BUILD_ASSERT(sizeof(default_fake_tpm_seed) == FP_CONTEXT_TPM_BYTES);
+
+int fpsensor_state_mock_set_tpm_seed(
+ const uint8_t tpm_seed[FP_CONTEXT_TPM_BYTES])
+{
+ struct ec_params_fp_seed params;
+
+ params.struct_version = FP_TEMPLATE_FORMAT_VERSION;
+ memcpy(params.seed, tpm_seed, FP_CONTEXT_TPM_BYTES);
+
+ return test_send_host_command(EC_CMD_FP_SEED, 0, &params,
+ sizeof(params), NULL, 0);
+}