summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compression.c93
-rw-r--r--test/dm/sf.c2
-rwxr-xr-xtest/image/test-fit.py16
3 files changed, 102 insertions, 9 deletions
diff --git a/test/compression.c b/test/compression.c
index 139ea01..ea2e4ad 100644
--- a/test/compression.c
+++ b/test/compression.c
@@ -7,8 +7,10 @@
#define DEBUG
#include <common.h>
+#include <bootm.h>
#include <command.h>
#include <malloc.h>
+#include <asm/io.h>
#include <u-boot/zlib.h>
#include <bzlib.h>
@@ -313,9 +315,8 @@ out:
return ret;
}
-
-static int do_test_compression(cmd_tbl_t *cmdtp, int flag, int argc,
- char * const argv[])
+static int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
{
int err = 0;
@@ -324,12 +325,94 @@ static int do_test_compression(cmd_tbl_t *cmdtp, int flag, int argc,
err += run_test("lzma", compress_using_lzma, uncompress_using_lzma);
err += run_test("lzo", compress_using_lzo, uncompress_using_lzo);
- printf("test_compression %s\n", err == 0 ? "ok" : "FAILED");
+ printf("ut_compression %s\n", err == 0 ? "ok" : "FAILED");
return err;
}
+static int compress_using_none(void *in, unsigned long in_size,
+ void *out, unsigned long out_max,
+ unsigned long *out_size)
+{
+ /* Here we just copy */
+ memcpy(out, in, in_size);
+ *out_size = in_size;
+
+ return 0;
+}
+
+/**
+ * run_bootm_test() - Run tests on the bootm decopmression function
+ *
+ * @comp_type: Compression type to test
+ * @compress: Our function to compress data
+ * @return 0 if OK, non-zero on failure
+ */
+static int run_bootm_test(int comp_type, mutate_func compress)
+{
+ ulong compress_size = 1024;
+ void *compress_buff;
+ int unc_len;
+ int err = 0;
+ const ulong image_start = 0;
+ const ulong load_addr = 0x1000;
+ ulong load_end;
+
+ printf("Testing: %s\n", genimg_get_comp_name(comp_type));
+ compress_buff = map_sysmem(image_start, 0);
+ unc_len = strlen(plain);
+ compress((void *)plain, unc_len, compress_buff, compress_size,
+ &compress_size);
+ err = bootm_decomp_image(comp_type, load_addr, image_start,
+ IH_TYPE_KERNEL, map_sysmem(load_addr, 0),
+ compress_buff, compress_size, unc_len,
+ &load_end);
+ if (err)
+ return err;
+ err = bootm_decomp_image(comp_type, load_addr, image_start,
+ IH_TYPE_KERNEL, map_sysmem(load_addr, 0),
+ compress_buff, compress_size, unc_len - 1,
+ &load_end);
+ if (!err)
+ return -EINVAL;
+
+ /* We can't detect corruption when not decompressing */
+ if (comp_type == IH_COMP_NONE)
+ return 0;
+ memset(compress_buff + compress_size / 2, '\x49',
+ compress_size / 2);
+ err = bootm_decomp_image(comp_type, load_addr, image_start,
+ IH_TYPE_KERNEL, map_sysmem(load_addr, 0),
+ compress_buff, compress_size, 0x10000,
+ &load_end);
+ if (!err)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int do_ut_image_decomp(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ int err = 0;
+
+ err = run_bootm_test(IH_COMP_GZIP, compress_using_gzip);
+ err |= run_bootm_test(IH_COMP_BZIP2, compress_using_bzip2);
+ err |= run_bootm_test(IH_COMP_LZMA, compress_using_lzma);
+ err |= run_bootm_test(IH_COMP_LZO, compress_using_lzo);
+ err |= run_bootm_test(IH_COMP_NONE, compress_using_none);
+
+ printf("ut_image_decomp %s\n", err == 0 ? "ok" : "FAILED");
+
+ return 0;
+}
+
U_BOOT_CMD(
- test_compression, 5, 1, do_test_compression,
+ ut_compression, 5, 1, do_ut_compression,
"Basic test of compressors: gzip bzip2 lzma lzo", ""
);
+
+U_BOOT_CMD(
+ ut_image_decomp, 5, 1, do_ut_image_decomp,
+ "Basic test of bootm decompression", ""
+);
diff --git a/test/dm/sf.c b/test/dm/sf.c
index 57dd134..08098a1 100644
--- a/test/dm/sf.c
+++ b/test/dm/sf.c
@@ -29,7 +29,7 @@ static int dm_test_spi_flash(struct dm_test_state *dms)
* benefit is worth the extra complexity.
*/
ut_asserteq(0, run_command_list(
- "sb save hostfs - spi.bin 0 200000;"
+ "sb save hostfs - 0 spi.bin 200000;"
"sf probe;"
"sf test 0 10000", -1, 0));
/*
diff --git a/test/image/test-fit.py b/test/image/test-fit.py
index b065fcb..e9e756a 100755
--- a/test/image/test-fit.py
+++ b/test/image/test-fit.py
@@ -20,6 +20,9 @@ import struct
import sys
import tempfile
+# Enable printing of all U-Boot output
+DEBUG = True
+
# The 'command' library in patman is convenient for running commands
base_path = os.path.dirname(sys.argv[0])
patman = os.path.join(base_path, '../../tools/patman')
@@ -97,12 +100,16 @@ sb load hostfs 0 %(fit_addr)x %(fit)s
fdt addr %(fit_addr)x
bootm start %(fit_addr)x
bootm loados
-sb save hostfs 0 %(kernel_out)s %(kernel_addr)x %(kernel_size)x
-sb save hostfs 0 %(fdt_out)s %(fdt_addr)x %(fdt_size)x
-sb save hostfs 0 %(ramdisk_out)s %(ramdisk_addr)x %(ramdisk_size)x
+sb save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x
+sb save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x
+sb save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x
reset
'''
+def debug_stdout(stdout):
+ if DEBUG:
+ print stdout
+
def make_fname(leaf):
"""Make a temporary filename
@@ -328,6 +335,7 @@ def run_fit_test(mkimage, u_boot):
# We could perhaps reduce duplication with some loss of readability
set_test('Kernel load')
stdout = command.Output(u_boot, '-d', control_dtb, '-c', cmd)
+ debug_stdout(stdout)
if read_file(kernel) != read_file(kernel_out):
fail('Kernel not loaded', stdout)
if read_file(control_dtb) == read_file(fdt_out):
@@ -352,6 +360,7 @@ def run_fit_test(mkimage, u_boot):
params['fdt_load'] = 'load = <%#x>;' % params['fdt_addr']
fit = make_fit(mkimage, params)
stdout = command.Output(u_boot, '-d', control_dtb, '-c', cmd)
+ debug_stdout(stdout)
if read_file(kernel) != read_file(kernel_out):
fail('Kernel not loaded', stdout)
if read_file(control_dtb) != read_file(fdt_out):
@@ -365,6 +374,7 @@ def run_fit_test(mkimage, u_boot):
params['ramdisk_load'] = 'load = <%#x>;' % params['ramdisk_addr']
fit = make_fit(mkimage, params)
stdout = command.Output(u_boot, '-d', control_dtb, '-c', cmd)
+ debug_stdout(stdout)
if read_file(ramdisk) != read_file(ramdisk_out):
fail('Ramdisk not loaded', stdout)