Merge pull request #2319 from YosysHQ/mwk/techmap-celltype-pattern
[yosys.git] / tests / rpc / frontend.py
index eff41738ab63d16911e60f00eb5f48d7e14e13a4..8cbec568238a7937720b603cad3d92f373530f50 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:
@@ -83,9 +83,11 @@ def main():
 
        if args.mode == "unix-socket":
                sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+               sock.settimeout(30)
                sock.bind(args.path)
                try:
                        sock.listen(1)
+                       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)])
                        conn, addr = sock.accept()
                        file = conn.makefile("rw")
                        while True:
@@ -93,7 +95,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)