mirror of
https://github.com/3cky/mbusd
synced 2025-10-19 23:54:47 +08:00
Set up stdout and stderr in Popen() calls in tests
This commit is contained in:
parent
d33d66f242
commit
b2effb1db9
|
|
@ -4,7 +4,7 @@ import random
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
from subprocess import Popen
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
from os.path import isfile
|
from os.path import isfile
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
|
@ -24,7 +24,8 @@ class TestModbusRequests(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.log.debug("1. run socat")
|
cls.log.debug("1. run socat")
|
||||||
cls.socat = Popen(["socat", "-d", "-d", "pty,raw,echo=0,link=/tmp/pts0", "pty,raw,echo=0,link=/tmp/pts1"])
|
cls.socat = Popen(["socat", "-d", "-d", "pty,raw,echo=0,link=/tmp/pts0", "pty,raw,echo=0,link=/tmp/pts1"],
|
||||||
|
stdout=PIPE, stderr=STDOUT)
|
||||||
|
|
||||||
cls.log.debug("2. run rtu_slave")
|
cls.log.debug("2. run rtu_slave")
|
||||||
from environment.rtu_slave import ModbusSerialServer
|
from environment.rtu_slave import ModbusSerialServer
|
||||||
|
|
@ -32,7 +33,8 @@ class TestModbusRequests(unittest.TestCase):
|
||||||
cls.mbs.start()
|
cls.mbs.start()
|
||||||
|
|
||||||
cls.log.debug("3. run mbusd to be tested with the binary:%s" % MBUSD_BINARY)
|
cls.log.debug("3. run mbusd to be tested with the binary:%s" % MBUSD_BINARY)
|
||||||
cls.mbusd_main = Popen([MBUSD_BINARY, "-d", "-L", "-v9", "-p/tmp/pts0", "-s19200", "-P" + str(MBUSD_PORT)])
|
cls.mbusd_main = Popen([MBUSD_BINARY, "-d", "-L", "-v9", "-p/tmp/pts0", "-s19200", "-P" + str(MBUSD_PORT)],
|
||||||
|
stdout=PIPE, stderr=STDOUT)
|
||||||
# wait a little bit for mbusd to come up
|
# wait a little bit for mbusd to come up
|
||||||
# alternatively do a poll for the socket
|
# alternatively do a poll for the socket
|
||||||
# https://stackoverflow.com/questions/667640/how-to-tell-if-a-connection-is-dead-in-python/667702#667702
|
# https://stackoverflow.com/questions/667640/how-to-tell-if-a-connection-is-dead-in-python/667702#667702
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user