Browse Source

[trac420] Check the returned data

The tests only received data, but did not check it is correct. Now it is
checked.
Michal 'vorner' Vaner 14 years ago
parent
commit
ed69c4be96
1 changed files with 9 additions and 6 deletions
  1. 9 6
      src/bin/msgq/tests/msgq_test.py

+ 9 - 6
src/bin/msgq/tests/msgq_test.py

@@ -6,6 +6,7 @@ import socket
 import signal
 import signal
 import sys
 import sys
 import time
 import time
+import isc.cc
 
 
 #
 #
 # Currently only the subscription part and some sending is implemented...
 # Currently only the subscription part and some sending is implemented...
@@ -195,13 +196,15 @@ class SendNonblock(unittest.TestCase):
                     os.kill(queue_pid, signal.SIGTERM)
                     os.kill(queue_pid, signal.SIGTERM)
                     sys.exit(1)
                     sys.exit(1)
                 signal.signal(signal.SIGALRM, killall)
                 signal.signal(signal.SIGALRM, killall)
-                msg = msgq.preparemsg({"type" : "ping"}, {"data" : data})
+                msg = msgq.preparemsg({"type" : "ping"}, data)
                 now = time.clock()
                 now = time.clock()
                 while time.clock() - now < 0.2:
                 while time.clock() - now < 0.2:
                     out.sendall(msg)
                     out.sendall(msg)
-                    amount = 0
-                    while amount < length:
-                        amount += len(out.recv(1024 + length - amount))
+                    # Check the answer
+                    (routing, received) = msgq.read_packet(out.fileno(), out)
+                    self.assertEqual({"type" : "pong"},
+                        isc.cc.message.from_wire(routing))
+                    self.assertEqual(data, received)
                 os.kill(queue_pid, signal.SIGTERM)
                 os.kill(queue_pid, signal.SIGTERM)
         self.terminate_check(run)
         self.terminate_check(run)
 
 
@@ -209,13 +212,13 @@ class SendNonblock(unittest.TestCase):
         """
         """
         Tests sending small data many times.
         Tests sending small data many times.
         """
         """
-        self.send_many("data")
+        self.send_many(b"data")
 
 
     def test_large_sends(self):
     def test_large_sends(self):
         """
         """
         Tests sending large data many times.
         Tests sending large data many times.
         """
         """
-        data = "data"
+        data = b"data"
         for i in range(1, 20):
         for i in range(1, 20):
             data = data + data
             data = data + data
         self.send_many(data)
         self.send_many(data)