test_perl.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import os
  2. import infra.basetest
  3. class TestPerlBase(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_TARGET_ROOTFS_CPIO=y
  7. # BR2_TARGET_ROOTFS_TAR is not set
  8. """
  9. def login(self):
  10. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  11. self.emulator.boot(arch="armv5",
  12. kernel="builtin",
  13. options=["-initrd", cpio_file])
  14. self.emulator.login()
  15. def module_test(self, module, script="1"):
  16. cmd = "perl -M{} -e '{}'".format(module, script)
  17. self.assertRunOk(cmd)
  18. class TestPerl(TestPerlBase):
  19. config = TestPerlBase.config + \
  20. """
  21. BR2_PACKAGE_PERL=y
  22. """
  23. def version_test(self):
  24. cmd = "perl -v"
  25. output, exit_code = self.emulator.run(cmd)
  26. self.assertEqual(exit_code, 0)
  27. self.assertIn("This is perl 5", output[1])
  28. def core_modules_test(self):
  29. self.module_test("Cwd")
  30. self.module_test("Data::Dumper")
  31. self.module_test("Devel::Peek")
  32. self.module_test("Digest::MD5")
  33. self.module_test("Digest::SHA")
  34. self.module_test("Encode")
  35. self.module_test("Fcntl")
  36. self.module_test("File::Glob")
  37. self.module_test("Hash::Util")
  38. self.module_test("I18N::Langinfo")
  39. self.module_test("IO::Handle")
  40. self.module_test("IPC::SysV")
  41. self.module_test("List::Util")
  42. self.module_test("MIME::Base64")
  43. self.module_test("POSIX")
  44. self.module_test("Socket")
  45. self.module_test("Storable")
  46. self.module_test("Sys::Hostname")
  47. self.module_test("Sys::Syslog")
  48. self.module_test("Time::HiRes")
  49. self.module_test("Time::Piece")
  50. self.module_test("Unicode::Collate")
  51. self.module_test("Unicode::Normalize")
  52. def test_run(self):
  53. self.login()
  54. self.version_test()
  55. self.core_modules_test()