test_z3.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import os
  2. import infra.basetest
  3. class TestZ3(infra.basetest.BRTest):
  4. # Need to use a different toolchain than the default due to
  5. # z3 requiring fenv.h not provided by uclibc.
  6. config = \
  7. """
  8. BR2_arm=y
  9. BR2_TOOLCHAIN_EXTERNAL=y
  10. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
  11. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_GLIBC_STABLE=y
  12. BR2_PACKAGE_PYTHON3=y
  13. BR2_PACKAGE_Z3=y
  14. BR2_PACKAGE_Z3_PYTHON=y
  15. BR2_ROOTFS_OVERLAY="{}"
  16. BR2_TARGET_ROOTFS_CPIO=y
  17. # BR2_TARGET_ROOTFS_TAR is not set
  18. """.format(
  19. # overlay to add a z3 smt and python test scripts
  20. infra.filepath("tests/package/test_z3/rootfs-overlay"))
  21. def test_run(self):
  22. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  23. self.emulator.boot(arch="armv5",
  24. kernel="builtin",
  25. options=["-initrd", cpio_file])
  26. self.emulator.login()
  27. # Check program executes
  28. cmd = "z3 --version"
  29. self.assertRunOk(cmd)
  30. # Run a basic smt2 example
  31. cmd = "z3 /root/z3test.smt2"
  32. output, exit_code = self.emulator.run(cmd)
  33. self.assertEqual(exit_code, 0)
  34. self.assertEqual(output[0], "unsat")
  35. # Run a basic python example
  36. cmd = "/root/z3test.py"
  37. self.assertRunOk(cmd, timeout=10)