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_ls.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_ls(u_boot_console):
15     build_dir = u_boot_console.config.build_dir
16     for opt in comp_opts:
17         try:
18             opt.gen_image(build_dir)
19         except RuntimeError:
20             opt.clean_source(build_dir)
21             # skip unsupported compression types
22             continue
23         path = os.path.join(build_dir, "sqfs-" + opt.name)
24         output = u_boot_console.run_command("host bind 0 " + path)
25
26         try:
27             # list files in root directory
28             output = u_boot_console.run_command("sqfsls host 0")
29             assert str(len(opt.files) + 1) + " file(s), 0 dir(s)" in output
30             assert "<SYM>   sym" in output
31             output = u_boot_console.run_command("sqfsls host 0 xxx")
32             assert "** Cannot find directory. **" in output
33         except:
34             opt.cleanup(build_dir)
35             assert False
36         opt.cleanup(build_dir)