test_openssh.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import os
  2. import infra.basetest
  3. class TestOpensshBase(infra.basetest.BRTest):
  4. passwd = "testpwd"
  5. opensshconfig = \
  6. """
  7. BR2_TARGET_GENERIC_ROOT_PASSWD="{}"
  8. BR2_PACKAGE_OPENSSH=y
  9. BR2_PACKAGE_SSHPASS=y
  10. BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
  11. # BR2_TARGET_ROOTFS_TAR is not set
  12. """.format(
  13. passwd,
  14. infra.filepath("tests/package/test_openssh/post-build.sh"))
  15. def openssh_test(self):
  16. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  17. self.emulator.boot(arch="armv5",
  18. kernel="builtin",
  19. options=["-initrd", img,
  20. "-net", "none"])
  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 -oStrictHostKeyChecking=no localhost /bin/true".format(self.passwd)
  26. _, exit_code = self.emulator.run(cmd)
  27. self.assertEqual(exit_code, 0)
  28. class TestOpenSshuClibc(TestOpensshBase):
  29. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  30. TestOpensshBase.opensshconfig + \
  31. """
  32. BR2_TARGET_ROOTFS_CPIO=y
  33. """
  34. def test_run(self):
  35. self.openssh_test()
  36. class TestOpenSshGlibc(TestOpensshBase):
  37. config = \
  38. TestOpensshBase.opensshconfig + \
  39. """
  40. BR2_arm=y
  41. BR2_TOOLCHAIN_EXTERNAL=y
  42. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
  43. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_GLIBC_STABLE=y
  44. BR2_PACKAGE_RNG_TOOLS=y
  45. BR2_TARGET_ROOTFS_CPIO=y
  46. """
  47. def test_run(self):
  48. self.openssh_test()