blob: 0b46f799591fe888c9c32e590430dbf119189a7e [file] [log] [blame]
Simon Glass3bb4db42022-08-30 21:05:36 -06001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2022 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <tpm_api.h>
10#include <dm/test.h>
11#include <test/test.h>
12#include <test/ut.h>
13
14/* Basic test of the TPM uclass */
15static int dm_test_tpm(struct unit_test_state *uts)
16{
17 struct udevice *dev;
18 char buf[50];
19
20 /* check probe success */
21 ut_assertok(uclass_first_device_err(UCLASS_TPM, &dev));
22 ut_assert(tpm_is_v2(dev));
23
24 ut_assert(tpm_report_state(dev, buf, sizeof(buf)));
25 ut_asserteq_str("init_done=0", buf);
26
27 ut_assertok(tpm_init(dev));
28
29 ut_assert(tpm_report_state(dev, buf, sizeof(buf)));
30 ut_asserteq_str("init_done=1", buf);
31
32 return 0;
33}
34DM_TEST(dm_test_tpm, UT_TESTF_SCAN_FDT);