blob: 2a1ea0611dc453be95aa5f5484adac1551e62e04 [file] [log] [blame]
Robert Marko7327b4c2022-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
8#include <common.h>
9#include <command.h>
10#include <dm.h>
11#include <dm/test.h>
12#include <test/test.h>
13#include <test/ut.h>
14
15static int dm_test_cmd_temperature(struct unit_test_state *uts)
16{
17 struct udevice *dev;
18
19 ut_assertok(uclass_get_device(UCLASS_THERMAL, 0, &dev));
20 ut_assertnonnull(dev);
21
22 ut_assertok(console_record_reset_enable());
23
24 /* Test that "temperature list" shows the sandbox device */
25 ut_assertok(run_command("temperature list", 0));
26 ut_assert_nextline("| Device | Driver | Parent");
27 ut_assert_nextline("| thermal | thermal-sandbox | root_driver");
28 ut_assert_console_end();
29
30 /* Test that "temperature get thermal" returns expected value */
31 console_record_reset();
32 ut_assertok(run_command("temperature get thermal", 0));
33 ut_assert_nextline("thermal: 100 C");
34 ut_assert_console_end();
35
36 return 0;
37}
38
39DM_TEST(dm_test_cmd_temperature, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);