1import os
2
3import infra.basetest
4
5
6class TestThttpd(infra.basetest.BRTest):
7    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
8        """
9        BR2_PACKAGE_THTTPD=y
10        BR2_TARGET_ROOTFS_CPIO=y
11        # BR2_TARGET_ROOTFS_TAR is not set
12        """
13
14    def test_run(self):
15        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
16        self.emulator.boot(arch="armv5",
17                           kernel="builtin",
18                           options=["-initrd", cpio_file])
19        self.emulator.login()
20
21        msg = "Hello Buildroot!"
22
23        self.assertRunOk("thttpd -V")
24        self.assertRunOk(f"echo '{msg}' > /var/www/data/index.html")
25        self.assertRunOk("wget http://localhost/index.html")
26        self.assertRunOk(f"grep -F '{msg}' index.html")
27