2018-05-06 17:58:06 -04:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-02-26 15:59:21 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2015-05-20 14:27:29 -05:00
|
|
|
#include <command.h>
|
2015-11-08 23:47:45 -07:00
|
|
|
#include <console.h>
|
2014-02-26 15:59:21 -07:00
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
2020-05-10 11:40:05 -06:00
|
|
|
#include <log.h>
|
2014-10-04 11:29:50 -06:00
|
|
|
#include <malloc.h>
|
2020-10-30 21:38:53 -06:00
|
|
|
#include <asm/global_data.h>
|
2015-11-08 23:47:44 -07:00
|
|
|
#include <asm/state.h>
|
2014-02-26 15:59:21 -07:00
|
|
|
#include <dm/root.h>
|
|
|
|
#include <dm/uclass-internal.h>
|
2020-07-19 10:15:37 -06:00
|
|
|
#include <test/test.h>
|
|
|
|
#include <test/test.h>
|
2015-05-20 14:27:27 -05:00
|
|
|
#include <test/ut.h>
|
2014-02-26 15:59:21 -07:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2021-03-07 17:35:12 -07:00
|
|
|
/**
|
|
|
|
* dm_test_run() - Run driver model tests
|
|
|
|
*
|
|
|
|
* Run all the available driver model tests, or a selection
|
|
|
|
*
|
|
|
|
* @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just
|
|
|
|
* "fdt_pre_reloc"), or NULL to run all
|
2022-01-19 18:05:50 +01:00
|
|
|
* Return: 0 if all tests passed, 1 if not
|
2021-03-07 17:35:12 -07:00
|
|
|
*/
|
|
|
|
static int dm_test_run(const char *test_name)
|
2014-02-26 15:59:21 -07:00
|
|
|
{
|
2021-03-07 17:35:10 -07:00
|
|
|
struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test);
|
|
|
|
const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test);
|
2021-03-07 17:35:06 -07:00
|
|
|
int ret;
|
2016-01-27 23:57:46 -07:00
|
|
|
|
2021-03-07 17:35:06 -07:00
|
|
|
ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name);
|
2014-02-26 15:59:21 -07:00
|
|
|
|
2021-03-07 17:35:06 -07:00
|
|
|
return ret ? CMD_RET_FAILURE : 0;
|
2014-02-26 15:59:21 -07:00
|
|
|
}
|
2015-05-20 14:27:29 -05:00
|
|
|
|
2020-05-10 11:40:03 -06:00
|
|
|
int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2015-05-20 14:27:29 -05:00
|
|
|
{
|
|
|
|
const char *test_name = NULL;
|
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
test_name = argv[1];
|
|
|
|
|
2021-03-07 17:34:46 -07:00
|
|
|
return dm_test_run(test_name);
|
2015-05-20 14:27:29 -05:00
|
|
|
}
|