blob: 9ba2ba23d5d447b02c29de9ea65146b2307e5e5f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass2e7d35d2014-02-26 15:59:21 -07002/*
3 * Copyright (c) 2013 Google, Inc
Simon Glass2e7d35d2014-02-26 15:59:21 -07004 */
5
6#include <common.h>
Joe Hershberger40441e02015-05-20 14:27:29 -05007#include <command.h>
Simon Glass24b852a2015-11-08 23:47:45 -07008#include <console.h>
Simon Glass2e7d35d2014-02-26 15:59:21 -07009#include <dm.h>
10#include <errno.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060011#include <log.h>
Simon Glass756ac0b2014-10-04 11:29:50 -060012#include <malloc.h>
Simon Glass401d1c42020-10-30 21:38:53 -060013#include <asm/global_data.h>
Simon Glass3884c982015-11-08 23:47:44 -070014#include <asm/state.h>
Simon Glass2e7d35d2014-02-26 15:59:21 -070015#include <dm/root.h>
16#include <dm/uclass-internal.h>
Simon Glass0e1fad42020-07-19 10:15:37 -060017#include <test/test.h>
18#include <test/test.h>
Joe Hershbergere721b882015-05-20 14:27:27 -050019#include <test/ut.h>
Simon Glass2e7d35d2014-02-26 15:59:21 -070020
21DECLARE_GLOBAL_DATA_PTR;
22
Simon Glass84823562021-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 Glass2e7d35d2014-02-26 15:59:21 -070033{
Simon Glassa7a98752021-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 Glass45d191a2021-03-07 17:35:06 -070036 int ret;
Stephen Warren26e1bec2016-01-27 23:57:46 -070037
Simon Glass45d191a2021-03-07 17:35:06 -070038 ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name);
Simon Glass2e7d35d2014-02-26 15:59:21 -070039
Simon Glass45d191a2021-03-07 17:35:06 -070040 return ret ? CMD_RET_FAILURE : 0;
Simon Glass2e7d35d2014-02-26 15:59:21 -070041}
Joe Hershberger40441e02015-05-20 14:27:29 -050042
Simon Glass09140112020-05-10 11:40:03 -060043int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Joe Hershberger40441e02015-05-20 14:27:29 -050044{
45 const char *test_name = NULL;
46
47 if (argc > 1)
48 test_name = argv[1];
49
Simon Glass409f4a22021-03-07 17:34:46 -070050 return dm_test_run(test_name);
Joe Hershberger40441e02015-05-20 14:27:29 -050051}