blob: 9ba2ba23d5d447b02c29de9ea65146b2307e5e5f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassb2c1cac2014-02-26 15:59:21 -07002/*
3 * Copyright (c) 2013 Google, Inc
Simon Glassb2c1cac2014-02-26 15:59:21 -07004 */
5
6#include <common.h>
Joe Hershberger9dc1d712015-05-20 14:27:29 -05007#include <command.h>
Simon Glassa73bda42015-11-08 23:47:45 -07008#include <console.h>
Simon Glassb2c1cac2014-02-26 15:59:21 -07009#include <dm.h>
10#include <errno.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Simon Glass0927a6f2014-10-04 11:29:50 -060012#include <malloc.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060013#include <asm/global_data.h>
Simon Glass2d7c4992015-11-08 23:47:44 -070014#include <asm/state.h>
Simon Glassb2c1cac2014-02-26 15:59:21 -070015#include <dm/root.h>
16#include <dm/uclass-internal.h>
Simon Glass75c4d412020-07-19 10:15:37 -060017#include <test/test.h>
18#include <test/test.h>
Joe Hershberger3a77be52015-05-20 14:27:27 -050019#include <test/ut.h>
Simon Glassb2c1cac2014-02-26 15:59:21 -070020
21DECLARE_GLOBAL_DATA_PTR;
22
Simon Glass1ef74ab2021-03-07 17:35:12 -070023/**
24 * dm_test_run() - Run driver model tests
25 *
26 * Run all the available driver model tests, or a selection
27 *
28 * @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just
29 * "fdt_pre_reloc"), or NULL to run all
30 * @return 0 if all tests passed, 1 if not
31 */
32static int dm_test_run(const char *test_name)
Simon Glassb2c1cac2014-02-26 15:59:21 -070033{
Simon Glassb50211f2021-03-07 17:35:10 -070034 struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test);
35 const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test);
Simon Glass5ed319b2021-03-07 17:35:06 -070036 int ret;
Stephen Warrenfcebff52016-01-27 23:57:46 -070037
Simon Glass5ed319b2021-03-07 17:35:06 -070038 ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name);
Simon Glassb2c1cac2014-02-26 15:59:21 -070039
Simon Glass5ed319b2021-03-07 17:35:06 -070040 return ret ? CMD_RET_FAILURE : 0;
Simon Glassb2c1cac2014-02-26 15:59:21 -070041}
Joe Hershberger9dc1d712015-05-20 14:27:29 -050042
Simon Glassed38aef2020-05-10 11:40:03 -060043int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Joe Hershberger9dc1d712015-05-20 14:27:29 -050044{
45 const char *test_name = NULL;
46
47 if (argc > 1)
48 test_name = argv[1];
49
Simon Glassa1add9d2021-03-07 17:34:46 -070050 return dm_test_run(test_name);
Joe Hershberger9dc1d712015-05-20 14:27:29 -050051}