test_dropbear.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import os
  2. import infra.basetest
  3. class TestDropbear(infra.basetest.BRTest):
  4. passwd = "testpwd"
  5. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  6. """
  7. BR2_TARGET_GENERIC_ROOT_PASSWD="{}"
  8. BR2_SYSTEM_DHCP="eth0"
  9. BR2_PACKAGE_DROPBEAR=y
  10. BR2_TARGET_ROOTFS_CPIO=y
  11. # BR2_TARGET_ROOTFS_TAR is not set
  12. """.format(passwd)
  13. def test_run(self):
  14. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  15. self.emulator.boot(arch="armv5",
  16. kernel="builtin",
  17. options=["-initrd", img,
  18. "-net", "nic",
  19. "-net", "user,hostfwd=tcp::2222-:22"])
  20. self.emulator.login(self.passwd)
  21. cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22"
  22. _, exit_code = self.emulator.run(cmd)
  23. self.assertEqual(exit_code, 0)
  24. # Would be useful to try to login through SSH here, through
  25. # localhost:2222, though it is not easy to pass the ssh
  26. # password on the command line.