test_openssh.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. self.assertRunOk(cmd)
  24. cmd = "sshpass -p {} ssh -oStrictHostKeyChecking=no localhost /bin/true".format(self.passwd)
  25. self.assertRunOk(cmd)
  26. class TestOpenSshuClibc(TestOpensshBase):
  27. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  28. TestOpensshBase.opensshconfig + \
  29. """
  30. BR2_TARGET_ROOTFS_CPIO=y
  31. """
  32. def test_run(self):
  33. self.openssh_test()
  34. class TestOpenSshGlibc(TestOpensshBase):
  35. config = \
  36. TestOpensshBase.opensshconfig + \
  37. """
  38. BR2_arm=y
  39. BR2_TOOLCHAIN_EXTERNAL=y
  40. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
  41. BR2_PACKAGE_RNG_TOOLS=y
  42. BR2_TARGET_ROOTFS_CPIO=y
  43. """
  44. def test_run(self):
  45. self.openssh_test()