test_z3.py 1.1 KB

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