Merge tag 'u-boot-imx-20200825' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[platform/kernel/u-boot.git] / test / py / tests / test_fs / test_squashfs / test_sqfs_load.py
1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (C) 2020 Bootlin
3 # Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
4
5 import os
6 import pytest
7 from sqfs_common import *
8
9 @pytest.mark.boardspec('sandbox')
10 @pytest.mark.buildconfigspec('cmd_fs_generic')
11 @pytest.mark.buildconfigspec('cmd_squashfs')
12 @pytest.mark.buildconfigspec('fs_squashfs')
13 @pytest.mark.requiredtool('mksquashfs')
14 def test_sqfs_load(u_boot_console):
15     build_dir = u_boot_console.config.build_dir
16     command = "sqfsload host 0 $kernel_addr_r "
17
18     for opt in comp_opts:
19         # generate and load the squashfs image
20         try:
21             opt.gen_image(build_dir)
22         except RuntimeError:
23             opt.clean_source(build_dir)
24             # skip unsupported compression types
25             continue
26
27         path = os.path.join(build_dir, "sqfs-" + opt.name)
28         output = u_boot_console.run_command("host bind 0 " + path)
29
30         output = u_boot_console.run_command(command + "xxx")
31         assert "File not found." in output
32
33         for (f, s) in zip(opt.files, opt.sizes):
34             try:
35                 output = u_boot_console.run_command(command + f)
36                 assert str(s) in output
37             except:
38                 assert False
39                 opt.cleanup(build_dir)
40
41         # test symbolic link
42         output = u_boot_console.run_command(command + "sym")
43         assert str(opt.sizes[0]) in output
44
45         # remove generated files
46         opt.cleanup(build_dir)