1import os
2
3import infra.basetest
4
5
6class TestNu(infra.basetest.BRTest):
7    # infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it doesn't
8    # support a host rustc which is necessary for nushell
9    config = \
10        """
11        BR2_arm=y
12        BR2_cortex_a9=y
13        BR2_ARM_ENABLE_NEON=y
14        BR2_ARM_ENABLE_VFP=y
15        BR2_TOOLCHAIN_EXTERNAL=y
16        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
17        BR2_SYSTEM_DHCP="eth0"
18        BR2_PACKAGE_NUSHELL=y
19        BR2_TARGET_ROOTFS_CPIO=y
20        BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
21        BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
22        """.format(infra.filepath("tests/package/copy-sample-script-to-target.sh"),
23                   infra.filepath("tests/package/sample_nu.nu"))
24
25    def test_run(self):
26        img = os.path.join(self.builddir, "images", "rootfs.cpio")
27        self.emulator.boot(arch="armv7",
28                           kernel="builtin",
29                           options=["-initrd", img])
30        self.emulator.login()
31        cmd = "nu sample_nu.nu"
32        self.assertRunOk(cmd)
33