test_python.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. import infra.basetest
  3. class TestPythonBase(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_PYTHON=y
  7. BR2_TARGET_ROOTFS_CPIO=y
  8. # BR2_TARGET_ROOTFS_TAR is not set
  9. """
  10. def test_run(self):
  11. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  12. self.emulator.boot(arch="armv5",
  13. kernel="builtin",
  14. options=["-initrd", cpio_file])
  15. self.emulator.login()
  16. cmd = "python --version 2>&1 | grep '^Python 2'"
  17. _, exit_code = self.emulator.run(cmd)
  18. self.assertEqual(exit_code, 0)
  19. cmd = "python -c 'import math; math.floor(12.3)'"
  20. _, exit_code = self.emulator.run(cmd)
  21. self.assertEqual(exit_code, 0)
  22. cmd = "python -c 'import ctypes;"
  23. cmd += "libc = ctypes.cdll.LoadLibrary(\"libc.so.1\");"
  24. cmd += "print libc.time(None)'"
  25. _, exit_code = self.emulator.run(cmd)
  26. self.assertEqual(exit_code, 0)
  27. cmd = "python -c 'import zlib'"
  28. _, exit_code = self.emulator.run(cmd)
  29. self.assertEqual(exit_code, 1)