Skip to content

Commit

Permalink
print stmts
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Aug 1, 2020
1 parent 3955de7 commit 6cd0762
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/test_debugger/test_networking.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Tests for the socket server."""

from typing import Optional
from subprocess import PIPE, Popen, run
from subprocess import Popen, run, PIPE
from shlex import split
import time
import pytest
import socket as net
import json
import logging

from dashmips.debuggerserver import send_dashmips_message, receive_dashmips_message

Expand All @@ -18,8 +19,12 @@
def server():
"""Start dashmips server."""
if SHOULD_START_SERVER:
debugger = Popen(split("python -m dashmips debug -i localhost -l tests/test_mips/smallest.mips"))
debugger = Popen(split("python -m dashmips debug -i localhost -l tests/test_mips/smallest.mips"), bufsize=1, stderr=PIPE, encoding="utf8")
time.sleep(0.2) # sleep so we can connect

if debugger.stderr:
print(debugger.stderr.readline())

assert debugger.returncode is None, "dashmips exited before we could test"
return debugger
return None
Expand All @@ -34,11 +39,9 @@ def test_connect(server):
"""Test that the socket is available for connecting."""
if server:
assert server.returncode is None, "Dashmips Exited before we could test!!"
try:
s = net.create_connection(ADDRESS)
assert s is not None
except ConnectionRefusedError as e:
assert False, "Failed to connect"

s = net.create_connection(ADDRESS)
assert s is not None

if server:
server.kill() # Avoid reuse addr errors
Expand Down

0 comments on commit 6cd0762

Please sign in to comment.