Closed kb1lqc closed 6 years ago
The first failure shows a pretty clear clue pointing at the issue.
=================================== FAILURES ===================================
_____________________ test_serialParamaterizedSynchSend[] ______________________
test_input = b''
@pytest.mark.parametrize("test_input", [
(b""),
(bytes(string.ascii_letters, "utf-8")),
(bytes(string.ascii_uppercase, "utf-8")),
(bytes(string.ascii_lowercase, "utf-8")),
(bytes(string.digits, "utf-8")),
(bytes(string.hexdigits, "utf-8")),
(bytes(string.printable, "utf-8")),
(bytes(string.octdigits, "utf-8")),
(sliplib.slip.END),
(sliplib.slip.END*2),
(sliplib.slip.ESC),
(sliplib.slip.ESC*2),
(sliplib.slip.ESC_ESC),
(sliplib.slip.ESC_ESC*2),
(sliplib.slip.ESC_END),
(sliplib.slip.ESC_END*2),
])
def test_serialParamaterizedSynchSend(test_input):
# Create class object necessary for test
serialPort = SerialTestClass()
faradayRadio = faraday.Faraday(serialPort)
# Create slip message to test against
slipMsg = sliplib.encode(test_input)
# Send data over Faraday
> res = faradayRadio.send(test_input)
tests/test_serial.py:46:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <faradayio.faraday.Faraday object at 0x7f36a992a128>, msg = b''
def send(self, msg):
"""Encodes data to slip protocol and then sends over serial port
Uses the SlipLib module to convert the message data into SLIP format.
The message is then sent over the serial port opened with the instance
of the Faraday class used when invoking send().
Args:
msg (bytes): Bytes format message to send over serial port.
Returns:
int: Number of bytes transmitted over the serial port.
"""
# Create a sliplib Driver
slipDriver = sliplib.Driver()
# Package data in slip format
slipData = slipDriver.send(msg)
# Send data over serial port
> res = self._serialPort.write(slipData)
E AttributeError: 'SerialTestClass' object has no attribute 'write'
This is happening because the faradayRadio = faraday.Faraday(serialPort)
in the unit test code is NOT passing a pyserial descriptor. This can be remidied by specifying the SerialTestClass()
property self.serialPort
when passing into the faradayio
functions in a way that mimics using normal pyserial
ports.
Serial port errors have been alleviated! Now I'm onto the Threading.Event
errors shown below...
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
rootdir: /home/bryce/Documents/git/faradayio, inifile:
plugins: cov-2.5.1
collected 37 items
tests/test_serial.py ................................. [ 89%]
tests/test_tun.py FFFF [100%]
=================================== FAILURES ===================================
________________________________ test_tunSetup _________________________________
def test_tunSetup():
"""Setup a Faraday TUN and check initialized values"""
# Create a test serial port
serialPort = SerialTestClass()
# Create test TUN monitor which sets up a python-pytun TUN device at _TUN
> faradayTUN = faraday.Monitor(serialPort=serialPort)
E TypeError: __init__() missing 1 required positional argument: 'isRunning'
tests/test_tun.py:17: TypeError
_________________________________ test_tunSend _________________________________
def test_tunSend():
"""
Start a TUN adapter and send a message through it. This tests sending ascii
over a socket connection through the TUN while using pytun to receive the
data and check that the IP payload is valid with scapy.
"""
# Create a test serial port
serialPort = SerialTestClass()
# Create test TUN monitor which sets up a python-pytun TUN device at _TUN
> faradayTUN = faraday.Monitor(serialPort=serialPort)
E TypeError: __init__() missing 1 required positional argument: 'isRunning'
tests/test_tun.py:36: TypeError
_______________________________ test_tunSlipSend _______________________________
def test_tunSlipSend():
"""
Test SLIP data sent over the TUN adapter and serial port.
Start a TUN adapter and send data over it while a thread runs to receive
data sent over the tunnel and promptly send it over a serial port which is
running a serial loopback test. Ensures data at the end of the loopback
test is valid when received over serial. This test does not cover serial
to TUN/IP nor IP to TUN data validation.
"""
# Create a test serial port
serialPort = SerialTestClass()
# Configure destination IP:port
destHost = '10.0.0.2'
destPort = 9999
# Start the monitor
> TUNMonitor = faraday.Monitor(serialPort=serialPort)
E TypeError: __init__() missing 1 required positional argument: 'isRunning'
tests/test_tun.py:91: TypeError
_______________________________ test_serialToTUN _______________________________
def test_serialToTUN():
"""
Test serial port to TUN link. Don't need a serial port but just assume that
an IP packet was received from the serial port and properly decoded with
SLIP. Send it to the TUN and verify that the IP:PORT receives the message.
"""
# Create a test serial port for TUN Monitor class. Won't be used.
serialPort = SerialTestClass()
# Configure TUN IP:PORT and IP Packet source IP:PORT parameters for test
sourceAddress = '10.0.0.2'
sourcePort = 9998
destPort = 9999
# Start a TUN Monitor class
> TUNMonitor = faraday.Monitor(serialPort=serialPort)
E TypeError: __init__() missing 1 required positional argument: 'isRunning'
tests/test_tun.py:149: TypeError
===================== 4 failed, 33 passed in 0.45 seconds ======================
This should be easy since in https://github.com/FaradayRF/faradayio/pull/44/commits/771a631a12c67b0655c27c304b6638beadda882c I added the need to pass the isRunning
parameter in the Monitor
class initialization and removed the need to pass it with the run()
function.
Fixed after removing some flake8
errors in https://travis-ci.org/FaradayRF/faradayio/jobs/346672578!
Passing unit tests and linting on Travis CI builds show the problem has been fixed. Will address coverage issues in #39
PR #44 brings in the
serialtest
fixes which changed how the TUN was used. This causes the unit testing to change.The following Travis CI build shows what failures occur. https://travis-ci.org/FaradayRF/faradayio/builds/346652907?utm_source=github_status&utm_medium=notification
Unit Test Errors