1import os
2
3import infra.basetest
4
5
6class TestFileCapabilities(infra.basetest.BRTest):
7    config = \
8        """
9        BR2_arm=y
10        BR2_TOOLCHAIN_EXTERNAL=y
11        BR2_ROOTFS_DEVICE_TABLE="system/device_table.txt {}"
12        BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES=y
13        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
14        BR2_LINUX_KERNEL=y
15        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
16        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.310"
17        BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
18        BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}"
19        BR2_LINUX_KERNEL_DTS_SUPPORT=y
20        BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
21        BR2_PACKAGE_LIBCAP=y
22        BR2_PACKAGE_LIBCAP_TOOLS=y
23        BR2_TARGET_ROOTFS_SQUASHFS=y
24        # BR2_TARGET_ROOTFS_TAR is not set
25        """.format(infra.filepath("tests/core/device_table2.txt"),
26                   infra.filepath("tests/core/squashfs-xattr-kernel.config"))
27
28    def test_run(self):
29        img = os.path.join(self.builddir, "images", "rootfs.squashfs")
30        infra.img_round_power2(img)
31
32        self.emulator.boot(arch="armv7",
33                           kernel=os.path.join(self.builddir, "images", "zImage"),
34                           kernel_cmdline=["root=/dev/mmcblk0",
35                                           "rootfstype=squashfs"],
36                           options=["-drive", "file={},if=sd,format=raw".format(img),
37                                    "-M", "vexpress-a9",
38                                    "-dtb", os.path.join(self.builddir, "images", "vexpress-v2p-ca9.dtb")])
39        self.emulator.login()
40
41        cmd = "getcap -v /usr/sbin/getcap"
42        output, _ = self.emulator.run(cmd)
43        self.assertIn("cap_kill", output[0])
44        self.assertIn("cap_sys_nice", output[0])
45        self.assertIn("cap_sys_time", output[0])
46        self.assertIn("=eip", output[0])
47