mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
test: Drop conditional compilation for suites
This is not needed anymore. If a test suite is not built, then it will have no linker-list entries. So we can just check for that and know that the suite is not present. This allows removal of the #ifdefs and the need to keep them in sync with the associated Makefile rules, which has actually failed, since the help does not match what commands are actually present. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
81c5434f49
commit
374203bd2e
2 changed files with 45 additions and 47 deletions
|
@ -120,78 +120,55 @@ SUITE_DECL(seama);
|
||||||
SUITE_DECL(upl);
|
SUITE_DECL(upl);
|
||||||
|
|
||||||
static struct suite suites[] = {
|
static struct suite suites[] = {
|
||||||
#ifdef CONFIG_CMD_BDI
|
|
||||||
SUITE(bdinfo),
|
SUITE(bdinfo),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_UT_BOOTSTD
|
#ifdef CONFIG_UT_BOOTSTD
|
||||||
SUITE_CMD(bootstd, do_ut_bootstd),
|
SUITE_CMD(bootstd, do_ut_bootstd),
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_CMDLINE
|
|
||||||
SUITE(cmd),
|
SUITE(cmd),
|
||||||
#endif
|
|
||||||
SUITE(common),
|
SUITE(common),
|
||||||
#if defined(CONFIG_UT_DM)
|
|
||||||
SUITE(dm),
|
SUITE(dm),
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_UT_ENV)
|
|
||||||
SUITE(env),
|
SUITE(env),
|
||||||
#endif
|
|
||||||
SUITE(exit),
|
SUITE(exit),
|
||||||
#ifdef CONFIG_CMD_FDT
|
|
||||||
SUITE(fdt),
|
SUITE(fdt),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CONSOLE_TRUETYPE
|
|
||||||
SUITE(font),
|
SUITE(font),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_UT_OPTEE
|
#ifdef CONFIG_UT_OPTEE
|
||||||
SUITE_CMD(optee, do_ut_optee),
|
SUITE_CMD(optee, do_ut_optee),
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_UT_OVERLAY
|
#ifdef CONFIG_UT_OVERLAY
|
||||||
SUITE_CMD(overlay, do_ut_overlay),
|
SUITE_CMD(overlay, do_ut_overlay),
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_UT_LIB
|
|
||||||
SUITE(lib),
|
SUITE(lib),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_UT_LOG
|
|
||||||
SUITE(log),
|
SUITE(log),
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && defined(CONFIG_CMD_MMC) \
|
|
||||||
&& defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE)
|
|
||||||
SUITE(mbr),
|
SUITE(mbr),
|
||||||
#endif
|
|
||||||
SUITE(mem),
|
SUITE(mem),
|
||||||
#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
|
|
||||||
SUITE(setexpr),
|
SUITE(setexpr),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_MEASURED_BOOT
|
|
||||||
SUITE(measurement),
|
SUITE(measurement),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_SANDBOX
|
|
||||||
#if CONFIG_IS_ENABLED(BLOBLIST)
|
|
||||||
SUITE(bloblist),
|
SUITE(bloblist),
|
||||||
SUITE(bootm),
|
SUITE(bootm),
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CMD_ADDRMAP
|
|
||||||
SUITE(addrmap),
|
SUITE(addrmap),
|
||||||
#endif
|
|
||||||
#if CONFIG_IS_ENABLED(HUSH_PARSER)
|
|
||||||
SUITE(hush),
|
SUITE(hush),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CMD_LOADM
|
|
||||||
SUITE(loadm),
|
SUITE(loadm),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CMD_PCI_MPS
|
|
||||||
SUITE(pci_mps),
|
SUITE(pci_mps),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CMD_SEAMA
|
|
||||||
SUITE(seama),
|
SUITE(seama),
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CMD_UPL
|
|
||||||
SUITE(upl),
|
SUITE(upl),
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* has_tests() - Check if a suite has tests, i.e. is supported in this build
|
||||||
|
*
|
||||||
|
* If the suite is run using a command, we have to assume that tests may be
|
||||||
|
* present, since we have no visibility
|
||||||
|
*
|
||||||
|
* @ste: Suite to check
|
||||||
|
* Return: true if supported, false if not
|
||||||
|
*/
|
||||||
|
static bool has_tests(struct suite *ste)
|
||||||
|
{
|
||||||
|
int n_ents = ste->end - ste->start;
|
||||||
|
|
||||||
|
return n_ents || ste->cmd;
|
||||||
|
}
|
||||||
|
|
||||||
/** run_suite() - Run a suite of tests */
|
/** run_suite() - Run a suite of tests */
|
||||||
static int run_suite(struct suite *ste, struct cmd_tbl *cmdtp, int flag,
|
static int run_suite(struct suite *ste, struct cmd_tbl *cmdtp, int flag,
|
||||||
int argc, char *const argv[])
|
int argc, char *const argv[])
|
||||||
|
@ -224,10 +201,12 @@ static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
struct suite *ste = &suites[i];
|
struct suite *ste = &suites[i];
|
||||||
char *const argv[] = {(char *)ste->name, NULL};
|
char *const argv[] = {(char *)ste->name, NULL};
|
||||||
|
|
||||||
printf("----Running %s tests----\n", ste->name);
|
if (has_tests(ste)) {
|
||||||
retval = run_suite(ste, cmdtp, flag, 1, argv);
|
printf("----Running %s tests----\n", ste->name);
|
||||||
if (!any_fail)
|
retval = run_suite(ste, cmdtp, flag, 1, argv);
|
||||||
any_fail = retval;
|
if (!any_fail)
|
||||||
|
any_fail = retval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return any_fail;
|
return any_fail;
|
||||||
|
@ -236,9 +215,17 @@ static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
|
int suite_count, i;
|
||||||
const char *flags;
|
const char *flags;
|
||||||
|
|
||||||
printf("Test suites: %d\n", (int)ARRAY_SIZE(suites));
|
for (suite_count = 0, i = 0; i < ARRAY_SIZE(suites); i++) {
|
||||||
|
struct suite *ste = &suites[i];
|
||||||
|
|
||||||
|
if (has_tests(ste))
|
||||||
|
suite_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Test suites: %d\n", suite_count);
|
||||||
printf("Total tests: %d\n", (int)UNIT_TEST_ALL_COUNT());
|
printf("Total tests: %d\n", (int)UNIT_TEST_ALL_COUNT());
|
||||||
|
|
||||||
flags = cmd_arg1(argc, argv);
|
flags = cmd_arg1(argc, argv);
|
||||||
|
@ -253,7 +240,7 @@ static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
|
||||||
if (n_ent)
|
if (n_ent)
|
||||||
printf("%5ld %s\n", n_ent, ste->name);
|
printf("%5ld %s\n", n_ent, ste->name);
|
||||||
else
|
else if (ste->cmd)
|
||||||
printf("%5s %s\n", "?", ste->name);
|
printf("%5s %s\n", "?", ste->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,6 +284,10 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
if (!ste) {
|
if (!ste) {
|
||||||
printf("Suite '%s' not found\n", argv[0]);
|
printf("Suite '%s' not found\n", argv[0]);
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
|
} else if (!has_tests(ste)) {
|
||||||
|
/* perhaps a Kconfig option needs to be set? */
|
||||||
|
printf("Suite '%s' is not enabled\n", argv[0]);
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = run_suite(ste, cmdtp, flag, argc, argv);
|
ret = run_suite(ste, cmdtp, flag, argc, argv);
|
||||||
|
|
|
@ -128,7 +128,7 @@ def process_ut_info(cons, output):
|
||||||
@pytest.mark.buildconfigspec('sandbox')
|
@pytest.mark.buildconfigspec('sandbox')
|
||||||
@pytest.mark.notbuildconfigspec('sandbox_spl')
|
@pytest.mark.notbuildconfigspec('sandbox_spl')
|
||||||
@pytest.mark.notbuildconfigspec('sandbox64')
|
@pytest.mark.notbuildconfigspec('sandbox64')
|
||||||
def test_suite(u_boot_console):
|
def test_suite(u_boot_console, u_boot_config):
|
||||||
"""Perform various checks on the unit tests, including:
|
"""Perform various checks on the unit tests, including:
|
||||||
|
|
||||||
- The number of suites matches that reported by the 'ut info'
|
- The number of suites matches that reported by the 'ut info'
|
||||||
|
@ -141,6 +141,7 @@ def test_suite(u_boot_console):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
cons = u_boot_console
|
cons = u_boot_console
|
||||||
|
buildconfig = u_boot_config.buildconfig
|
||||||
with cons.log.section('Run all unit tests'):
|
with cons.log.section('Run all unit tests'):
|
||||||
# ut hush hush_test_simple_dollar prints "Unknown command" on purpose.
|
# ut hush hush_test_simple_dollar prints "Unknown command" on purpose.
|
||||||
with u_boot_console.disable_check('unknown_command'):
|
with u_boot_console.disable_check('unknown_command'):
|
||||||
|
@ -154,7 +155,13 @@ def test_suite(u_boot_console):
|
||||||
cons.log.info(f'extra {extra}')
|
cons.log.info(f'extra {extra}')
|
||||||
|
|
||||||
# Make sure we got a test count for each suite
|
# Make sure we got a test count for each suite
|
||||||
assert suites - exp_test_count.keys() == set()
|
assert not (suites - exp_test_count.keys())
|
||||||
|
|
||||||
|
# Deal with missing suites
|
||||||
|
with cons.log.section('Check missing suites'):
|
||||||
|
if 'config_cmd_seama' not in buildconfig:
|
||||||
|
cons.log.info("CMD_SEAMA not enabled: Ignoring suite 'seama'")
|
||||||
|
missing.discard('seama')
|
||||||
|
|
||||||
# Run 'ut info' and compare with the log results
|
# Run 'ut info' and compare with the log results
|
||||||
with cons.log.section('Check suite test-counts'):
|
with cons.log.section('Check suite test-counts'):
|
||||||
|
|
Loading…
Add table
Reference in a new issue