summaryrefslogtreecommitdiff
path: root/gps
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-02-09 06:13:31 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-02-09 06:13:31 -0500
commit156c381715e13466682af32d284ee1c684b0de96 (patch)
treecd4610ad39f6c8cc8a927882cb421118dd4ce0aa /gps
parent2bfb81a123d1eb21358f0c6bfe730562f755dd32 (diff)
downloadgpsd-156c381715e13466682af32d284ee1c684b0de96.tar.gz
CLOSE_DELAY is gone. Test source termination is now deterministic.
All regression tests pass.
Diffstat (limited to 'gps')
-rw-r--r--gps/fake.py73
1 files changed, 4 insertions, 69 deletions
diff --git a/gps/fake.py b/gps/fake.py
index 250c4e26..9a9e9c98 100644
--- a/gps/fake.py
+++ b/gps/fake.py
@@ -72,92 +72,38 @@ import exceptions, threading, socket, select
import gps
import packet as sniffer
-# The two magic numbers below have to be derived from observation. If
-# they're too high you'll slow the tests down a lot. If they're too low
+# The magic number below has to be derived from observation. If
+# it's too high you'll slow the tests down a lot. If they're too low
# you'll get random spurious regression failures that usually look
# like lines missing from the end of the test output relative to the
-# check file. The need for them may be symptomatic of race conditions
+# check file. The need for it may be symptomatic of race conditions
# in the pty layer or elsewhere.
# WRITE_PAD: Define a per-line delay on writes so we won't spam the
# buffers in the pty layer or gpsd itself. Values smaller than the
# system timer tick don't make any difference here.
-# CLOSE_DELAY: We delay briefly after a GPS source is exhausted before
-# removing it. This should give its subscribers time to get gpsd's
-# response before we call the cleanup code. Note that using fractional
-# seconds in CLOSE_DELAY may have no effect; Python time.time()
-# returns a float value, but it is not guaranteed by Python that the C
-# implementation underneath will return with precision finer than 1
-# second. (Linux and *BSD return full precision.)
-
# Field reports on minima:
#
-# Eric Raymond runningLinux 3.11.0 on an Intel Core Duo at 2.66GHz.
-# WRITE_PAD = 0.0 / CLOSE_DELAY = 0.1 Works, 112s real
-# WRITE_PAD = 0.0 / CLOSE_DELAY = 0.05 Fails
-#
-# Michael Tatarinov running ?? on a Raspberry Pi:
-# WRITE_PAD = 0.0 / CLOSE_DELAY = 0.05 Works, 344s real
-# WRITE_PAD = 0.0 / CLOSE_DELAY = 0.0 Fails, 339s real
-#
-# Hal Murray running NetBSD 6.1.2 on an Intel(R) Celeron(R) CPU 2.80GHz
-# WRITE_PAD = 0.0 / CLOSE_DELAY = 0.4 Works, takes 688.69s real
-# WRITE_PAD = 0.0 / CLOSE_DELAY = 0.3 Fails tcp-torture.log, 677.53s real
-#
-# Greg Troxel running NetBSD 6 on a Core i5 (i386, 4 cpus) 2.90GHz.
-# WRITE_PAD = 0.001 / CLOSE_DELAY = 0.2 had failures (645s)
-# WRITE_PAD = 0.001 / CLOSE_DELAY = 0.4 had failures (662s)
-# WRITE_PAD = 0.000 / CLOSE_DELAY = 0.8 had 69/89 failures (148s)
-# WRITE_PAD = 0.001 / CLOSE_DELAY = 0.8 all tests passed (697s)
-# WRITE_PAD = 0.004 / CLOSE_DELAY = 0.8 all tests passed (737s)
-#
-# Greg Troxel running NetBSD 5 on a Core 2 Duo E8500 (amd64, 2 cpus) 3.167GHz.
-# WRITE_PAD = 0.004 / CLOSE_DELAY = 0.8 had 7/89 failures (730s)
-# WRITE_PAD = 0.004 / CLOSE_DELAY = 2.0 had 3/89 failures (757s)
-# WRITE_PAD = 0.010 / CLOSE_DELAY = 2.0 had 32/89 failures (755s)
-# WRITE_PAD = 0.004 / CLOSE_DELAY = 4.0 had 13/89 failures (795s)
-# WRITE_PAD = 0.004 / CLOSE_DELAY = 8.0 had 27/89 failures (872s)
-# WRITE_PAD = 0.100 / CLOSE_DELAY = 8.0 had 9/89 failures (3519s)
-# WRITE_PAD = 0.100 / CLOSE_DELAY = 8.0 had 7/89 failures (3539s)
-# WRITE_PAD = 0.200 / CLOSE_DELAY = 8.0 all tests passed (6456s)
-# WRITE_PAD = 0.200 / CLOSE_DELAY = 0.8 all tests passed (6310s)
-#
-# Greg Troxel running OS X 10.9 on a Core i7 (2 cpus) 1.7 GHz.
-# WRITE_PAD = 0.01 / CLOSE_DELAY = 4 had 81/89 failures (767s)
-# WRITE_PAD = 0.01 / CLOSE_DELAY = 10 had 81/89 failures (1288s)
-# WRITE_PAD = 0.03 / CLOSE_DELAY = 1 all tests passed (1111s)
-# WRITE_PAD = 0.03 / CLOSE_DELAY = 2 all tests passed (1194s)
-# WRITE_PAD = 0.05 / CLOSE_DELAY = 2 all tests passed (1780s)
-# WRITE_PAD = 0.1 / CLOSE_DELAY = 2 all tests passed (3248s)
-# WRITE_PAD = 1 / CLOSE_DELAY = 2 all tests passed (29665s)
-# WRITE_PAD = 1 / CLOSE_DELAY = 10 all tests passed (30362s)
# examples are "# sys.platform platform.platform()"
if sys.platform.startswith("linux"):
WRITE_PAD = 0.0
- CLOSE_DELAY = 0.1
elif sys.platform.startswith("freebsd"):
WRITE_PAD = 0.001
- CLOSE_DELAY = 0.4
elif sys.platform.startswith("netbsd5"):
WRITE_PAD = 0.200
- CLOSE_DELAY = 0.8
elif sys.platform.startswith("netbsd"):
WRITE_PAD = 0.004
- CLOSE_DELAY = 0.8
elif sys.platform.startswith("darwin"):
# darwin Darwin-13.4.0-x86_64-i386-64bit
WRITE_PAD = 0.03
- CLOSE_DELAY = 1
else:
WRITE_PAD = 0.004
- CLOSE_DELAY = 0.8
# Additional delays in slow mode
WRITE_PAD_SLOWDOWN = 0.01
-CLOSE_DELAY_SLOWDOWN = 2.0
class TestLoadError(exceptions.Exception):
def __init__(self, msg):
@@ -570,9 +516,6 @@ class TestSession:
self.port = port
else:
self.port = gps.GPSD_PORT
- self.close_delay = CLOSE_DELAY
- if slow:
- self.close_delay += CLOSE_DELAY_SLOWDOWN
self.progress = lambda x: None
self.reporter = lambda x: None
self.default_predicate = None
@@ -668,10 +611,7 @@ class TestSession:
had_output = False
chosen = self.choose()
if isinstance(chosen, FakeGPS):
- if chosen.exhausted and (time.time() - chosen.exhausted > self.close_delay) and chosen.byname in self.fakegpslist:
- self.gps_remove(chosen.byname)
- self.progress("gpsfake: GPS %s removed (timeout)\n" % chosen.byname)
- elif not chosen.go_predicate(chosen.index, chosen):
+ if not chosen.go_predicate(chosen.index, chosen):
if chosen.exhausted == 0:
chosen.exhausted = time.time()
self.progress("gpsfake: GPS %s ran out of input\n" % chosen.byname)
@@ -686,11 +626,6 @@ class TestSession:
chosen.read()
if chosen.valid & gps.PACKET_SET:
self.reporter(chosen.response)
- # If we're lucky, this close notification reaches
- # us before the device timeout. It would be nice
- # if this were the only logic for device closing
- # and we could get rid of CLOSE_DELAY, but this
- # sometimes fails on binary logfiles.
if chosen.data["class"] == "DEVICE" and chosen.data["activated"] == 0 and chosen.data["path"] in self.fakegpslist:
self.gps_remove(chosen.data["path"])
self.progress("gpsfake: GPS %s removed (notification)\n" % chosen.data["path"])