xref: /OK3568_Linux_fs/buildroot/support/testing/tests/package/test_dropbear.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1import os
2
3import infra.basetest
4
5
6class TestDropbear(infra.basetest.BRTest):
7    passwd = "testpwd"
8    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
9        """
10        BR2_TARGET_GENERIC_ROOT_PASSWD="{}"
11        BR2_SYSTEM_DHCP="eth0"
12        BR2_PACKAGE_DROPBEAR=y
13        BR2_PACKAGE_SSHPASS=y
14        BR2_TARGET_ROOTFS_CPIO=y
15        # BR2_TARGET_ROOTFS_TAR is not set
16        """.format(passwd)
17
18    def test_run(self):
19        img = os.path.join(self.builddir, "images", "rootfs.cpio")
20        self.emulator.boot(arch="armv5",
21                           kernel="builtin",
22                           options=["-initrd", img,
23                                    "-net", "nic",
24                                    "-net", "user"])
25        self.emulator.login(self.passwd)
26        cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22"
27        self.assertRunOk(cmd)
28
29        cmd = "sshpass -p {} ssh -y localhost /bin/true".format(self.passwd)
30        self.assertRunOk(cmd)
31