mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
Merge patch series "test: Tidy up the test/ directory"
Simon Glass <sjg@chromium.org> says: Some tests do not use the unit-test framework. Others are in a suite of their own, for no obvious reason. This series tidies this up. Link: https://lore.kernel.org/r/20241102193715.432529-1-sjg@chromium.org
This commit is contained in:
commit
aa482995a8
19 changed files with 205 additions and 394 deletions
|
@ -1,16 +0,0 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Google, Inc
|
|
||||||
* Written by Simon Glass <sjg@chromium.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __TEST_COMPRESSION_H__
|
|
||||||
#define __TEST_COMPRESSION_H__
|
|
||||||
|
|
||||||
#include <test/test.h>
|
|
||||||
|
|
||||||
/* Declare a new compression test */
|
|
||||||
#define COMPRESSION_TEST(_name, _flags) \
|
|
||||||
UNIT_TEST(_name, _flags, compression_test)
|
|
||||||
|
|
||||||
#endif /* __TEST_ENV_H__ */
|
|
|
@ -4,14 +4,8 @@
|
||||||
|
|
||||||
obj-y += test-main.o
|
obj-y += test-main.o
|
||||||
|
|
||||||
ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
|
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o
|
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
|
|
||||||
endif
|
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
|
obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o
|
obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += command_ut.o
|
|
||||||
obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o
|
|
||||||
obj-y += dm/
|
obj-y += dm/
|
||||||
obj-$(CONFIG_FUZZ) += fuzz/
|
obj-$(CONFIG_FUZZ) += fuzz/
|
||||||
ifndef CONFIG_SANDBOX_VPL
|
ifndef CONFIG_SANDBOX_VPL
|
||||||
|
@ -20,16 +14,12 @@ endif
|
||||||
ifneq ($(CONFIG_HUSH_PARSER),)
|
ifneq ($(CONFIG_HUSH_PARSER),)
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += hush/
|
obj-$(CONFIG_$(XPL_)CMDLINE) += hush/
|
||||||
endif
|
endif
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += print_ut.o
|
|
||||||
obj-$(CONFIG_$(XPL_)CMDLINE) += str_ut.o
|
|
||||||
obj-$(CONFIG_UT_TIME) += time_ut.o
|
|
||||||
obj-y += ut.o
|
obj-y += ut.o
|
||||||
|
|
||||||
ifeq ($(CONFIG_XPL_BUILD),)
|
ifeq ($(CONFIG_XPL_BUILD),)
|
||||||
obj-y += boot/
|
obj-y += boot/
|
||||||
obj-$(CONFIG_UNIT_TEST) += common/
|
obj-$(CONFIG_UNIT_TEST) += common/
|
||||||
obj-y += log/
|
obj-y += log/
|
||||||
obj-$(CONFIG_$(XPL_)UT_UNICODE) += unicode_ut.o
|
|
||||||
else
|
else
|
||||||
obj-$(CONFIG_SPL_UT_LOAD) += image/
|
obj-$(CONFIG_SPL_UT_LOAD) += image/
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -10,6 +10,9 @@ obj-$(CONFIG_EXPO) += expo.o
|
||||||
obj-$(CONFIG_CEDIT) += cedit.o
|
obj-$(CONFIG_CEDIT) += cedit.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef CONFIG_SANDBOX
|
||||||
|
obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
|
||||||
|
endif
|
||||||
obj-$(CONFIG_MEASURED_BOOT) += measurement.o
|
obj-$(CONFIG_MEASURED_BOOT) += measurement.o
|
||||||
|
|
||||||
ifdef CONFIG_OF_LIVE
|
ifdef CONFIG_OF_LIVE
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
obj-y += cmd_ut_cmd.o
|
obj-y += cmd_ut_cmd.o
|
||||||
|
|
||||||
|
obj-$(CONFIG_$(XPL_)CMDLINE) += command.o
|
||||||
ifdef CONFIG_HUSH_PARSER
|
ifdef CONFIG_HUSH_PARSER
|
||||||
obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o
|
obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o
|
||||||
endif
|
endif
|
||||||
|
|
108
test/cmd/command.c
Normal file
108
test/cmd/command.c
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012, The Chromium Authors
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEBUG
|
||||||
|
|
||||||
|
#include <command.h>
|
||||||
|
#include <env.h>
|
||||||
|
#include <log.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <linux/errno.h>
|
||||||
|
#include <test/cmd.h>
|
||||||
|
#include <test/ut.h>
|
||||||
|
|
||||||
|
static const char test_cmd[] = "setenv list 1\n setenv list ${list}2; "
|
||||||
|
"setenv list ${list}3\0"
|
||||||
|
"setenv list ${list}4";
|
||||||
|
|
||||||
|
static int command_test(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
char long_str[CONFIG_SYS_CBSIZE + 42];
|
||||||
|
|
||||||
|
printf("%s: Testing commands\n", __func__);
|
||||||
|
run_command("env default -f -a", 0);
|
||||||
|
|
||||||
|
/* commands separated by \n */
|
||||||
|
run_command_list("setenv list 1\n setenv list ${list}1", -1, 0);
|
||||||
|
ut_assert(!strcmp("11", env_get("list")));
|
||||||
|
|
||||||
|
/* command followed by \n and nothing else */
|
||||||
|
run_command_list("setenv list 1${list}\n", -1, 0);
|
||||||
|
ut_assert(!strcmp("111", env_get("list")));
|
||||||
|
|
||||||
|
/* a command string with \0 in it. Stuff after \0 should be ignored */
|
||||||
|
run_command("setenv list", 0);
|
||||||
|
run_command_list(test_cmd, sizeof(test_cmd), 0);
|
||||||
|
ut_assert(!strcmp("123", env_get("list")));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* a command list where we limit execution to only the first command
|
||||||
|
* using the length parameter.
|
||||||
|
*/
|
||||||
|
run_command_list("setenv list 1\n setenv list ${list}2; "
|
||||||
|
"setenv list ${list}3", strlen("setenv list 1"), 0);
|
||||||
|
ut_assert(!strcmp("1", env_get("list")));
|
||||||
|
|
||||||
|
ut_asserteq(1, run_command("false", 0));
|
||||||
|
ut_assertok(run_command("echo", 0));
|
||||||
|
ut_asserteq(1, run_command_list("false", -1, 0));
|
||||||
|
ut_assertok(run_command_list("echo", -1, 0));
|
||||||
|
|
||||||
|
#ifdef CONFIG_HUSH_PARSER
|
||||||
|
run_command("setenv foo 'setenv black 1\nsetenv adder 2'", 0);
|
||||||
|
run_command("run foo", 0);
|
||||||
|
ut_assertnonnull(env_get("black"));
|
||||||
|
ut_asserteq(0, strcmp("1", env_get("black")));
|
||||||
|
ut_assertnonnull(env_get("adder"));
|
||||||
|
ut_asserteq(0, strcmp("2", env_get("adder")));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ut_assertok(run_command("", 0));
|
||||||
|
ut_assertok(run_command(" ", 0));
|
||||||
|
|
||||||
|
ut_asserteq(1, run_command("'", 0));
|
||||||
|
|
||||||
|
/* Variadic function test-cases */
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat-zero-length"
|
||||||
|
ut_assertok(run_commandf(""));
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
ut_assertok(run_commandf(" "));
|
||||||
|
ut_asserteq(1, run_commandf("'"));
|
||||||
|
|
||||||
|
ut_assertok(run_commandf("env %s %s", "delete -f", "list"));
|
||||||
|
/*
|
||||||
|
* Expected: "## Error: "list" not defined"
|
||||||
|
* (disabled to avoid pytest bailing out)
|
||||||
|
*
|
||||||
|
* ut_asserteq(1, run_commandf("printenv list"));
|
||||||
|
*/
|
||||||
|
|
||||||
|
memset(long_str, 'x', sizeof(long_str));
|
||||||
|
ut_asserteq(-ENOSPC, run_commandf("Truncation case: %s", long_str));
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_HUSH_PARSER)) {
|
||||||
|
ut_assertok(run_commandf("env %s %s %s %s", "delete -f",
|
||||||
|
"adder", "black", "foo"));
|
||||||
|
ut_assertok(run_commandf(
|
||||||
|
"setenv foo 'setenv %s 1\nsetenv %s 2'",
|
||||||
|
"black", "adder"));
|
||||||
|
ut_assertok(run_command("run foo", 0));
|
||||||
|
ut_assertnonnull(env_get("black"));
|
||||||
|
ut_asserteq(0, strcmp("1", env_get("black")));
|
||||||
|
ut_assertnonnull(env_get("adder"));
|
||||||
|
ut_asserteq(0, strcmp("2", env_get("adder")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up before exit */
|
||||||
|
ut_assertok(run_command("env default -f -a", 0));
|
||||||
|
|
||||||
|
/* put back the FDT environment */
|
||||||
|
ut_assertok(env_set("from_fdt", "yes"));
|
||||||
|
|
||||||
|
printf("%s: Everything went swimmingly\n", __func__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CMD_TEST(command_test, 0);
|
|
@ -98,26 +98,16 @@ static struct cmd_tbl cmd_ut_sub[] = {
|
||||||
#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
|
#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
|
||||||
U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "",
|
U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "",
|
||||||
""),
|
""),
|
||||||
#endif
|
|
||||||
U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_ut_print, "", ""),
|
|
||||||
#ifdef CONFIG_UT_TIME
|
|
||||||
U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
|
|
||||||
#endif
|
|
||||||
#if CONFIG_IS_ENABLED(UT_UNICODE) && !defined(API_BUILD)
|
|
||||||
U_BOOT_CMD_MKENT(unicode, CONFIG_SYS_MAXARGS, 1, do_ut_unicode, "", ""),
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_MEASURED_BOOT
|
#ifdef CONFIG_MEASURED_BOOT
|
||||||
U_BOOT_CMD_MKENT(measurement, CONFIG_SYS_MAXARGS, 1, do_ut_measurement,
|
U_BOOT_CMD_MKENT(measurement, CONFIG_SYS_MAXARGS, 1, do_ut_measurement,
|
||||||
"", ""),
|
"", ""),
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SANDBOX
|
#ifdef CONFIG_SANDBOX
|
||||||
U_BOOT_CMD_MKENT(compression, CONFIG_SYS_MAXARGS, 1, do_ut_compression,
|
|
||||||
"", ""),
|
|
||||||
U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist,
|
U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist,
|
||||||
"", ""),
|
"", ""),
|
||||||
U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""),
|
U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""),
|
||||||
#endif
|
#endif
|
||||||
U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""),
|
|
||||||
#ifdef CONFIG_CMD_ADDRMAP
|
#ifdef CONFIG_CMD_ADDRMAP
|
||||||
U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),
|
U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),
|
||||||
#endif
|
#endif
|
||||||
|
@ -207,9 +197,7 @@ U_BOOT_LONGHELP(ut,
|
||||||
#ifdef CONFIG_CMDLINE
|
#ifdef CONFIG_CMDLINE
|
||||||
"\ncmd - test various commands"
|
"\ncmd - test various commands"
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SANDBOX
|
"\ncommon - tests for common/ directory"
|
||||||
"\ncompression - compressors and bootm decompression"
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_UT_DM
|
#ifdef CONFIG_UT_DM
|
||||||
"\ndm - driver model"
|
"\ndm - driver model"
|
||||||
#endif
|
#endif
|
||||||
|
@ -244,20 +232,9 @@ U_BOOT_LONGHELP(ut,
|
||||||
#ifdef CONFIG_CMD_PCI_MPS
|
#ifdef CONFIG_CMD_PCI_MPS
|
||||||
"\npci_mps - PCI Express Maximum Payload Size"
|
"\npci_mps - PCI Express Maximum Payload Size"
|
||||||
#endif
|
#endif
|
||||||
"\nprint - printing things to the console"
|
|
||||||
"\nsetexpr - setexpr command"
|
"\nsetexpr - setexpr command"
|
||||||
#ifdef CONFIG_SANDBOX
|
|
||||||
"\nstr - basic test of string functions"
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CMD_SEAMA
|
#ifdef CONFIG_CMD_SEAMA
|
||||||
"\nseama - seama command parameters loading and decoding"
|
"\nseama - seama command parameters loading and decoding"
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_UT_TIME
|
|
||||||
"\ntime - very basic test of time functions"
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_UT_UNICODE) && \
|
|
||||||
!defined(CONFIG_XPL_BUILD) && !defined(API_BUILD)
|
|
||||||
"\nunicode - Unicode functions"
|
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0+
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2012, The Chromium Authors
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
#include <command.h>
|
|
||||||
#include <env.h>
|
|
||||||
#include <log.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <linux/errno.h>
|
|
||||||
|
|
||||||
static const char test_cmd[] = "setenv list 1\n setenv list ${list}2; "
|
|
||||||
"setenv list ${list}3\0"
|
|
||||||
"setenv list ${list}4";
|
|
||||||
|
|
||||||
static int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
||||||
char *const argv[])
|
|
||||||
{
|
|
||||||
char long_str[CONFIG_SYS_CBSIZE + 42];
|
|
||||||
|
|
||||||
printf("%s: Testing commands\n", __func__);
|
|
||||||
run_command("env default -f -a", 0);
|
|
||||||
|
|
||||||
/* commands separated by \n */
|
|
||||||
run_command_list("setenv list 1\n setenv list ${list}1", -1, 0);
|
|
||||||
assert(!strcmp("11", env_get("list")));
|
|
||||||
|
|
||||||
/* command followed by \n and nothing else */
|
|
||||||
run_command_list("setenv list 1${list}\n", -1, 0);
|
|
||||||
assert(!strcmp("111", env_get("list")));
|
|
||||||
|
|
||||||
/* a command string with \0 in it. Stuff after \0 should be ignored */
|
|
||||||
run_command("setenv list", 0);
|
|
||||||
run_command_list(test_cmd, sizeof(test_cmd), 0);
|
|
||||||
assert(!strcmp("123", env_get("list")));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* a command list where we limit execution to only the first command
|
|
||||||
* using the length parameter.
|
|
||||||
*/
|
|
||||||
run_command_list("setenv list 1\n setenv list ${list}2; "
|
|
||||||
"setenv list ${list}3", strlen("setenv list 1"), 0);
|
|
||||||
assert(!strcmp("1", env_get("list")));
|
|
||||||
|
|
||||||
assert(run_command("false", 0) == 1);
|
|
||||||
assert(run_command("echo", 0) == 0);
|
|
||||||
assert(run_command_list("false", -1, 0) == 1);
|
|
||||||
assert(run_command_list("echo", -1, 0) == 0);
|
|
||||||
|
|
||||||
#ifdef CONFIG_HUSH_PARSER
|
|
||||||
run_command("setenv foo 'setenv black 1\nsetenv adder 2'", 0);
|
|
||||||
run_command("run foo", 0);
|
|
||||||
assert(env_get("black") != NULL);
|
|
||||||
assert(!strcmp("1", env_get("black")));
|
|
||||||
assert(env_get("adder") != NULL);
|
|
||||||
assert(!strcmp("2", env_get("adder")));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(run_command("", 0) == 0);
|
|
||||||
assert(run_command(" ", 0) == 0);
|
|
||||||
|
|
||||||
assert(run_command("'", 0) == 1);
|
|
||||||
|
|
||||||
/* Variadic function test-cases */
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wformat-zero-length"
|
|
||||||
assert(run_commandf("") == 0);
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
assert(run_commandf(" ") == 0);
|
|
||||||
assert(run_commandf("'") == 1);
|
|
||||||
|
|
||||||
assert(run_commandf("env %s %s", "delete -f", "list") == 0);
|
|
||||||
/* Expected: "Error: "list" not defined" */
|
|
||||||
assert(run_commandf("printenv list") == 1);
|
|
||||||
|
|
||||||
memset(long_str, 'x', sizeof(long_str));
|
|
||||||
assert(run_commandf("Truncation case: %s", long_str) == -ENOSPC);
|
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_HUSH_PARSER)) {
|
|
||||||
assert(run_commandf("env %s %s %s %s", "delete -f", "adder",
|
|
||||||
"black", "foo") == 0);
|
|
||||||
assert(run_commandf("setenv foo 'setenv %s 1\nsetenv %s 2'",
|
|
||||||
"black", "adder") == 0);
|
|
||||||
run_command("run foo", 0);
|
|
||||||
assert(env_get("black"));
|
|
||||||
assert(!strcmp("1", env_get("black")));
|
|
||||||
assert(env_get("adder"));
|
|
||||||
assert(!strcmp("2", env_get("adder")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up before exit */
|
|
||||||
run_command("env default -f -a", 0);
|
|
||||||
|
|
||||||
printf("%s: Everything went swimmingly\n", __func__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
U_BOOT_CMD(
|
|
||||||
ut_cmd, 5, 1, do_ut_cmd,
|
|
||||||
"Very basic test of command parsers",
|
|
||||||
""
|
|
||||||
);
|
|
|
@ -1,20 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
OUTPUT_DIR=sandbox
|
|
||||||
|
|
||||||
fail() {
|
|
||||||
echo "Test failed: $1"
|
|
||||||
if [ -n ${tmp} ]; then
|
|
||||||
rm ${tmp}
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
build_uboot() {
|
|
||||||
echo "Build sandbox"
|
|
||||||
OPTS="O=${OUTPUT_DIR} $1"
|
|
||||||
NUM_CPUS=$(nproc)
|
|
||||||
echo ${OPTS}
|
|
||||||
make ${OPTS} sandbox_config
|
|
||||||
make ${OPTS} -s -j${NUM_CPUS}
|
|
||||||
}
|
|
|
@ -1,6 +1,10 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0+
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
obj-y += cmd_ut_common.o
|
obj-y += cmd_ut_common.o
|
||||||
obj-$(CONFIG_AUTOBOOT) += test_autoboot.o
|
obj-$(CONFIG_AUTOBOOT) += test_autoboot.o
|
||||||
|
ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
|
||||||
|
obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o
|
||||||
|
endif
|
||||||
obj-$(CONFIG_CYCLIC) += cyclic.o
|
obj-$(CONFIG_CYCLIC) += cyclic.o
|
||||||
obj-$(CONFIG_EVENT_DYNAMIC) += event.o
|
obj-$(CONFIG_EVENT_DYNAMIC) += event.o
|
||||||
obj-y += cread.o
|
obj-y += cread.o
|
||||||
|
obj-$(CONFIG_$(XPL_)CMDLINE) += print.o
|
||||||
|
|
|
@ -6,13 +6,10 @@
|
||||||
#include <bloblist.h>
|
#include <bloblist.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
#include <asm/global_data.h>
|
|
||||||
#include <test/suites.h>
|
#include <test/suites.h>
|
||||||
#include <test/test.h>
|
#include <test/test.h>
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
|
|
||||||
/* Declare a new bloblist test */
|
/* Declare a new bloblist test */
|
||||||
#define BLOBLIST_TEST(_name, _flags) \
|
#define BLOBLIST_TEST(_name, _flags) \
|
||||||
UNIT_TEST(_name, _flags, bloblist_test)
|
UNIT_TEST(_name, _flags, bloblist_test)
|
|
@ -11,7 +11,7 @@
|
||||||
#include <version_string.h>
|
#include <version_string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vsprintf.h>
|
#include <vsprintf.h>
|
||||||
#include <test/suites.h>
|
#include <test/common.h>
|
||||||
#include <test/test.h>
|
#include <test/test.h>
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@
|
||||||
#define FAKE_BUILD_TAG "jenkins-u-boot-denx_uboot_dm-master-build-aarch64" \
|
#define FAKE_BUILD_TAG "jenkins-u-boot-denx_uboot_dm-master-build-aarch64" \
|
||||||
"and a lot more text to come"
|
"and a lot more text to come"
|
||||||
|
|
||||||
/* Declare a new print test */
|
|
||||||
#define PRINT_TEST(_name, _flags) UNIT_TEST(_name, _flags, print_test)
|
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(LIB_UUID)
|
#if CONFIG_IS_ENABLED(LIB_UUID)
|
||||||
/* Test printing GUIDs */
|
/* Test printing GUIDs */
|
||||||
static int print_guid(struct unit_test_state *uts)
|
static int print_guid(struct unit_test_state *uts)
|
||||||
|
@ -59,7 +56,7 @@ static int print_guid(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_TEST(print_guid, 0);
|
COMMON_TEST(print_guid, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
|
#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
|
||||||
|
@ -95,7 +92,7 @@ static int print_efi_ut(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_TEST(print_efi_ut, 0);
|
COMMON_TEST(print_efi_ut, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int print_printf(struct unit_test_state *uts)
|
static int print_printf(struct unit_test_state *uts)
|
||||||
|
@ -163,7 +160,7 @@ static int print_printf(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_TEST(print_printf, 0);
|
COMMON_TEST(print_printf, 0);
|
||||||
|
|
||||||
static int print_display_buffer(struct unit_test_state *uts)
|
static int print_display_buffer(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -238,7 +235,7 @@ static int print_display_buffer(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_TEST(print_display_buffer, UTF_CONSOLE);
|
COMMON_TEST(print_display_buffer, UTF_CONSOLE);
|
||||||
|
|
||||||
static int print_hexdump_line(struct unit_test_state *uts)
|
static int print_hexdump_line(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -264,7 +261,7 @@ static int print_hexdump_line(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_TEST(print_hexdump_line, UTF_CONSOLE);
|
COMMON_TEST(print_hexdump_line, UTF_CONSOLE);
|
||||||
|
|
||||||
static int print_do_hex_dump(struct unit_test_state *uts)
|
static int print_do_hex_dump(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -350,7 +347,7 @@ static int print_do_hex_dump(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_TEST(print_do_hex_dump, UTF_CONSOLE);
|
COMMON_TEST(print_do_hex_dump, UTF_CONSOLE);
|
||||||
|
|
||||||
static int snprint(struct unit_test_state *uts)
|
static int snprint(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -376,12 +373,4 @@ static int snprint(struct unit_test_state *uts)
|
||||||
ut_asserteq(8, ret);
|
ut_asserteq(8, ret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_TEST(snprint, 0);
|
COMMON_TEST(snprint, 0);
|
||||||
|
|
||||||
int do_ut_print(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
||||||
{
|
|
||||||
struct unit_test *tests = UNIT_TEST_SUITE_START(print_test);
|
|
||||||
const int n_ents = UNIT_TEST_SUITE_COUNT(print_test);
|
|
||||||
|
|
||||||
return cmd_ut_category("print", "print_", tests, n_ents, argc, argv);
|
|
||||||
}
|
|
|
@ -2,6 +2,9 @@
|
||||||
#
|
#
|
||||||
# (C) Copyright 2018
|
# (C) Copyright 2018
|
||||||
# Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
|
# Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
|
||||||
|
|
||||||
|
obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o
|
||||||
|
|
||||||
ifeq ($(CONFIG_XPL_BUILD),)
|
ifeq ($(CONFIG_XPL_BUILD),)
|
||||||
obj-y += cmd_ut_lib.o
|
obj-y += cmd_ut_lib.o
|
||||||
obj-y += abuf.o
|
obj-y += abuf.o
|
||||||
|
@ -14,6 +17,7 @@ obj-y += lmb.o
|
||||||
obj-$(CONFIG_HAVE_SETJMP) += longjmp.o
|
obj-$(CONFIG_HAVE_SETJMP) += longjmp.o
|
||||||
obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
|
obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
|
||||||
obj-$(CONFIG_SSCANF) += sscanf.o
|
obj-$(CONFIG_SSCANF) += sscanf.o
|
||||||
|
obj-$(CONFIG_$(XPL_)CMDLINE) += str.o
|
||||||
obj-y += string.o
|
obj-y += string.o
|
||||||
obj-y += strlcat.o
|
obj-y += strlcat.o
|
||||||
obj-$(CONFIG_ERRNO_STR) += test_errno_str.o
|
obj-$(CONFIG_ERRNO_STR) += test_errno_str.o
|
||||||
|
@ -23,6 +27,8 @@ obj-$(CONFIG_AES) += test_aes.o
|
||||||
obj-$(CONFIG_GETOPT) += getopt.o
|
obj-$(CONFIG_GETOPT) += getopt.o
|
||||||
obj-$(CONFIG_CRC8) += test_crc8.o
|
obj-$(CONFIG_CRC8) += test_crc8.o
|
||||||
obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o
|
obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o
|
||||||
|
obj-$(CONFIG_UT_TIME) += time.o
|
||||||
|
obj-$(CONFIG_$(XPL_)UT_UNICODE) += unicode.o
|
||||||
obj-$(CONFIG_LIB_UUID) += uuid.o
|
obj-$(CONFIG_LIB_UUID) += uuid.o
|
||||||
else
|
else
|
||||||
obj-$(CONFIG_SANDBOX) += kconfig_spl.o
|
obj-$(CONFIG_SANDBOX) += kconfig_spl.o
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
|
|
||||||
#include <linux/lzo.h>
|
#include <linux/lzo.h>
|
||||||
#include <linux/zstd.h>
|
#include <linux/zstd.h>
|
||||||
#include <test/compression.h>
|
#include <test/lib.h>
|
||||||
#include <test/suites.h>
|
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
|
||||||
static const char plain[] =
|
static const char plain[] =
|
||||||
|
@ -471,40 +470,40 @@ static int compression_test_gzip(struct unit_test_state *uts)
|
||||||
return run_test(uts, "gzip", compress_using_gzip,
|
return run_test(uts, "gzip", compress_using_gzip,
|
||||||
uncompress_using_gzip);
|
uncompress_using_gzip);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_gzip, 0);
|
LIB_TEST(compression_test_gzip, 0);
|
||||||
|
|
||||||
static int compression_test_bzip2(struct unit_test_state *uts)
|
static int compression_test_bzip2(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_test(uts, "bzip2", compress_using_bzip2,
|
return run_test(uts, "bzip2", compress_using_bzip2,
|
||||||
uncompress_using_bzip2);
|
uncompress_using_bzip2);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bzip2, 0);
|
LIB_TEST(compression_test_bzip2, 0);
|
||||||
|
|
||||||
static int compression_test_lzma(struct unit_test_state *uts)
|
static int compression_test_lzma(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_test(uts, "lzma", compress_using_lzma,
|
return run_test(uts, "lzma", compress_using_lzma,
|
||||||
uncompress_using_lzma);
|
uncompress_using_lzma);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_lzma, 0);
|
LIB_TEST(compression_test_lzma, 0);
|
||||||
|
|
||||||
static int compression_test_lzo(struct unit_test_state *uts)
|
static int compression_test_lzo(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_test(uts, "lzo", compress_using_lzo, uncompress_using_lzo);
|
return run_test(uts, "lzo", compress_using_lzo, uncompress_using_lzo);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_lzo, 0);
|
LIB_TEST(compression_test_lzo, 0);
|
||||||
|
|
||||||
static int compression_test_lz4(struct unit_test_state *uts)
|
static int compression_test_lz4(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_test(uts, "lz4", compress_using_lz4, uncompress_using_lz4);
|
return run_test(uts, "lz4", compress_using_lz4, uncompress_using_lz4);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_lz4, 0);
|
LIB_TEST(compression_test_lz4, 0);
|
||||||
|
|
||||||
static int compression_test_zstd(struct unit_test_state *uts)
|
static int compression_test_zstd(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_test(uts, "zstd", compress_using_zstd,
|
return run_test(uts, "zstd", compress_using_zstd,
|
||||||
uncompress_using_zstd);
|
uncompress_using_zstd);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_zstd, 0);
|
LIB_TEST(compression_test_zstd, 0);
|
||||||
|
|
||||||
static int compress_using_none(struct unit_test_state *uts,
|
static int compress_using_none(struct unit_test_state *uts,
|
||||||
void *in, unsigned long in_size,
|
void *in, unsigned long in_size,
|
||||||
|
@ -570,50 +569,40 @@ static int compression_test_bootm_gzip(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_bootm_test(uts, IH_COMP_GZIP, compress_using_gzip);
|
return run_bootm_test(uts, IH_COMP_GZIP, compress_using_gzip);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bootm_gzip, 0);
|
LIB_TEST(compression_test_bootm_gzip, 0);
|
||||||
|
|
||||||
static int compression_test_bootm_bzip2(struct unit_test_state *uts)
|
static int compression_test_bootm_bzip2(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_bootm_test(uts, IH_COMP_BZIP2, compress_using_bzip2);
|
return run_bootm_test(uts, IH_COMP_BZIP2, compress_using_bzip2);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bootm_bzip2, 0);
|
LIB_TEST(compression_test_bootm_bzip2, 0);
|
||||||
|
|
||||||
static int compression_test_bootm_lzma(struct unit_test_state *uts)
|
static int compression_test_bootm_lzma(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_bootm_test(uts, IH_COMP_LZMA, compress_using_lzma);
|
return run_bootm_test(uts, IH_COMP_LZMA, compress_using_lzma);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bootm_lzma, 0);
|
LIB_TEST(compression_test_bootm_lzma, 0);
|
||||||
|
|
||||||
static int compression_test_bootm_lzo(struct unit_test_state *uts)
|
static int compression_test_bootm_lzo(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_bootm_test(uts, IH_COMP_LZO, compress_using_lzo);
|
return run_bootm_test(uts, IH_COMP_LZO, compress_using_lzo);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bootm_lzo, 0);
|
LIB_TEST(compression_test_bootm_lzo, 0);
|
||||||
|
|
||||||
static int compression_test_bootm_lz4(struct unit_test_state *uts)
|
static int compression_test_bootm_lz4(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_bootm_test(uts, IH_COMP_LZ4, compress_using_lz4);
|
return run_bootm_test(uts, IH_COMP_LZ4, compress_using_lz4);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bootm_lz4, 0);
|
LIB_TEST(compression_test_bootm_lz4, 0);
|
||||||
|
|
||||||
static int compression_test_bootm_zstd(struct unit_test_state *uts)
|
static int compression_test_bootm_zstd(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_bootm_test(uts, IH_COMP_ZSTD, compress_using_zstd);
|
return run_bootm_test(uts, IH_COMP_ZSTD, compress_using_zstd);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bootm_zstd, 0);
|
LIB_TEST(compression_test_bootm_zstd, 0);
|
||||||
|
|
||||||
static int compression_test_bootm_none(struct unit_test_state *uts)
|
static int compression_test_bootm_none(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
return run_bootm_test(uts, IH_COMP_NONE, compress_using_none);
|
return run_bootm_test(uts, IH_COMP_NONE, compress_using_none);
|
||||||
}
|
}
|
||||||
COMPRESSION_TEST(compression_test_bootm_none, 0);
|
LIB_TEST(compression_test_bootm_none, 0);
|
||||||
|
|
||||||
int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
||||||
char *const argv[])
|
|
||||||
{
|
|
||||||
struct unit_test *tests = UNIT_TEST_SUITE_START(compression_test);
|
|
||||||
const int n_ents = UNIT_TEST_SUITE_COUNT(compression_test);
|
|
||||||
|
|
||||||
return cmd_ut_category("compression", "compression_test_",
|
|
||||||
tests, n_ents, argc, argv);
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vsprintf.h>
|
#include <vsprintf.h>
|
||||||
#include <test/suites.h>
|
#include <test/lib.h>
|
||||||
#include <test/test.h>
|
#include <test/test.h>
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
|
||||||
|
@ -19,9 +19,6 @@ static const char str5[] = "0x9876543210the last time I was deloused";
|
||||||
static const char str6[] = "0778octal is seldom used";
|
static const char str6[] = "0778octal is seldom used";
|
||||||
static const char str7[] = "707it is a piece of computing history";
|
static const char str7[] = "707it is a piece of computing history";
|
||||||
|
|
||||||
/* Declare a new str test */
|
|
||||||
#define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test)
|
|
||||||
|
|
||||||
static int str_upper(struct unit_test_state *uts)
|
static int str_upper(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
char out[TEST_STR_SIZE];
|
char out[TEST_STR_SIZE];
|
||||||
|
@ -58,7 +55,7 @@ static int str_upper(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_upper, 0);
|
LIB_TEST(str_upper, 0);
|
||||||
|
|
||||||
static int run_strtoul(struct unit_test_state *uts, const char *str, int base,
|
static int run_strtoul(struct unit_test_state *uts, const char *str, int base,
|
||||||
ulong expect_val, int expect_endp_offset, bool upper)
|
ulong expect_val, int expect_endp_offset, bool upper)
|
||||||
|
@ -112,7 +109,7 @@ static int str_simple_strtoul(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_simple_strtoul, 0);
|
LIB_TEST(str_simple_strtoul, 0);
|
||||||
|
|
||||||
static int run_strtoull(struct unit_test_state *uts, const char *str, int base,
|
static int run_strtoull(struct unit_test_state *uts, const char *str, int base,
|
||||||
unsigned long long expect_val, int expect_endp_offset,
|
unsigned long long expect_val, int expect_endp_offset,
|
||||||
|
@ -175,7 +172,7 @@ static int str_simple_strtoull(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_simple_strtoull, 0);
|
LIB_TEST(str_simple_strtoull, 0);
|
||||||
|
|
||||||
static int str_hextoul(struct unit_test_state *uts)
|
static int str_hextoul(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +184,7 @@ static int str_hextoul(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_hextoul, 0);
|
LIB_TEST(str_hextoul, 0);
|
||||||
|
|
||||||
static int str_dectoul(struct unit_test_state *uts)
|
static int str_dectoul(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -199,7 +196,7 @@ static int str_dectoul(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_dectoul, 0);
|
LIB_TEST(str_dectoul, 0);
|
||||||
|
|
||||||
static int str_itoa(struct unit_test_state *uts)
|
static int str_itoa(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -219,7 +216,7 @@ static int str_itoa(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_itoa, 0);
|
LIB_TEST(str_itoa, 0);
|
||||||
|
|
||||||
static int str_xtoa(struct unit_test_state *uts)
|
static int str_xtoa(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -239,7 +236,7 @@ static int str_xtoa(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_xtoa, 0);
|
LIB_TEST(str_xtoa, 0);
|
||||||
|
|
||||||
static int str_trailing(struct unit_test_state *uts)
|
static int str_trailing(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -271,7 +268,7 @@ static int str_trailing(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(str_trailing, 0);
|
LIB_TEST(str_trailing, 0);
|
||||||
|
|
||||||
static int test_str_to_list(struct unit_test_state *uts)
|
static int test_str_to_list(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -351,12 +348,4 @@ static int test_str_to_list(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
STR_TEST(test_str_to_list, 0);
|
LIB_TEST(test_str_to_list, 0);
|
||||||
|
|
||||||
int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
||||||
{
|
|
||||||
struct unit_test *tests = UNIT_TEST_SUITE_START(str_test);
|
|
||||||
const int n_ents = UNIT_TEST_SUITE_COUNT(str_test);
|
|
||||||
|
|
||||||
return cmd_ut_category("str", "str_", tests, n_ents, argc, argv);
|
|
||||||
}
|
|
|
@ -4,12 +4,13 @@
|
||||||
* Written by Simon Glass <sjg@chromium.org>
|
* Written by Simon Glass <sjg@chromium.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <command.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <test/lib.h>
|
||||||
|
#include <test/ut.h>
|
||||||
|
|
||||||
static int test_get_timer(void)
|
static int test_get_timer(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
ulong base, start, next, diff;
|
ulong base, start, next, diff;
|
||||||
int iter;
|
int iter;
|
||||||
|
@ -21,11 +22,7 @@ static int test_get_timer(void)
|
||||||
next = get_timer(0);
|
next = get_timer(0);
|
||||||
} while (start == next);
|
} while (start == next);
|
||||||
|
|
||||||
if (start + 1 != next) {
|
ut_asserteq(start + 1, next);
|
||||||
printf("%s: iter=%d, start=%lu, next=%lu, expected a difference of 1\n",
|
|
||||||
__func__, iter, start, next);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,16 +31,13 @@ static int test_get_timer(void)
|
||||||
* an extra millisecond may have passed.
|
* an extra millisecond may have passed.
|
||||||
*/
|
*/
|
||||||
diff = get_timer(base);
|
diff = get_timer(base);
|
||||||
if (diff != iter && diff != iter + 1) {
|
ut_assert(diff == iter || diff == iter + 1);
|
||||||
printf("%s: expected get_timer(base) to match elapsed time: diff=%lu, expected=%d\n",
|
|
||||||
__func__, diff, iter);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
LIB_TEST(test_get_timer, 0);
|
||||||
|
|
||||||
static int test_timer_get_us(void)
|
static int test_timer_get_us(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
ulong prev, next, min = 1000000;
|
ulong prev, next, min = 1000000;
|
||||||
long delta;
|
long delta;
|
||||||
|
@ -55,11 +49,8 @@ static int test_timer_get_us(void)
|
||||||
next = timer_get_us();
|
next = timer_get_us();
|
||||||
if (next != prev) {
|
if (next != prev) {
|
||||||
delta = next - prev;
|
delta = next - prev;
|
||||||
if (delta < 0) {
|
ut_assert(delta >= 0);
|
||||||
printf("%s: timer_get_us() went backwards from %lu to %lu\n",
|
if (delta) {
|
||||||
__func__, prev, next);
|
|
||||||
return -EINVAL;
|
|
||||||
} else if (delta != 0) {
|
|
||||||
if (delta < min)
|
if (delta < min)
|
||||||
min = delta;
|
min = delta;
|
||||||
prev = next;
|
prev = next;
|
||||||
|
@ -68,16 +59,13 @@ static int test_timer_get_us(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min != 1) {
|
ut_asserteq(1, min);
|
||||||
printf("%s: Minimum microsecond delta should be 1 but is %lu\n",
|
|
||||||
__func__, min);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
LIB_TEST(test_timer_get_us, 0);
|
||||||
|
|
||||||
static int test_time_comparison(void)
|
static int test_time_comparison(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
ulong start_us, end_us, delta_us;
|
ulong start_us, end_us, delta_us;
|
||||||
long error;
|
long error;
|
||||||
|
@ -92,13 +80,13 @@ static int test_time_comparison(void)
|
||||||
error = delta_us - 1000000;
|
error = delta_us - 1000000;
|
||||||
printf("%s: Microsecond time for 1 second: %lu, error = %ld\n",
|
printf("%s: Microsecond time for 1 second: %lu, error = %ld\n",
|
||||||
__func__, delta_us, error);
|
__func__, delta_us, error);
|
||||||
if (abs(error) > 1000)
|
ut_assert(abs(error) <= 1000);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
LIB_TEST(test_time_comparison, 0);
|
||||||
|
|
||||||
static int test_udelay(void)
|
static int test_udelay(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
long error;
|
long error;
|
||||||
ulong start, delta;
|
ulong start, delta;
|
||||||
|
@ -111,22 +99,8 @@ static int test_udelay(void)
|
||||||
error = delta - 1000;
|
error = delta - 1000;
|
||||||
printf("%s: Delay time for 1000 udelay(1000): %lu ms, error = %ld\n",
|
printf("%s: Delay time for 1000 udelay(1000): %lu ms, error = %ld\n",
|
||||||
__func__, delta, error);
|
__func__, delta, error);
|
||||||
if (abs(error) > 100)
|
ut_assert(abs(error) <= 100);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
LIB_TEST(test_udelay, 0);
|
||||||
int do_ut_time(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
ret |= test_get_timer();
|
|
||||||
ret |= test_timer_get_us();
|
|
||||||
ret |= test_time_comparison();
|
|
||||||
ret |= test_udelay();
|
|
||||||
|
|
||||||
printf("Test %s\n", ret ? "failed" : "passed");
|
|
||||||
|
|
||||||
return ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
|
|
||||||
}
|
|
|
@ -11,13 +11,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <test/lib.h>
|
||||||
#include <test/test.h>
|
#include <test/test.h>
|
||||||
#include <test/suites.h>
|
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
|
||||||
/* Linker list entry for a Unicode test */
|
|
||||||
#define UNICODE_TEST(_name) UNIT_TEST(_name, 0, unicode_test)
|
|
||||||
|
|
||||||
/* Constants c1-c4 and d1-d4 encode the same letters */
|
/* Constants c1-c4 and d1-d4 encode the same letters */
|
||||||
|
|
||||||
/* Six characters translating to one utf-8 byte each. */
|
/* Six characters translating to one utf-8 byte each. */
|
||||||
|
@ -64,7 +61,7 @@ static int unicode_test_u16_strlen(struct unit_test_state *uts)
|
||||||
ut_asserteq(6, u16_strlen(c4));
|
ut_asserteq(6, u16_strlen(c4));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strlen);
|
LIB_TEST(unicode_test_u16_strlen, 0);
|
||||||
|
|
||||||
static int unicode_test_u16_strnlen(struct unit_test_state *uts)
|
static int unicode_test_u16_strnlen(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +72,7 @@ static int unicode_test_u16_strnlen(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strnlen);
|
LIB_TEST(unicode_test_u16_strnlen, 0);
|
||||||
|
|
||||||
static int unicode_test_u16_strdup(struct unit_test_state *uts)
|
static int unicode_test_u16_strdup(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -87,7 +84,7 @@ static int unicode_test_u16_strdup(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strdup);
|
LIB_TEST(unicode_test_u16_strdup, 0);
|
||||||
|
|
||||||
static int unicode_test_u16_strcpy(struct unit_test_state *uts)
|
static int unicode_test_u16_strcpy(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +97,7 @@ static int unicode_test_u16_strcpy(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strcpy);
|
LIB_TEST(unicode_test_u16_strcpy, 0);
|
||||||
|
|
||||||
/* U-Boot uses UTF-16 strings in the EFI context only. */
|
/* U-Boot uses UTF-16 strings in the EFI context only. */
|
||||||
#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
|
#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
|
||||||
|
@ -173,7 +170,7 @@ static int unicode_test_string16(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_string16);
|
LIB_TEST(unicode_test_string16, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int unicode_test_utf8_get(struct unit_test_state *uts)
|
static int unicode_test_utf8_get(struct unit_test_state *uts)
|
||||||
|
@ -218,7 +215,7 @@ static int unicode_test_utf8_get(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_get);
|
LIB_TEST(unicode_test_utf8_get, 0);
|
||||||
|
|
||||||
static int unicode_test_utf8_put(struct unit_test_state *uts)
|
static int unicode_test_utf8_put(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -256,7 +253,7 @@ static int unicode_test_utf8_put(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_put);
|
LIB_TEST(unicode_test_utf8_put, 0);
|
||||||
|
|
||||||
static int unicode_test_utf8_utf16_strlen(struct unit_test_state *uts)
|
static int unicode_test_utf8_utf16_strlen(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +269,7 @@ static int unicode_test_utf8_utf16_strlen(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_utf16_strlen);
|
LIB_TEST(unicode_test_utf8_utf16_strlen, 0);
|
||||||
|
|
||||||
static int unicode_test_utf8_utf16_strnlen(struct unit_test_state *uts)
|
static int unicode_test_utf8_utf16_strnlen(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -290,7 +287,7 @@ static int unicode_test_utf8_utf16_strnlen(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_utf16_strnlen);
|
LIB_TEST(unicode_test_utf8_utf16_strnlen, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ut_u16_strcmp() - Compare to u16 strings.
|
* ut_u16_strcmp() - Compare to u16 strings.
|
||||||
|
@ -354,7 +351,7 @@ static int unicode_test_utf8_utf16_strcpy(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_utf16_strcpy);
|
LIB_TEST(unicode_test_utf8_utf16_strcpy, 0);
|
||||||
|
|
||||||
static int unicode_test_utf8_utf16_strncpy(struct unit_test_state *uts)
|
static int unicode_test_utf8_utf16_strncpy(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -398,7 +395,7 @@ static int unicode_test_utf8_utf16_strncpy(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_utf16_strncpy);
|
LIB_TEST(unicode_test_utf8_utf16_strncpy, 0);
|
||||||
|
|
||||||
static int unicode_test_utf16_get(struct unit_test_state *uts)
|
static int unicode_test_utf16_get(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -424,7 +421,7 @@ static int unicode_test_utf16_get(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf16_get);
|
LIB_TEST(unicode_test_utf16_get, 0);
|
||||||
|
|
||||||
static int unicode_test_utf16_put(struct unit_test_state *uts)
|
static int unicode_test_utf16_put(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -452,7 +449,7 @@ static int unicode_test_utf16_put(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf16_put);
|
LIB_TEST(unicode_test_utf16_put, 0);
|
||||||
|
|
||||||
static int unicode_test_utf16_strnlen(struct unit_test_state *uts)
|
static int unicode_test_utf16_strnlen(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -470,7 +467,7 @@ static int unicode_test_utf16_strnlen(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf16_strnlen);
|
LIB_TEST(unicode_test_utf16_strnlen, 0);
|
||||||
|
|
||||||
static int unicode_test_utf16_utf8_strlen(struct unit_test_state *uts)
|
static int unicode_test_utf16_utf8_strlen(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -486,7 +483,7 @@ static int unicode_test_utf16_utf8_strlen(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf16_utf8_strlen);
|
LIB_TEST(unicode_test_utf16_utf8_strlen, 0);
|
||||||
|
|
||||||
static int unicode_test_utf16_utf8_strnlen(struct unit_test_state *uts)
|
static int unicode_test_utf16_utf8_strnlen(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -498,7 +495,7 @@ static int unicode_test_utf16_utf8_strnlen(struct unit_test_state *uts)
|
||||||
ut_asserteq(12, utf16_utf8_strnlen(c4, 3));
|
ut_asserteq(12, utf16_utf8_strnlen(c4, 3));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf16_utf8_strnlen);
|
LIB_TEST(unicode_test_utf16_utf8_strnlen, 0);
|
||||||
|
|
||||||
static int unicode_test_utf16_utf8_strcpy(struct unit_test_state *uts)
|
static int unicode_test_utf16_utf8_strcpy(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -543,7 +540,7 @@ static int unicode_test_utf16_utf8_strcpy(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf16_utf8_strcpy);
|
LIB_TEST(unicode_test_utf16_utf8_strcpy, 0);
|
||||||
|
|
||||||
static int unicode_test_utf16_utf8_strncpy(struct unit_test_state *uts)
|
static int unicode_test_utf16_utf8_strncpy(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -587,7 +584,7 @@ static int unicode_test_utf16_utf8_strncpy(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf16_utf8_strncpy);
|
LIB_TEST(unicode_test_utf16_utf8_strncpy, 0);
|
||||||
|
|
||||||
static int unicode_test_utf_to_lower(struct unit_test_state *uts)
|
static int unicode_test_utf_to_lower(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -604,7 +601,7 @@ static int unicode_test_utf_to_lower(struct unit_test_state *uts)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf_to_lower);
|
LIB_TEST(unicode_test_utf_to_lower, 0);
|
||||||
|
|
||||||
static int unicode_test_utf_to_upper(struct unit_test_state *uts)
|
static int unicode_test_utf_to_upper(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -621,7 +618,7 @@ static int unicode_test_utf_to_upper(struct unit_test_state *uts)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf_to_upper);
|
LIB_TEST(unicode_test_utf_to_upper, 0);
|
||||||
|
|
||||||
static int unicode_test_u16_strcasecmp(struct unit_test_state *uts)
|
static int unicode_test_u16_strcasecmp(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -646,7 +643,7 @@ static int unicode_test_u16_strcasecmp(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strcasecmp);
|
LIB_TEST(unicode_test_u16_strcasecmp, 0);
|
||||||
|
|
||||||
static int unicode_test_u16_strncmp(struct unit_test_state *uts)
|
static int unicode_test_u16_strncmp(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -659,7 +656,7 @@ static int unicode_test_u16_strncmp(struct unit_test_state *uts)
|
||||||
ut_assert(u16_strcmp(u"deghi", u"abcdef") > 0);
|
ut_assert(u16_strcmp(u"deghi", u"abcdef") > 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strncmp);
|
LIB_TEST(unicode_test_u16_strncmp, 0);
|
||||||
|
|
||||||
static int unicode_test_u16_strsize(struct unit_test_state *uts)
|
static int unicode_test_u16_strsize(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -669,7 +666,7 @@ static int unicode_test_u16_strsize(struct unit_test_state *uts)
|
||||||
ut_asserteq_64(u16_strsize(c4), 14);
|
ut_asserteq_64(u16_strsize(c4), 14);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strsize);
|
LIB_TEST(unicode_test_u16_strsize, 0);
|
||||||
|
|
||||||
static int unicode_test_utf_to_cp(struct unit_test_state *uts)
|
static int unicode_test_utf_to_cp(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
@ -698,7 +695,7 @@ static int unicode_test_utf_to_cp(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf_to_cp);
|
LIB_TEST(unicode_test_utf_to_cp, 0);
|
||||||
|
|
||||||
static void utf8_to_cp437_stream_helper(const char *in, char *out)
|
static void utf8_to_cp437_stream_helper(const char *in, char *out)
|
||||||
{
|
{
|
||||||
|
@ -729,7 +726,7 @@ static int unicode_test_utf8_to_cp437_stream(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_to_cp437_stream);
|
LIB_TEST(unicode_test_utf8_to_cp437_stream, 0);
|
||||||
|
|
||||||
static void utf8_to_utf32_stream_helper(const char *in, s32 *out)
|
static void utf8_to_utf32_stream_helper(const char *in, s32 *out)
|
||||||
{
|
{
|
||||||
|
@ -778,7 +775,7 @@ static int unicode_test_utf8_to_utf32_stream(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_utf8_to_utf32_stream);
|
LIB_TEST(unicode_test_utf8_to_utf32_stream, 0);
|
||||||
|
|
||||||
#ifdef CONFIG_EFI_LOADER
|
#ifdef CONFIG_EFI_LOADER
|
||||||
static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts)
|
static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts)
|
||||||
|
@ -795,7 +792,7 @@ static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_efi_create_indexed_name);
|
LIB_TEST(unicode_test_efi_create_indexed_name, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int unicode_test_u16_strlcat(struct unit_test_state *uts)
|
static int unicode_test_u16_strlcat(struct unit_test_state *uts)
|
||||||
|
@ -846,13 +843,4 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNICODE_TEST(unicode_test_u16_strlcat);
|
LIB_TEST(unicode_test_u16_strlcat, 0);
|
||||||
|
|
||||||
int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
||||||
{
|
|
||||||
struct unit_test *tests = UNIT_TEST_SUITE_START(unicode_test);
|
|
||||||
const int n_ents = UNIT_TEST_SUITE_COUNT(unicode_test);
|
|
||||||
|
|
||||||
return cmd_ut_category("Unicode", "unicode_test_",
|
|
||||||
tests, n_ents, argc, argv);
|
|
||||||
}
|
|
|
@ -617,14 +617,14 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
|
||||||
*/
|
*/
|
||||||
len = strlen(test_name);
|
len = strlen(test_name);
|
||||||
if (len < 6 || strcmp(test_name + len - 6, "_norun")) {
|
if (len < 6 || strcmp(test_name + len - 6, "_norun")) {
|
||||||
printf("Test %s is manual so must have a name ending in _norun\n",
|
printf("Test '%s' is manual so must have a name ending in _norun\n",
|
||||||
test_name);
|
test_name);
|
||||||
uts->fail_count++;
|
uts->fail_count++;
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
if (!uts->force_run) {
|
if (!uts->force_run) {
|
||||||
if (select_name) {
|
if (select_name) {
|
||||||
printf("Test %s skipped as it is manual (use -f to run it)\n",
|
printf("Test '%s' skipped as it is manual (use -f to run it)\n",
|
||||||
test_name);
|
test_name);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -635,7 +635,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
|
||||||
if (one && upto == pos) {
|
if (one && upto == pos) {
|
||||||
ret = ut_run_test_live_flat(uts, one);
|
ret = ut_run_test_live_flat(uts, one);
|
||||||
if (uts->fail_count != old_fail_count) {
|
if (uts->fail_count != old_fail_count) {
|
||||||
printf("Test %s failed %d times (position %d)\n",
|
printf("Test '%s' failed %d times (position %d)\n",
|
||||||
one->name,
|
one->name,
|
||||||
uts->fail_count - old_fail_count, pos);
|
uts->fail_count - old_fail_count, pos);
|
||||||
}
|
}
|
||||||
|
@ -645,7 +645,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
|
||||||
for (i = 0; i < uts->runs_per_test; i++)
|
for (i = 0; i < uts->runs_per_test; i++)
|
||||||
ret = ut_run_test_live_flat(uts, test);
|
ret = ut_run_test_live_flat(uts, test);
|
||||||
if (uts->fail_count != old_fail_count) {
|
if (uts->fail_count != old_fail_count) {
|
||||||
printf("Test %s failed %d times\n", select_name,
|
printf("Test '%s' failed %d times\n", test_name,
|
||||||
uts->fail_count - old_fail_count);
|
uts->fail_count - old_fail_count);
|
||||||
}
|
}
|
||||||
found++;
|
found++;
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# SPDX-License-Identifier: GPL-2.0+
|
|
||||||
# Copyright (c) 2013 The Chromium OS Authors.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Simple test script for tracing with sandbox
|
|
||||||
|
|
||||||
TRACE_OPT="FTRACE=1"
|
|
||||||
|
|
||||||
BASE="$(dirname $0)/.."
|
|
||||||
. $BASE/common.sh
|
|
||||||
|
|
||||||
run_trace() {
|
|
||||||
echo "Run trace"
|
|
||||||
./${OUTPUT_DIR}/u-boot <<END
|
|
||||||
trace stats
|
|
||||||
hash sha256 0 10000
|
|
||||||
trace pause
|
|
||||||
trace stats
|
|
||||||
hash sha256 0 10000
|
|
||||||
trace stats
|
|
||||||
trace resume
|
|
||||||
hash sha256 0 10000
|
|
||||||
trace pause
|
|
||||||
trace stats
|
|
||||||
reset
|
|
||||||
END
|
|
||||||
}
|
|
||||||
|
|
||||||
check_results() {
|
|
||||||
echo "Check results"
|
|
||||||
|
|
||||||
# Expect sha256 to run 3 times, so we see the string 6 times
|
|
||||||
if [ $(grep -c sha256 ${tmp}) -ne 6 ]; then
|
|
||||||
fail "sha256 error"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 4 sets of results (output of 'trace stats')
|
|
||||||
if [ $(grep -c "traced function calls" ${tmp}) -ne 4 ]; then
|
|
||||||
fail "trace output error"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check trace counts. We expect to see an increase in the number of
|
|
||||||
# traced function calls between each 'trace stats' command, except
|
|
||||||
# between calls 2 and 3, where tracing is paused.
|
|
||||||
# This code gets the sign of the difference between each number and
|
|
||||||
# its predecessor.
|
|
||||||
counts="$(tr -d ',\r' <${tmp} | awk \
|
|
||||||
'/traced function calls/ { diff = $1 - upto; upto = $1; \
|
|
||||||
printf "%d ", diff < 0 ? -1 : (diff > 0 ? 1 : 0)}')"
|
|
||||||
|
|
||||||
if [ "${counts}" != "1 1 0 1 " ]; then
|
|
||||||
fail "trace collection error: ${counts}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Simple trace test / sanity check using sandbox"
|
|
||||||
echo
|
|
||||||
tmp="$(tempfile)"
|
|
||||||
build_uboot "${TRACE_OPT}"
|
|
||||||
run_trace >${tmp}
|
|
||||||
check_results ${tmp}
|
|
||||||
rm ${tmp}
|
|
||||||
echo "Test passed"
|
|
Loading…
Add table
Reference in a new issue