aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini2022-09-19 13:19:39 -0400
committerTom Rini2022-09-19 16:07:12 -0400
commite9a1ff9724348408144c7f1c5b5cc26130ba46e5 (patch)
tree68b56f117206d121b4a7e567b0209c02283c98e6 /test
parentb6c50e5831f6ce3800d4b3cf3c7aa35dde8c48d9 (diff)
parentf76f3e3b44328fe6229650540109af93750fd5f0 (diff)
Merge branch 'master' into next
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'test')
-rw-r--r--test/dm/Makefile1
-rw-r--r--test/dm/tpm.c34
2 files changed, 35 insertions, 0 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 52fe178a828..7543df8823c 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -107,6 +107,7 @@ obj-$(CONFIG_SYSINFO_GPIO) += sysinfo-gpio.o
obj-$(CONFIG_UT_DM) += tag.o
obj-$(CONFIG_TEE) += tee.o
obj-$(CONFIG_TIMER) += timer.o
+obj-$(CONFIG_TPM_V2) += tpm.o
obj-$(CONFIG_DM_USB) += usb.o
obj-$(CONFIG_DM_VIDEO) += video.o
ifeq ($(CONFIG_VIRTIO_SANDBOX),y)
diff --git a/test/dm/tpm.c b/test/dm/tpm.c
new file mode 100644
index 00000000000..0b46f799591
--- /dev/null
+++ b/test/dm/tpm.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <tpm_api.h>
+#include <dm/test.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+/* Basic test of the TPM uclass */
+static int dm_test_tpm(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ char buf[50];
+
+ /* check probe success */
+ ut_assertok(uclass_first_device_err(UCLASS_TPM, &dev));
+ ut_assert(tpm_is_v2(dev));
+
+ ut_assert(tpm_report_state(dev, buf, sizeof(buf)));
+ ut_asserteq_str("init_done=0", buf);
+
+ ut_assertok(tpm_init(dev));
+
+ ut_assert(tpm_report_state(dev, buf, sizeof(buf)));
+ ut_asserteq_str("init_done=1", buf);
+
+ return 0;
+}
+DM_TEST(dm_test_tpm, UT_TESTF_SCAN_FDT);