Files
buildroot/support/testing/tests/package/test_swipl.py
Romain Naour dac94834cc support/testing: TestSWIPL: increase timeout value
The swipl runtime test is unreliable, depending on the execution speed
of its runner or local host.

Running on a build server, the last test resolve the sudoku in
30sec while the timeout is 10sec.

  # time swipl -g top -t halt /root/sudoku.pl
  Sudoku solution:
  [9, 8, 7, 6, 5, 4, 3, 2, 1].
  [2, 4, 6, 1, 7, 3, 9, 8, 5].
  [3, 5, 1, 9, 2, 8, 7, 4, 6].
  [1, 2, 8, 5, 3, 7, 6, 9, 4].
  [6, 3, 4, 8, 9, 2, 1, 5, 7].
  [7, 9, 5, 4, 6, 1, 8, 3, 2].
  [5, 1, 9, 2, 8, 6, 4, 7, 3].
  [4, 7, 2, 3, 1, 9, 5, 6, 8].
  [8, 6, 3, 7, 4, 5, 2, 1, 9].
  real	0m 28.53s
  user	0m 27.99s
  sys	0m 0.51s

Increase the timout to 120sec.

Note: On Gitlab-CI, every emulator timeout are increased by a factor 10
to avoid sporadic failures in elastic runners.

https://gitlab.com/buildroot.org/buildroot/-/blame/2025.08-rc3/support/misc/gitlab-ci.yml.in?ref_type=tags#L101

Cc: Julien Olivain <ju.o@free.fr>
Signed-off-by: Romain Naour <romain.naour@smile.fr>
Signed-off-by: Julien Olivain <ju.o@free.fr>
2025-09-04 18:41:25 +02:00

47 lines
1.5 KiB
Python

import os
import infra.basetest
class TestSWIPL(infra.basetest.BRTest):
rootfs_overlay = \
infra.filepath("tests/package/test_swipl/rootfs-overlay")
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
f"""
BR2_PACKAGE_SWIPL=y
BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=["-initrd", cpio_file])
self.emulator.login()
# Check program executes.
cmd = "swipl --version"
self.assertRunOk(cmd)
# Check swipl fails when goal is false.
cmd = "swipl -g false"
_, exit_code = self.emulator.run(cmd)
self.assertNotEqual(exit_code, 0)
# Test output.
string = "Hello Buildroot !"
cmd = f"swipl -g 'writeln(\"{string}\")' -t halt"
output, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
self.assertEqual(output[0], string)
# Check the swipl demo file works (ex: "sam" likes "pizza").
cmd = "swipl -g '[swi(demo/likes)]' -g 'likes(sam,pizza)' -t halt"
self.assertRunOk(cmd)
# Run a more complex logic program (solve a sudoku).
cmd = "swipl -g top -t halt /root/sudoku.pl"
self.assertRunOk(cmd, timeout=120)