123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <!--
- This file is Copyright 2005 by the GPSD project
- SPDX-License-Identifier: BSD-2-clause
- -->
- <!DOCTYPE refentry PUBLIC
- "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
- <refentry id='gpsfake.1'>
- <refentryinfo><date>30 March 2020</date></refentryinfo>
- <refmeta>
- <refentrytitle>gpsfake</refentrytitle>
- <manvolnum>1</manvolnum>
- <refmiscinfo class="source">The GPSD Project</refmiscinfo>
- <refmiscinfo class="manual">GPSD Documentation</refmiscinfo>
- </refmeta>
- <refnamediv id='name'>
- <refname>gpsfake</refname>
- <refpurpose>test harness for gpsd, simulating a GPS</refpurpose>
- </refnamediv>
- <refsynopsisdiv id='synopsis'>
- <cmdsynopsis>
- <command>gpsfake</command>
- <arg choice='opt'>-1</arg>
- <arg choice='opt'>-b</arg>
- <arg choice='opt'>--baton</arg>
- <arg choice='opt'>-c <replaceable>interval</replaceable></arg>
- <arg choice='opt'>--cycle <replaceable>interval</replaceable></arg>
- <arg choice='opt'>-D <replaceable>debuglevel</replaceable></arg>
- <arg choice='opt'>-g</arg>
- <arg choice='opt'>-G</arg>
- <arg choice='opt'>--gdb</arg>
- <arg choice='opt'>-h</arg>
- <arg choice='opt'>--help</arg>
- <arg choice='opt'>-i</arg>
- <arg choice='opt'>--initcmd <replaceable>initcmd</replaceable></arg>
- <arg choice='opt'>-l</arg>
- <arg choice='opt'>--linedump</arg>
- <arg choice='opt'>--lldb</arg>
- <arg choice='opt'>--monitor <replaceable>monitor</replaceable></arg>
- <arg choice='opt'>-m <replaceable>monitor</replaceable></arg>
- <arg choice='opt'>-n</arg>
- <arg choice='opt'>--nowait</arg>
- <arg choice='opt'>--options <replaceable>options</replaceable></arg>
- <arg choice='opt'>-o <replaceable>options</replaceable></arg>
- <arg choice='opt'>-p</arg>
- <arg choice='opt'>--pipe</arg>
- <arg choice='opt'>--port <replaceable>port</replaceable></arg>
- <arg choice='opt'>--predump</arg>
- <arg choice='opt'>-P <replaceable>port</replaceable></arg>
- <arg choice='opt'>--promptme</arg>
- <arg choice='opt'>-q</arg>
- <arg choice='opt'>--quiet</arg>
- <arg choice='opt'>-r <replaceable>initcmd</replaceable></arg>
- <arg choice='opt'>-S</arg>
- <arg choice='opt'>--singleshot</arg>
- <arg choice='opt'>--slow</arg>
- <arg choice='opt'>--speed <replaceable>speed</replaceable></arg>
- <arg choice='opt'>-s <replaceable>speed</replaceable></arg>
- <arg choice='opt'>-t</arg>
- <arg choice='opt'>-T</arg>
- <arg choice='opt'>--tcp</arg>
- <arg choice='opt'>--timeout <replaceable>timeout</replaceable></arg>
- <arg choice='opt'>-u</arg>
- <arg choice='opt'>--udp</arg>
- <arg choice='opt'>-v</arg>
- <arg choice='opt'>-V</arg>
- <arg choice='opt'>--verbose</arg>
- <arg choice='opt'>--version</arg>
- <arg choice='opt'>-W <replaceable>timeout</replaceable></arg>
- <arg rep='repeat'>
- <arg choice='plain'><replaceable>logfile</replaceable></arg>
- </arg>
- </cmdsynopsis>
- </refsynopsisdiv>
- <refsect1 id='description'><title>DESCRIPTION</title>
- <para><application>gpsfake</application> is a test harness for
- <application>gpsd</application> and its clients. It opens a pty
- (pseudo-TTY), launches a <application>gpsd</application> instance that
- thinks the slave side of the pty is its GPS device, and repeatedly
- feeds the contents of one or more test logfiles through the master side to the
- GPS. If there are multiple logfiles, sentences from them are
- interleaved in the order the files are specified.</para>
- <para><application>gpsfake</application> does not require root
- privileges, and can be run concurrently with a production
- <application>gpsd</application> instance without causing problems.</para>
- <para>The logfiles may contain packets in any supported format,
- including in particular NMEA, SiRF, TSIP, or Zodiac. Leading lines
- beginning with # will be treated as comments and ignored, except in
- the following special cases:</para>
- <itemizedlist>
- <listitem><para>
- a comment of the form #Date: yyyy-mm-dd (ISO8601 date format) may be
- used to set the initial date for the log.
- </para></listitem>
- <listitem><para>
- a comment of the form #Serial: [0-9]* [78][NOE][12] may be used to set
- serial parameters for the log - baud rate, word length, stop bits.
- </para></listitem>
- <listitem><para>
- a comment of the form #Transport: UDP may be used to fake a UDP source
- rather than the normal pty.
- </para></listitem>
- </itemizedlist>
- <para>The <application>gpsd</application> instance is run in
- foreground. The thread sending fake GPS data to the daemon
- is run in background.</para>
- </refsect1>
- <refsect1 id='options'><title>OPTIONS</title>
- <para><option>-?</option>,<option>-h</option>, <option>--help</option>
- makes <application>gpsfake</application> print a usage message and
- exit.</para>
- <para><option>-1</option> means the logfile is interpreted once only rather
- than repeatedly. This option is intended to facilitate regression
- testing.</para>
- <para><option>-b</option>, <option>--baton</option> enables a twirling-baton
- progress indicator on standard error. At termination, it reports elapsed
- time.</para>
- <para><option>-c</option>, <option>-cycle</option> sets the delay between
- sentences in seconds. Fractional values of seconds are legal. The default
- is zero (no delay).</para>
- <para><option>-D</option>, <option>--debug</option> passes a -D option
- to the daemon: thus -D 4 is shorthand for -o="-D 4".</para>
- <para><option>-g</option>, <option>--gdb</option> or
- <option>-G</option>, <option>--lldb</option> options use the monitor
- facility to run the <application>gpsd</application> instance within
- gpsfake under control of gdb or lldb, respectively. They also disable
- the timeout on daemon inactivity, to allow for breakpointing.
- If necessary, the timeout can be reenabled by a subsequent
- <option>-W</option> or <option>--wait</option> . If xterm and $DISPLAY
- are available, these options launch the debugger in a separate xterm
- window, to separate the debugger dialog from the program output, but
- otherwise run it directly. In the gdb case, -tui is used with xterm
- but not otherwise, since curses and program output don't play nicely
- together. Although lldb lacks an equivalent option, some versions have a
- 'gui' command.</para>
- <para><option>-i</option>, <option>--promptme</option> is for
- single-stepping through logfiles. It dumps the line or packet
- number (and the sentence if the protocol is textual) followed by
- "? ". Only when the user keys Enter is the line actually fed to
- <application>gpsd</application>.</para>
- <para><option>-l</option>, <option>--singleshot</option> makes the
- program dump a line or packet number just before each sentence is fed to
- the daemon. If the sentence is textual (e.g. NMEA), the text is dumped
- as well. If not, the packet will be dumped in hexadecimal (except for
- RTCM packets, which aren't dumped at all). This option is useful for
- checking that gpsfake is getting packet boundaries right.</para>
- <para><option>-m</option>, <option>--monitor</option>
- specifies a monitor program inside which the daemon
- should be run. This option is intended to be used with
- <citerefentry><refentrytitle>valgrind</refentrytitle>
- <manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum>
- </citerefentry> and similar programs.</para>
- <para><option>-n</option>, <option>--nowait</option> passes "-n" to the
- daemon to start the daemon reading the GPS without waiting for a client
- (equivalent to -o="-n"). </para>
- <para><option>-o</option>, <option>--option</option> specifies options
- to pass to the daemon. The -n option passes -n to start the daemon
- reading the GPS without waiting for a client (equivalent to -o="-n").
- The <option>-D</option> passes a -D option to the daemon: thus -D 4 is
- shorthand for -o="-D 4".</para>
- <para><option>-p</option>, <option>--pipe</option> sets watcher mode and
- dumps the NMEA and GPSD notifications generated by the log to standard
- output. This is useful for regression-testing.</para>
- <para><option>-P</option>, <option>--port</option> sets the daemon's
- listening port.</para>
- <para><option>-q</option>,<option>-quiet</option> tells gpsfake to
- suppress normal progress output and thus act in a quiet manner.</para>
- <para><option>-r</option>, <option>--clientinit</option> specifies
- an initialization command to use in pipe mode. The default is
- <command>?WATCH={"enable":true,"json":true}</command>.</para>
- <para><option>-s</option>, <option>--speed</option> sets the baud rate
- for the slave tty. The default is 4800.</para>
- <para><option>-S</option>, <option>--slow</option> tells gpsfake to
- insert realistic delays in the test input rather than trying to stuff it
- through the daemon as fast as possible. This will make the test(s) run
- much slower, but avoids flaky failures due to machine load and possible
- race conditions in the pty layer.</para>
- <para><option>-t</option>, <option>--tcp</option> forces the test
- framework to use TCP rather than pty devices. Besides being a test of
- TCP source handling, this may be useful for testing from within chroot
- jails where access to pty devices is locked out.</para>
- <para><option>-T</option>, <option>--sysinfo</option> makes
- <application>gpsfake</application> print some system information and
- then exit.</para>
- <para><option>-u</option>, <option>--udp</option> forces the test
- framework to use UDP rather than pty devices. Besides being a test of
- UDP source handling, this may be useful for testing from within chroot
- jails where access to pty devices is locked out.</para>
- <para><option>-v</option>, <option>--verbose</option> enables verbose
- progress reports to stderr. Use multiple times to increase verbosity.
- It is mainly useful for debugging <application>gpsfake</application>
- itself.</para>
- <para><option>-W</option>, <option>--wait</option> option sets the
- timeout on daemon inactivity, in seconds. The default timeout is 60
- seconds, and a value of 0 suppresses the timeout altogether. Note that
- the actual timeout is longer due to internal delays, typically by about
- 20 seconds.</para>
- <para><option>-x</option>,<option>--predump</option> dumps packets as
- <application>gpsfake</application> gathers them. It is mainly useful
- for debugging <application>gpsfake</application> itself.</para>
- <para>The last argument(s) must be the name of a file or
- files containing the data to be cycled at the device.
- <application>gpsfake</application> will print a notification each time
- it cycles.</para>
- <para>Normally, gpsfake creates a pty for each logfile and passes the
- slave side of the device to the daemon. If the header comment in the
- logfile contains the string "UDP", packets are instead shipped via UDP
- port 5000 to the address 192.168.0.1.255. You can monitor them with
- this: <command>tcpdump -s0 -n -A -i lo udp and port 5000</command>.</para>
- </refsect1>
- <refsect1 id='magic'><title>MAGIC COMMENTS</title>
- <para>Certain magic comments in test load headers can change the
- conditions of the test. These are:</para>
- <variablelist>
- <varlistentry>
- <term>Serial:</term>
- <listitem><para>May contain a serial-port setting such as 4800 7N2 -
- baud rate followed by 7 or 8 for byte length, N or O or E for parity
- and 1 or 2 for stop bits. The test is run with those settings on the
- slave port that the daemon sees.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term>Transport:</term>
- <listitem><para>Values 'TCP' and 'UDP' force the use of TCP and
- UDP feeds respectively (the default is a pty).</para></listitem>
- </varlistentry>
- <varlistentry>
- <term>Delay-Cookie:</term>
- <listitem><para>Must be followed by two whitespace-separated fields, a
- delimiter character and a numeric delay in seconds. Instead of being
- broken up by packet boundaries, the test load is split on the
- delimiters. The delay is performed after each feed. Can be useful
- for imposing write boundaries in the middle of packets.
- </para></listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
- <refsect1 id='custom'><title>CUSTOM TESTS</title>
- <para><application>gpsfake</application> is a trivial wrapper around a
- Python module, also named gpsfake, that can be used to fully script
- sessions involving a <application>gpsd</application> instance, any
- number of client sessions, and any number of fake GPSes feeding the
- daemon instance with data from specified sentence logs.</para>
- <para>Source and embedded documentation for this module is shipped with the
- <application>gpsd</application> development tools. You can use it to
- torture-test either <application>gpsd</application> itself or any
- <application>gpsd</application>-aware client application.</para>
- <para>Logfiles for the use with <application>gpsfake</application> can
- be retrieved using <application>gpspipe</application>,
- <application>gpscat</application>, or
- <application>gpsmon</application> from the gpsd distribution, or any
- other application which is able to create a compatible output.</para>
- <para>If <application>gpsfake</application> exits with "Cannot execute
- gpsd: executable not found." the environment variable GPSD_HOME can be
- set to the path where gpsd can be found. (instead of adding that folder
- to the PATH environment variable</para>
- </refsect1>
- <refsect1 id='environment'><title>ENVIRONMENT</title>
- <para>For unknown reasons <application>gpsfake</application> may sometimes
- time out and fail. Set the WRITE_PAD environment value to a larger value
- to avoid this issue. A starting point might be "WRITE_PAD = 0.005". Values
- as large os 0.200 may be required.</para>
- </refsect1>
- <refsect1 id='see_also'><title>SEE ALSO</title>
- <para>
- <citerefentry><refentrytitle>gpsd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>gps</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>libgps</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>libgpsmm</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>gpsctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>gpspipe</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>gpsprof</refentrytitle><manvolnum>1</manvolnum></citerefentry>
- <citerefentry><refentrytitle>gpsmon</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
- </para>
- </refsect1>
- <refsect1 id='maintainer'><title>AUTHOR</title>
- <para>Eric S. Raymond <email>esr@thyrsus.com</email>.</para>
- </refsect1>
- </refentry>
|