From aab049c7e9630bc8992c0fcd0edd593d00b00b93 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Sun, 24 Nov 2019 15:47:46 -0500 Subject: Fix socat spawning in tests --- .../test/scala/akka/serial/PseudoTerminal.scala | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sync/src/test/scala/akka/serial/PseudoTerminal.scala b/sync/src/test/scala/akka/serial/PseudoTerminal.scala index 3e9e9fe..7ed675a 100644 --- a/sync/src/test/scala/akka/serial/PseudoTerminal.scala +++ b/sync/src/test/scala/akka/serial/PseudoTerminal.scala @@ -15,21 +15,21 @@ trait PseudoTerminal { val dir = Files.createTempDirectory("akka-serial-pty").toFile val pty = new File(dir, "pty") - val socat = try { - val s = Seq( - "socat", - "-d -d", - s"exec:cat,pty,raw,b115200,echo=0", - s"pty,raw,b115200,echo=0,link=${pty.getAbsolutePath}" - ).run(ProcessLogger(println(_)), false) - Thread.sleep(SetupTimeout.toMillis) // allow ptys to set up - s - } catch { - case NonFatal(ex) => - throw new IOException( - "Error running echo service, make sure the program 'socat' is installed", ex) + val socat = Process( + "socat", + Seq( + "-d", "-d", + s"exec:cat,pty,raw,b115200,echo=0", + s"pty,raw,b115200,echo=0,link=${pty.getAbsoluteFile()}" + ) + ).run(ProcessLogger(println(_)), false) + + Thread.sleep(SetupTimeout.toMillis) // allow ptys to set up + + if (!socat.isAlive()) { + sys.error(s"socat exited too early with code ${socat.exitValue()}") } - + try { val result = action(pty.getAbsolutePath, SerialSettings(baud = 115200)) Thread.sleep(SetupTimeout.toMillis) // allow for async cleanup before destroying ptys -- cgit v1.2.3