diff --git a/.travis.yml b/.travis.yml index 27316ec..41cc3e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ services: docker before_install: docker pull verilator/verilator:latest script: - docker run --rm -t -v `pwd`:/build -w /build --entrypoint /bin/bash verilator/verilator:latest -c "apt update; apt install -y default-jre-headless gnupg; apt update; echo 'deb https://dl.bintray.com/sbt/debian /' | tee -a /etc/apt/sources.list.d/sbt.list; apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823; apt update; apt install -y sbt; make; make check" + docker run --rm -t -v `pwd`:/build -w /build --entrypoint /bin/bash verilator/verilator:latest -c "apt update; apt install -y default-jre-headless gnupg python3-pexpect; apt update; echo 'deb https://dl.bintray.com/sbt/debian /' | tee -a /etc/apt/sources.list.d/sbt.list; apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823; apt update; apt install -y sbt; make; make check; ./scripts/test_micropython_long.py" diff --git a/scripts/test_micropython_long.py b/scripts/test_micropython_long.py new file mode 100755 index 0000000..9191ee2 --- /dev/null +++ b/scripts/test_micropython_long.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +import tempfile +import os +from shutil import copyfile +import subprocess +from pexpect import fdpexpect +import sys +import signal + +tempdir = tempfile.TemporaryDirectory() +cwd = os.getcwd() +os.chdir(tempdir.name) + +copyfile(os.path.join(cwd, 'micropython/firmware.hex'), + os.path.join(tempdir.name, 'insns.hex')) + +cmd = [ os.path.join(cwd, 'chiselwatt') ] + +devNull = open(os.devnull, 'w') +p = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stdin=subprocess.PIPE, stderr=subprocess.PIPE) + +exp = fdpexpect.fdspawn(p.stdout) +exp.logfile = sys.stdout.buffer + +exp.expect('Type "help\(\)" for more information.') +exp.expect('>>>') + +p.stdin.write(b'n2=0\r\n') +p.stdin.write(b'n1=1\r\n') +p.stdin.write(b'for i in range(30):\r\n') +p.stdin.write(b' n0 = n1 + n2\r\n') +p.stdin.write(b' print(n0)\r\n') +p.stdin.write(b' n2 = n1\r\n') +p.stdin.write(b' n1 = n0\r\n') +p.stdin.write(b'\r\n') +p.stdin.flush() + +exp.expect('n1 = n0', timeout=60) +n2 = 0 +n1 = 1 +for i in range(30): + n0 = n1 + n2 + exp.expect("%s" % n0, timeout=60) + n2 = n1 + n1 = n0 + +os.kill(p.pid, signal.SIGKILL)