make rpc frontend unix socket test less fragile
authorN. Engelhardt <nak@symbioticeda.com>
Thu, 13 Feb 2020 19:52:22 +0000 (20:52 +0100)
committerN. Engelhardt <nak@symbioticeda.com>
Thu, 13 Feb 2020 19:52:22 +0000 (20:52 +0100)
tests/rpc/frontend.py
tests/rpc/run-test.sh
tests/rpc/unix.ys [deleted file]

index eff41738ab63d16911e60f00eb5f48d7e14e13a4..eace07bf91c0ba682f139b6eafde27663b62c23b 100644 (file)
@@ -31,7 +31,7 @@ end
 
 import json
 import argparse
-import sys, socket, os
+import sys, socket, os, subprocess
 try:
        import msvcrt, win32pipe, win32file
 except ImportError:
@@ -85,6 +85,7 @@ def main():
                sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
                sock.bind(args.path)
                try:
+                       ys_proc = subprocess.Popen(["../../yosys", "-ql", "unix.log", "-p", "connect_rpc -path {}; read_verilog design.v; hierarchy -top top; flatten; select -assert-count 1 t:$neg".format(args.path)])
                        sock.listen(1)
                        conn, addr = sock.accept()
                        file = conn.makefile("rw")
@@ -93,7 +94,11 @@ def main():
                                if not input: break
                                file.write(call(input) + "\n")
                                file.flush()
+                       ys_proc.wait(timeout=10)
+                       if ys_proc.returncode:
+                               raise subprocess.CalledProcessError(ys_proc.returncode, ys_proc.args)
                finally:
+                       ys_proc.kill()
                        sock.close()
                        os.unlink(args.path)
 
index 44ce7e6741f45edf2bad06e8f6424cfef095f8dd..eeb309347cfebe275352830b57dcb18c1407a30b 100755 (executable)
@@ -4,3 +4,4 @@ for x in *.ys; do
   echo "Running $x.."
   ../../yosys -ql ${x%.ys}.log $x
 done
+python3 frontend.py unix-socket frontend.sock
diff --git a/tests/rpc/unix.ys b/tests/rpc/unix.ys
deleted file mode 100644 (file)
index cc7ec14..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-!python3 frontend.py unix-socket frontend.sock & sleep 0.1
-connect_rpc -path frontend.sock
-read_verilog design.v
-hierarchy -top top
-flatten
-select -assert-count 1 t:$neg