test_dropbear.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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_PACKAGE_SSHPASS=y
  11. BR2_TARGET_ROOTFS_CPIO=y
  12. # BR2_TARGET_ROOTFS_TAR is not set
  13. """.format(passwd)
  14. def test_run(self):
  15. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  16. self.emulator.boot(arch="armv5",
  17. kernel="builtin",
  18. options=["-initrd", img,
  19. "-net", "nic",
  20. "-net", "user"])
  21. self.emulator.login(self.passwd)
  22. cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22"
  23. _, exit_code = self.emulator.run(cmd)
  24. self.assertEqual(exit_code, 0)
  25. cmd = "sshpass -p {} ssh -y localhost /bin/true".format(self.passwd)
  26. _, exit_code = self.emulator.run(cmd)
  27. self.assertEqual(exit_code, 0)