Skip to content

Commit

Permalink
Merge 915e6f5 into 17f0165
Browse files Browse the repository at this point in the history
  • Loading branch information
rucarrol committed Oct 20, 2019
2 parents 17f0165 + 915e6f5 commit 5f90600
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/test___main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest
import traceflow


class Test__main__(unittest.TestCase):
def test_ipid_to_ints(self):
(i, j) = traceflow.__main__.ipid_to_ints(257)
self.assertIsInstance(i, int)
self.assertIsInstance(j, int)
self.assertEqual(i, 1)
self.assertEqual(j, 1)

def test_ints_to_ipid(self):
ipid = traceflow.__main__.ints_to_ipid(1, 1)
self.assertIsInstance(ipid, int)
self.assertEqual(ipid, 257)


if __name__ == "__main__":
unittest.main()
5 changes: 5 additions & 0 deletions traceflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

from traceflow.printer import printer as printer

# Expose __main__.py functions for unittest
from traceflow.__main__ import ipid_to_ints as ipid_to_ints
from traceflow.__main__ import ints_to_ipid as ints_to_ipid


# logging
import logging

Expand Down
1 change: 1 addition & 0 deletions traceflow/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def main():
# Here we will fill in missing probes with a *
# We should also trim any duplicate replies from daddr
# and also fill in an x to pad up unequal path lengths
logging.debug(traces)
traces = remove_duplicates(traces, daddr)
path_max = max([max(traces[i].keys()) for i in traces.keys()])
for path in traces.keys():
Expand Down
7 changes: 5 additions & 2 deletions traceflow/socket_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ def __init__(self, ip_daddr):
print("Please run as root!")
exit(1)
# TODO: Test Timestamps correctly
SO_TIMESTAMPNS = 35
self.icmp_listener.setsockopt(socket.SOL_SOCKET, SO_TIMESTAMPNS, 1)
try:
SO_TIMESTAMPNS = 35
self.icmp_listener.setsockopt(socket.SOL_SOCKET, SO_TIMESTAMPNS, 1)
except OSError as e:
logging.debug("No timestamps available")
self.ip_daddr = ip_daddr
self.mutex = threading.Lock()
logging.debug("Starting")
Expand Down

0 comments on commit 5f90600

Please sign in to comment.