summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cmd/temperature.c2
-rw-r--r--test/dm/Makefile2
-rw-r--r--test/dm/led.c8
-rw-r--r--test/log/syslog_test.c1
-rw-r--r--test/log/syslog_test_ndebug.c1
-rw-r--r--test/optee/Kconfig1
-rw-r--r--test/optee/optee.c42
-rw-r--r--test/py/tests/test_efi_capsule/capsule_common.py4
-rw-r--r--test/py/tests/test_efi_capsule/conftest.py3
-rw-r--r--test/py/tests/test_fit_auto_signed.py67
10 files changed, 111 insertions, 20 deletions
diff --git a/test/cmd/temperature.c b/test/cmd/temperature.c
index 309693aa1e8..464d055b94d 100644
--- a/test/cmd/temperature.c
+++ b/test/cmd/temperature.c
@@ -27,7 +27,7 @@ static int dm_test_cmd_temperature(struct unit_test_state *uts)
/* Test that "temperature get thermal" returns expected value */
console_record_reset();
ut_assertok(run_command("temperature get thermal", 0));
- ut_assert_nextline("thermal: 100 C");
+ ut_assert_nextline("thermal: 100000 mC");
ut_assert_console_end();
return 0;
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 474e77a2151..2db0e3b8dfd 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -126,7 +126,7 @@ obj-$(CONFIG_TEE) += tee.o
obj-$(CONFIG_TIMER) += timer.o
obj-$(CONFIG_TPM_V2) += tpm.o
obj-$(CONFIG_DM_USB) += usb.o
-obj-$(CONFIG_VIDEO) += video.o
+obj-$(CONFIG_VIDEO_SANDBOX_SDL) += video.o
ifeq ($(CONFIG_VIRTIO_SANDBOX),y)
obj-y += virtio.o
obj-$(CONFIG_VIRTIO_RNG) += virtio_device.o
diff --git a/test/dm/led.c b/test/dm/led.c
index 36652c2833a..f41a2fb73fc 100644
--- a/test/dm/led.c
+++ b/test/dm/led.c
@@ -162,7 +162,7 @@ DM_TEST(dm_test_led_blink, UTF_SCAN_PDATA | UTF_SCAN_FDT);
#ifdef CONFIG_LED_BOOT
static int dm_test_led_boot(struct unit_test_state *uts)
{
- struct udevice *dev
+ struct udevice *dev;
/* options/u-boot/boot-led is set to phandle to "sandbox:green" */
ut_assertok(led_get_by_label("sandbox:green", &dev));
@@ -180,7 +180,7 @@ DM_TEST(dm_test_led_boot, UTF_SCAN_PDATA | UTF_SCAN_FDT);
#ifndef CONFIG_LED_BLINK
static int dm_test_led_boot_blink(struct unit_test_state *uts)
{
- struct udevice *dev
+ struct udevice *dev;
/* options/u-boot/boot-led is set to phandle to "sandbox:green" */
ut_assertok(led_get_by_label("sandbox:green", &dev));
@@ -200,7 +200,7 @@ DM_TEST(dm_test_led_boot_blink, UTF_SCAN_PDATA | UTF_SCAN_FDT);
#ifdef CONFIG_LED_ACTIVITY
static int dm_test_led_activity(struct unit_test_state *uts)
{
- struct udevice *dev
+ struct udevice *dev;
/* options/u-boot/activity-led is set to phandle to "sandbox:red" */
ut_assertok(led_get_by_label("sandbox:red", &dev));
@@ -218,7 +218,7 @@ DM_TEST(dm_test_led_activity, UTF_SCAN_PDATA | UTF_SCAN_FDT);
#ifndef CONFIG_LED_BLINK
static int dm_test_led_activityt_blink(struct unit_test_state *uts)
{
- struct udevice *dev
+ struct udevice *dev;
/* options/u-boot/activity-led is set to phandle to "sandbox:red" */
ut_assertok(led_get_by_label("sandbox:red", &dev));
diff --git a/test/log/syslog_test.c b/test/log/syslog_test.c
index 98b91436580..b6c0631aaf6 100644
--- a/test/log/syslog_test.c
+++ b/test/log/syslog_test.c
@@ -10,6 +10,7 @@
/* Override CONFIG_LOG_MAX_LEVEL */
#define LOG_DEBUG
+#include <env.h>
#include <asm/global_data.h>
#include <dm/device.h>
#include <hexdump.h>
diff --git a/test/log/syslog_test_ndebug.c b/test/log/syslog_test_ndebug.c
index dfd0217c1e4..a02d207ac0b 100644
--- a/test/log/syslog_test_ndebug.c
+++ b/test/log/syslog_test_ndebug.c
@@ -7,6 +7,7 @@
* Invoke the test with: ./u-boot -d arch/sandbox/dts/test.dtb
*/
+#include <env.h>
#include <asm/global_data.h>
#include <dm/device.h>
#include <hexdump.h>
diff --git a/test/optee/Kconfig b/test/optee/Kconfig
index 63e2cbf79c7..ebf8d07c41c 100644
--- a/test/optee/Kconfig
+++ b/test/optee/Kconfig
@@ -1,6 +1,7 @@
config UT_OPTEE
bool "Enable OP-TEE Unit Tests"
depends on OF_CONTROL && OPTEE
+ select OPTEE_LIB
default y
help
This enables the 'ut optee' command which runs a series of unit
diff --git a/test/optee/optee.c b/test/optee/optee.c
index 658621fa2fa..7e1c8d04a11 100644
--- a/test/optee/optee.c
+++ b/test/optee/optee.c
@@ -5,16 +5,20 @@
#include <command.h>
#include <errno.h>
+#include <fdtdec.h>
#include <fdt_support.h>
#include <log.h>
#include <malloc.h>
#include <tee/optee.h>
+#include <asm/global_data.h>
#include <linux/sizes.h>
#include <test/ut.h>
#include <test/optee.h>
+DECLARE_GLOBAL_DATA_PTR;
+
/* 4k ought to be enough for anybody */
#define FDT_COPY_SIZE (4 * SZ_1K)
@@ -40,14 +44,6 @@ static int optee_test_init(struct unit_test_state *uts)
if (!fdt)
return ret;
- /*
- * Resize the FDT to 4k so that we have room to operate on
- *
- * (and relocate it since the memory might be mapped
- * read-only)
- */
- ut_assertok(fdt_open_into(fdt_base, fdt, FDT_COPY_SIZE));
-
return 0;
}
OPTEE_TEST_INIT(optee_test_init, 0);
@@ -127,9 +123,21 @@ static int optee_fdt_protected_memory(struct unit_test_state *uts)
static int optee_fdt_copy_empty(struct unit_test_state *uts)
{
void *fdt_no_optee = &__dtb_test_optee_no_optee_begin;
+ const void *fdt_blob = gd->fdt_blob;
+
+ /*
+ * Resize the FDT to 4k so that we have room to operate on
+ *
+ * (and relocate it since the memory might be mapped
+ * read-only)
+ */
+ ut_assertok(fdt_open_into(&__dtb_test_optee_base_begin, fdt,
+ FDT_COPY_SIZE));
/* This should still run successfully */
- ut_assertok(optee_copy_fdt_nodes(fdt_no_optee, fdt));
+ gd->fdt_blob = fdt_no_optee;
+ ut_assertok(optee_copy_fdt_nodes(fdt));
+ gd->fdt_blob = fdt_blob;
expect_success = false;
ut_assertok(optee_fdt_firmware(uts));
@@ -143,8 +151,14 @@ OPTEE_TEST(optee_fdt_copy_empty, 0);
static int optee_fdt_copy_prefilled(struct unit_test_state *uts)
{
void *fdt_optee = &__dtb_test_optee_optee_begin;
+ const void *fdt_blob = gd->fdt_blob;
- ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt));
+ ut_assertok(fdt_open_into(&__dtb_test_optee_base_begin, fdt,
+ FDT_COPY_SIZE));
+
+ gd->fdt_blob = fdt_optee;
+ ut_assertok(optee_copy_fdt_nodes(fdt));
+ gd->fdt_blob = fdt_blob;
expect_success = true;
ut_assertok(optee_fdt_firmware(uts));
@@ -158,9 +172,15 @@ OPTEE_TEST(optee_fdt_copy_prefilled, 0);
static int optee_fdt_copy_already_filled(struct unit_test_state *uts)
{
void *fdt_optee = &__dtb_test_optee_optee_begin;
+ const void *fdt_blob = gd->fdt_blob;
+
+ ut_assertok(fdt_open_into(&__dtb_test_optee_base_begin, fdt,
+ FDT_COPY_SIZE));
ut_assertok(fdt_open_into(fdt_optee, fdt, FDT_COPY_SIZE));
- ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt));
+ gd->fdt_blob = fdt_optee;
+ ut_assertok(optee_copy_fdt_nodes(fdt));
+ gd->fdt_blob = fdt_blob;
expect_success = true;
ut_assertok(optee_fdt_firmware(uts));
diff --git a/test/py/tests/test_efi_capsule/capsule_common.py b/test/py/tests/test_efi_capsule/capsule_common.py
index 04dabc176c4..8aaddfc19d6 100644
--- a/test/py/tests/test_efi_capsule/capsule_common.py
+++ b/test/py/tests/test_efi_capsule/capsule_common.py
@@ -42,7 +42,7 @@ def init_content(ubman, target, filename, expected):
'sf probe 0:0',
f'fatload host 0:1 4000000 {CAPSULE_DATA_DIR}/{filename}',
f'sf write 4000000 {target} 10',
- 'sf read 5000000 100000 10',
+ f'sf read 5000000 {target} 10',
'md.b 5000000 10'])
assert expected in ''.join(output)
@@ -137,6 +137,8 @@ def do_reboot_dtb_specified(u_boot_config, ubman, dtb_filename):
dtb_filename -- DTB file name.
"""
mnt_point = u_boot_config.persistent_data_dir + '/scratch'
+ old_dtb = ubman.config.dtb
ubman.config.dtb = mnt_point + CAPSULE_DATA_DIR \
+ f'/{dtb_filename}'
ubman.restart_uboot()
+ ubman.config.dtb = old_dtb
diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py
index 961d2e0b3c1..ad0cda59ebf 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -44,8 +44,6 @@ def efi_capsule_data(request, ubman):
% (key_dir, data_dir), shell=True)
check_call('cp %s/capsule_pub_key_good.crt %s/SIGNER.crt'
% (key_dir, data_dir), shell=True)
- check_call('cp %s/capsule_pub_esl_good.esl %s/SIGNER.esl'
- % (key_dir, data_dir), shell=True)
check_call('cp %s/capsule_priv_key_bad.key %s/SIGNER2.key'
% (key_dir, data_dir), shell=True)
@@ -103,6 +101,7 @@ def efi_capsule_data(request, ubman):
pytest.skip('Setup failed: %s' % exception.cmd)
return
else:
+ ubman.restart_uboot()
yield image_path
finally:
call('rm -rf %s' % mnt_point, shell=True)
diff --git a/test/py/tests/test_fit_auto_signed.py b/test/py/tests/test_fit_auto_signed.py
index cdfd341c6f5..0b5dbd5401c 100644
--- a/test/py/tests/test_fit_auto_signed.py
+++ b/test/py/tests/test_fit_auto_signed.py
@@ -117,6 +117,23 @@ class SignedFitHelper(object):
algo = self.__fdt_get_string(f'{node}/signature', 'algo')
assert algo == sign_algo + "\n", "Missing expected signature algo!"
+ def check_fit_loadables(self, present):
+ """Test that loadables contains both kernel and TFA BL31 entries.
+
+ Each configuration must have a loadables property which lists both
+ kernel-1 and tfa-bl31-1 strings in the string list.
+ """
+ if present:
+ assert "/images/tfa-bl31-1" in self.images_nodes
+ else:
+ assert "/images/tfa-bl31-1" not in self.images_nodes
+ for node in self.confgs_nodes:
+ loadables = self.__fdt_get_string(f'{node}', 'loadables')
+ assert "kernel-1" in loadables
+ if present:
+ assert "tfa-bl31-1" in loadables
+ else:
+ assert "tfa-bl31-1" not in loadables
@pytest.mark.buildconfigspec('fit_signature')
@pytest.mark.requiredtool('fdtget')
@@ -139,6 +156,7 @@ def test_fit_auto_signed(ubman):
kernel_file = f'{tempdir}/vmlinuz'
dt1_file = f'{tempdir}/dt-1.dtb'
dt2_file = f'{tempdir}/dt-2.dtb'
+ tfa_file = f'{tempdir}/tfa-bl31.bin'
key_name = 'sign-key'
sign_algo = 'sha256,rsa4096'
key_file = f'{tempdir}/{key_name}.key'
@@ -154,6 +172,9 @@ def test_fit_auto_signed(ubman):
with open(dt2_file, 'wb') as fd:
fd.write(os.urandom(256))
+ with open(tfa_file, 'wb') as fd:
+ fd.write(os.urandom(256))
+
# Create 4096 RSA key and write to file to be read by mkimage
key = RSA.generate(bits=4096)
verifier = pkcs1_15.new(key)
@@ -173,6 +194,8 @@ def test_fit_auto_signed(ubman):
fit.check_fit_crc32_images()
+ fit.check_fit_loadables(present=False)
+
# 2 - Create auto FIT with signed images, and verify it
utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + s_args + " " +
fit_file)
@@ -183,6 +206,8 @@ def test_fit_auto_signed(ubman):
fit.check_fit_signed_images(key_name, sign_algo, verifier)
+ fit.check_fit_loadables(present=False)
+
# 3 - Create auto FIT with signed configs and hashed images, and verify it
utils.run_and_log(ubman, mkimage + ' -fauto-conf' + b_args + s_args + " " +
fit_file)
@@ -192,3 +217,45 @@ def test_fit_auto_signed(ubman):
raise ValueError('FIT-3 has no "/image" nor "/configuration" nodes')
fit.check_fit_signed_confgs(key_name, sign_algo)
+
+ fit.check_fit_loadables(present=False)
+
+ # Run the same tests as 1/2/3 above, but this time with TFA BL31
+ # options -y tfa-bl31.bin -Y 0x12340000 to cover both mkimage with
+ # and without TFA BL31 use cases.
+ b_args = " -d" + kernel_file + " -b" + dt1_file + " -b" + dt2_file + " -y" + tfa_file + " -Y 0x12340000"
+
+ # 4 - Create auto FIT with images crc32 checksum, and verify it
+ utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + " " + fit_file)
+
+ fit = SignedFitHelper(ubman, fit_file)
+ if fit.build_nodes_sets() == 0:
+ raise ValueError('FIT-4 has no "/image" nor "/configuration" nodes')
+
+ fit.check_fit_crc32_images()
+
+ fit.check_fit_loadables(present=True)
+
+ # 5 - Create auto FIT with signed images, and verify it
+ utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + s_args + " " +
+ fit_file)
+
+ fit = SignedFitHelper(ubman, fit_file)
+ if fit.build_nodes_sets() == 0:
+ raise ValueError('FIT-5 has no "/image" nor "/configuration" nodes')
+
+ fit.check_fit_signed_images(key_name, sign_algo, verifier)
+
+ fit.check_fit_loadables(present=True)
+
+ # 6 - Create auto FIT with signed configs and hashed images, and verify it
+ utils.run_and_log(ubman, mkimage + ' -fauto-conf' + b_args + s_args + " " +
+ fit_file)
+
+ fit = SignedFitHelper(ubman, fit_file)
+ if fit.build_nodes_sets() == 0:
+ raise ValueError('FIT-6 has no "/image" nor "/configuration" nodes')
+
+ fit.check_fit_signed_confgs(key_name, sign_algo)
+
+ fit.check_fit_loadables(present=True)