blob: 364972626b1fe2fdc6bc3a327f3be63700a76304 [file] [log] [blame]
Robert Markoc68e73b2022-09-06 13:30:36 +02001// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Executes tests for temperature command
4 *
5 * Copyright (C) 2022 Sartura Ltd.
6 */
7
Robert Markoc68e73b2022-09-06 13:30:36 +02008#include <command.h>
9#include <dm.h>
10#include <dm/test.h>
11#include <test/test.h>
12#include <test/ut.h>
13
14static int dm_test_cmd_temperature(struct unit_test_state *uts)
15{
16 struct udevice *dev;
17
18 ut_assertok(uclass_get_device(UCLASS_THERMAL, 0, &dev));
19 ut_assertnonnull(dev);
20
21 ut_assertok(console_record_reset_enable());
22
23 /* Test that "temperature list" shows the sandbox device */
24 ut_assertok(run_command("temperature list", 0));
25 ut_assert_nextline("| Device | Driver | Parent");
26 ut_assert_nextline("| thermal | thermal-sandbox | root_driver");
27 ut_assert_console_end();
28
29 /* Test that "temperature get thermal" returns expected value */
30 console_record_reset();
31 ut_assertok(run_command("temperature get thermal", 0));
32 ut_assert_nextline("thermal: 100 C");
33 ut_assert_console_end();
34
35 return 0;
36}
37
38DM_TEST(dm_test_cmd_temperature, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);