oft: add --default-negative-timeout command line option

This option controls how long OFTest waits for an event that we don't expect to
occur. It replaces several hardcoded values.
diff --git a/oft b/oft
index 7db8257..9d5df6a 100755
--- a/oft
+++ b/oft
@@ -83,7 +83,8 @@
     "relax"              : False,
     "test_params"        : "None",
     "fail_skipped"       : False,
-    "default_timeout"    : 2,
+    "default_timeout"    : 2.0,
+    "default_negative_timeout" : 0.01,
     "minsize"            : 0,
     "random_seed"        : None,
     "disable_ipv6"       : False,
@@ -191,8 +192,10 @@
     group.add_option("-t", "--test-params", help=test_params_help)
     group.add_option("--fail-skipped", action="store_true",
                       help="Return failure if any test was skipped")
-    group.add_option("--default-timeout", type="int",
+    group.add_option("--default-timeout", type=float,
                       help="Timeout in seconds for most operations")
+    group.add_option("--default-negative-timeout", type=float,
+                      help="Timeout in seconds for negative checks")
     group.add_option("--minsize", type="int",
                       help="Minimum allowable packet size on the dataplane.")
     group.add_option("--random-seed", type="int",
@@ -493,6 +496,7 @@
 logging.info("OF port map: " + str(config["port_map"]))
 
 oftest.ofutils.default_timeout = config["default_timeout"]
+oftest.ofutils.default_negative_timeout = config["default_negative_timeout"]
 oftest.testutils.MINSIZE = config['minsize']
 
 if os.getuid() != 0 and not config["allow_user"]:
diff --git a/src/python/oftest/ofutils.py b/src/python/oftest/ofutils.py
index 8cf2ae0..f81a2f5 100644
--- a/src/python/oftest/ofutils.py
+++ b/src/python/oftest/ofutils.py
@@ -10,6 +10,7 @@
 import logging
 
 default_timeout = None # set by oft
+default_negative_timeout = None # set by oft
 
 def gen_xid():
     return random.randrange(1,0xffffffff)
@@ -19,11 +20,9 @@
 The condition variable must already be acquired.
 The timeout value -1 means use the default timeout.
 There is deliberately no support for an infinite timeout.
-TODO: get the default timeout from configuration
 """
 def timed_wait(cv, fn, timeout=-1):
     if timeout == -1:
-        # TODO make this configurable
         timeout = default_timeout
 
     end_time = time.time() + timeout
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index 5b2e365..ae16ee1 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -576,11 +576,6 @@
     DEPRECATED in favor in verify_packets
     """
 
-    # Wait this long for packets that we don't expect to receive.
-    # 100ms is (rarely) too short for positive tests on slow
-    # switches but is definitely not too short for a negative test.
-    negative_timeout = 0.1
-
     exp_pkt_arg = None
     if oftest.config["relax"]:
         exp_pkt_arg = pkt
@@ -598,7 +593,7 @@
                              "Received packet does not match expected packet " +
                              "on port " + str(ofport))
     if len(no_ports) > 0:
-        time.sleep(negative_timeout)
+        time.sleep(oftest.ofutils.negative_timeout)
     for ofport in no_ports:
         logging.debug("Negative check for pkt on port " + str(ofport))
         (rcv_port, rcv_pkt, pkt_time) = dp.poll(
@@ -1605,7 +1600,7 @@
 
     # Negative test, need to wait a short amount of time before checking we
     # didn't receive the message.
-    time.sleep(0.5)
+    time.sleep(oftest.ofutils.default_negative_timeout)
 
     # Check every packet_in queued in the controller
     while True:
@@ -1648,7 +1643,10 @@
     Check that a particular packet is not received
     """
     logging.debug("Negative check for pkt on port %r", ofport)
-    (rcv_port, rcv_pkt, pkt_time) = test.dataplane.poll(port_number=ofport, exp_pkt=str(pkt), timeout=0.01)
+    (rcv_port, rcv_pkt, pkt_time) = \
+        test.dataplane.poll(
+            port_number=ofport, exp_pkt=str(pkt),
+            timeout=oftest.ofutils.default_negative_timeout)
     test.assertTrue(rcv_pkt == None, "Received packet on %r" % ofport)
 
 def verify_no_other_packets(test):
@@ -1660,7 +1658,7 @@
     if oftest.config["relax"]:
         return
     logging.debug("Checking for unexpected packets on all ports")
-    (rcv_port, rcv_pkt, pkt_time) = test.dataplane.poll(timeout=0.01)
+    (rcv_port, rcv_pkt, pkt_time) = test.dataplane.poll(timeout=oftest.ofutils.default_negative_timeout)
     if rcv_pkt != None:
         logging.debug("Received unexpected packet on port %r: %s", rcv_port, format_packet(rcv_pkt))
     test.assertTrue(rcv_pkt == None, "Unexpected packet on port %r" % rcv_port)