| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
Although the client read() method provides a return value to indicate
that daemon output has become unavailable (due to its death), the
run() method in fake.py was ignoring it, and just repeatedly outputting
the old string until it eventually noticed the death. It now pays
attention to the failure return.
TESTED:
All tests pass. Quitting the daemon while stopped at a breakpoint no
longer spews duplicated output for a while.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Death of the daemon (after initial connection) wasn't being noticed,
so that the daemon dying (e.g., by quitting it from a debugger) left
gpsfake looping and spewing output. This puts an alive check in the
main loop, as well as in an inner loop that's sometimes relevant.
TESTED:
Quit the daemon after stopping at breakpoints in a couple of different
cases; gpsfake now quits with an error. It does still spew a bunch of
duplicated output in some cases, though.
|
|
|
|
|
|
|
|
|
|
| |
Although there doesn't seem to be any WRITE_PAD value that's 100%
reliable, 5ms is usually adequately generous for OSX, and is the override
value currently used by MacPorts. The current default 30ms makes
some tests way too slow.
TESTED:
Tests pass on OSX 10.5-10.13.
|
|
|
|
|
|
|
|
|
|
|
| |
This adds an argument to allow overriding the default 60-second
timeout on gpsd's activity. A value of 0 disables the timeout
completely. Note that the timeout mechanism is somewhat sloppy, and
typically adds about 20s to the value.
TESTED:
Ran with unspecified (default) timeout, a short timeout, a long
timeout, and no timeout, all with reasonable results.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
pylint complains when a class function is overridden with a function
taking different arguments.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This doesn't fix all complaints by pylint, but significantly
reduces their number. Ditto for pep8 complaints.
Also makes a couple of related cosmetic edits.
TESTED:
Ran "scons build-all check" with no errors.
Both "pylint" and "pep8" targets report fewer issues.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The default port number used by gpsfake is (probably incorrectly)
specified as a string rather than an integer. The shmkey derivation
added in commit 1f209455 expects an integer, causing a failure when
the port is not explicitly specified. This fix forces an integer
where needed.
TESTED:
Ran "scons build-all check".
Previously failing gpsfake case now works correctly.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this change, multiple gpsd instances would normally share a
single SHM segment, confusing anyone using it. This was a problem
either when running parallel regression tests, or even when running a
single test with a system gpsd also running. Now, each gpsd instance
launched by fake.py gets a SHM ID of the form 0x4770xxxx, where xxxx
is the TCP or UDP port number. The high-order part is 0x4770 ('Gp')
instead of 0x4750 ('GP') to ensure that it doesn't collide with the
standard 'GPSD'.
This does not do anything about 'NTPx' SHM segments.
TESTED:
Ran "scons -j24 check", and observed many 'Gpxx' SHM segments with
ipcs, all disappearing by the end of testing.
|
|
|
|
|
|
|
|
|
|
|
| |
This generates a more specific exception when a connect from
client_add() fails due to the daemon's having died. Aside from real
daemon failures, this also catches some broken valgrind cases.
TESTED:
Ran "scons build-all check" on OSX. Also ran failing valgrind-audit
and observed more informative (and less verbose) backtrace. Note that
this is due to an OSX issue with valgrind itself, not the daemon.
|
|
|
|
|
|
|
|
|
| |
This reduces duplicated code by using subclasses for local exceptions.
It's not entirely clear that limiting __str__() to only certain
exceptions is necessary, but it preserves that behavior.
TESTED:
Ran "scons build-all check" on several platforms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This does two things:
1) It splits DaemonInstance into a base class and subclass, where the
base class is a more generic subprogram runner. This makes it easier
to add additional program runners without code duplication.
2) It switches from os.system() to subprocess.Popen() as the mechanism
for running subprograms. This is generally cleaner, and in
"background mode" is able to use natural parallelism rather than the
ugly kludge of using shell backgrounding. Aside from being less ugly,
this also makes termination of the "background" process directly
visible, avoiding, e.g., hangs when valgrind bombs.
TESTED:
Ran "scons build-all check" on several platforms. Also ran
valgrind-audit where valgrind was installed, though this has issues on
some platforms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Given that the data returned bye fake.py may include binary data,
'bytes' is a more appropriate type. Unlike the client API, where it's
easy to provide both return types, it would be less convenient to do
that here, so 'bytes' is preferred as the one choice (and is
consistent with network sockets).
When sending such data to stdout (or stderr), the straightforward
method is to write to sys.stdXXX.buffer rather than sys.stdXXX. That
doesn't exist in Python 2, but a helper function is now provided to
get the appropriate 'bytes' stream for stdXXX.
Since no previous *release* of GPSD is compatible with Python 3,
changing this now doesn't break anything based on released code.
TESTED:
Ran "scons check" on OSX with all supported Python versions.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This doesn't really change any behavior, but serves as a better
example for future code. Note that this can't be done so easily for
gps.gps, due to the mismatched init signatures.
This uses the older super() syntax, which is compatible with both
Python 2 and Python 3.
TESTED:
Ran "scons build-all check" with all six supported Python versions.
Also tested exception objects manually.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Although this isn't strictly a Python 3 requirement, using the
new-style class definition syntax improves consistency between Python
2 and Python 3. Old-style classes have been deprecated since Python
2.2, but many such definitions linger on. Python 3 eliminates
old-style classes, but instead of complaining about old-style
definitions, it simply unconditionally and silently makes all classes
new-style. The only incompatible differences are quite subtle and
rarely matter in practice, but things are more consistent across
versions if the new-style definitions are used.
Also, the preferred method for subclasses to invoke parent init
methods is via the super() construct, which is only available with
new-style classes. Using super() is especially useful with multiple
inheritance, which it handles automatically (provided that the init
methods have compatible signatures).
TESTED:
Ran "scons build-all check valgrind-audit", as well as gegps, gpscat,
gpsprof, xgps, and xgpsspeed, with all six supported Python versions
(except 2.6 for xgps*).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This incorporates the following changes:
1) Adds definitions for polystr(), polybytes(), and make_std_wrapper()
to misc.py (the most logical place for code needed by multiple
modules), using dummy definitions in the Python 2 case. For more
info, see the Practical Python Porting guide.
2) Reworks the logfile->daemon data path in fake.py to use 'bytes'
consistently.
3) Uses polybytes() in fake.py to construct control-socket commands as
'bytes', as expected by the socket I/O.
4) Uses make_std_wrapper() in gpsfake, to ensure that binary data is
correctly written to stdout.
5) Adds 'division' to the future imports in gpsfake for consistency,
though it doesn't actually matter in practice.
Also updates the compatibility comments in all three files, and fixes
a minor typo in misc.py.
TESTED:
Ran "scons build-all check" with Python 2.7, and ran all daemon
regression tests with Python 2.6 and with Python 3.2-3.5 (with
appropriately built extensions; not yet a build option).
|
|
|
|
|
|
|
|
|
|
|
|
| |
This ensures that any future changes that accidentally rely on the
Python 2 implicit relative import behavior will fail in Python 2 as
well as Python 3.
TESTED:
Ran "scons build-all check" (with Python 2.7). Also verified that the
regression tests and test_maidenhead.py run with Python 2.6, and that
gpsfake -T and test_maidenhead.py run with Python 3 when the
extensions are built for Python 3 (not yet a build option).
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changes the import of the 'packet' module to be an explicit
relative import, which is valid in both Python2 and Python 3. The old
implicit relative import doesn't work in Python 3.
TESTED:
Ran "scons build-all check" (with Python 2.7). Also verified that the
regression tests and test_maidenhead.py run with Python 2.6, and that
gpsfake -T and test_maidenhead.py run with Python 3 when the
extensions are built for Python 3 (not yet a build option).
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
Verified by testing gpsprof under both versions. leapecond.py is also OK.
Not yet polyglot: gegps, gpscap.py, gpscat, gpsfake, jsongen.py, maskaudit.py,
test_maidenhead.py, valgrind_audit.py, xgps, xgpsspeed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This makes it possible to view the "slow" as well as the normal
WRITE_PAD values with gpsfake -T, without having to look at the source
code. It adds a new GetDelay() function to fake.py, which returns the
proper delay value, taking into account both the possible environment
variable and the "slow" option. This is now used for all hree uses of
WRITE_PAD.
Because the environment override is now part of the function, the
WRITE_PAD constant is no longer modified by the environment value, but
instead reflects the platform default.
TESTED:
Ran the full set of regression tests, with both default and acceptably
shortened WRITE_PAD. Also verified that a zero value causes trouble
(OSX), and that adding -S to the zero value makes it work.
Signed-off-by: Jon Schlueter <jon.schlueter@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Depending on timing, in TCP mode, gpsd may try to reconnect to fake.py
between the time that the logfile is complete and the time that the
remove_device is issued. With no listener, this results in a set of
three error messages from gpsd. They don't affect the test outcome,
since they only go to stderr and the "real" output is complete, but
they're annoying to the user.
The likelihood of this happening increases with longer logfiles and
with larger WRITE_PAD values. With a 30ms WRITE_PAD (the default on
OSX), most logfiles exhibit this on all platforms, though it's not
seen on Linux with the default zero WRITE_PAD.
The fix is simply to avoid closing the listener after accepting the
incoming connection. It's not necessary to explicitly service the
listener further, since the OS listen queue is sufficient to accept
the additional connection.
Closing the listener at drain time is almost acceptable, but still
occasionally fails due to the fact that drain() is (necessarily)
called before remove_device(). Not explicitly closing it at all is
acceptable, since Python closes it as part of the object cleanup.
TESTED:
Ran regress-driver in TCP mode with a 30ms WRITE_PAD on all logfiles
on three versions of OSX, as well as Linux, FreeBSD, and OpenBSD, both
with and without the fix. Observed spurious errors in all cases
without the fix, and no cases with the fix. Also verified that no
dangling sockets were left at the end of the runs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current method for assigning ports uses a counter initialized to a
constant. Although this works fine for multiple sessions managed by a
single instance of fake.py, it fails miserably when running multiple
parallel instances of fake.py. The fix is to allow the OS to assign
the port numbers, since it's guaranteed to pick unused ports.
In the TCP case, this is simply a matter of specifying 0 as the port,
and then extracting the actual assigned port number with
getsockname().
In the UDP case, it's more complicated since the port number being
picked is actually for *gpsd's* end, which can't be done in a
straightforward manner. The workaround, which was already being used
to pick the control-socket port for gpsd, is to bind a socket with a
reusable address, close it, and then assume that the port will remain
available until gpsd grabs it. This change turns the existing code to
do that into a function, with the socket type now being specifiable.
TESTED:
Ran all daemon tests in both TCP and UDP modes, on three versions of
OSX as well as Linux, FreeBSD, and OpenBSD. Used default WRITE_PAD
values except on OSX, where it was reduced to 1ms to save time.
Signed-off-by: Jon Schlueter <jon.schlueter@gmail.com>
|
| |
|
|
|
|
|
| |
large scale autopep8 cleanup of several
pep8 whitespace warnings
|
| |
|
|
|
|
|
|
|
|
| |
When gpsfake is run as root, it may, depending on OS configuration,
create the pty's with 600 permissions that gpsd can not later read.
Make fake.py create all pty's permission 666. Solves the problem
running scons check as root on Gentoo and OS X.
|
| |
|
|
|
|
| |
No logic changes. All regression tests pass.
|
| |
|
|
|
|
| |
All regression tests pass.
|
|
|
|
| |
All regression tests pass.
|
| |
|
| |
|
| |
|
|
|
|
| |
All regression tests pass.
|
|
|
|
|
|
|
|
|
| |
Regression tests pass with nonblocking I/O, but a regression test *rebuild*
fails with timing errors. Much as we want a solution to the select-buzz
problem, this change must go on hold until the root cause of the timing
problems is found and fixed.
Regression tests still pass.
|
| |
|
|
|
|
| |
This commit has no semantic change, just housekeeping.
|
| |
|
| |
|
| |
|
| |
|
| |
|