1import os
2import subprocess
3
4import infra.basetest
5
6
7def compare_file(file1, file2):
8    return subprocess.call(["cmp", file1, file2])
9
10
11class TestRootfsOverlay(infra.basetest.BRTest):
12
13    rootfs_overlay_path = infra.filepath("tests/core/rootfs-overlay")
14
15    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
16        infra.basetest.MINIMAL_CONFIG + \
17        """
18        BR2_ROOTFS_OVERLAY="{0}1 {0}2"
19        """.format(rootfs_overlay_path)
20
21    def test_run(self):
22        target_file = os.path.join(self.builddir, "target", "test-file1")
23        overlay_file = "{}1/test-file1".format(self.rootfs_overlay_path)
24        ret = compare_file(overlay_file, target_file)
25        self.assertEqual(ret, 0)
26
27        target_file = os.path.join(self.builddir, "target", "etc", "test-file2")
28        overlay_file = "{}2/etc/test-file2".format(self.rootfs_overlay_path)
29        ret = compare_file(overlay_file, target_file)
30        self.assertEqual(ret, 0)
31