hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import subprocess
 
import infra.basetest
 
 
class TestSquashfs(infra.basetest.BRTest):
    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
        """
        BR2_TARGET_ROOTFS_SQUASHFS=y
        # BR2_TARGET_ROOTFS_SQUASHFS4_GZIP is not set
        BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y
        # BR2_TARGET_ROOTFS_TAR is not set
        """
 
    def test_run(self):
        unsquashfs_cmd = ["host/bin/unsquashfs", "-s", "images/rootfs.squashfs"]
        out = subprocess.check_output(unsquashfs_cmd,
                                      cwd=self.builddir,
                                      env={"LANG": "C"})
        out = out.splitlines()
        self.assertEqual(out[0],
                         "Found a valid SQUASHFS 4:0 superblock on images/rootfs.squashfs.")
        self.assertEqual(out[3], "Compression lz4")
 
        img = os.path.join(self.builddir, "images", "rootfs.squashfs")
        subprocess.call(["truncate", "-s", "%1M", img])
 
        self.emulator.boot(arch="armv7",
                           kernel="builtin",
                           kernel_cmdline=["root=/dev/mmcblk0",
                                           "rootfstype=squashfs"],
                           options=["-drive", "file={},if=sd,format=raw".format(img)])
        self.emulator.login()
 
        cmd = "mount | grep '/dev/root on / type squashfs'"
        _, exit_code = self.emulator.run(cmd)
        self.assertEqual(exit_code, 0)