1import os
2
3import infra.basetest
4
5
6class TestMender(infra.basetest.BRTest):
7    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
8        """
9        BR2_PACKAGE_MENDER=y
10        BR2_TARGET_ROOTFS_CPIO=y
11        BR2_ROOTFS_OVERLAY="{}"
12        """.format(
13           # overlay to add a fake 'fw_printenv', used by Mender
14           infra.filepath("tests/package/test_mender/rootfs-overlay"))
15
16    def test_run(self):
17        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
18        self.emulator.boot(arch="armv5",
19                           kernel="builtin",
20                           options=["-initrd", cpio_file])
21        self.emulator.login()
22
23        # Check if the Daemon is running
24        self.assertRunOk("ls /var/run/mender.pid")
25        self.assertRunOk("ps aux | egrep [m]ender")
26
27        # Check if a simple Mender command is correctly executed
28        self.assertRunOk("mender -log-level debug show-artifact")
29        self.assertRunOk("mender -log-level debug show-artifact | grep 'RUNTIME_TEST_ARTIFACT_NAME'")
30        cmd = "mender show-artifact 2>&1 | grep -i 'err'"  # Check if no 'error' among the traces
31        _, exit_code = self.emulator.run(cmd)
32        self.assertEqual(exit_code, 1)
33