From aa4b25a90d2501553658d96267a01e2eda2297bf Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 2 Feb 2015 14:14:49 -0500 Subject: In the test framework, use the bind-to-port-0 trick to get a random unused port. This makes the -f option of gpsfake obsolete, and it has been removed. All regression tests pass. --- gpsfake | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'gpsfake') diff --git a/gpsfake b/gpsfake index cc3d7adb..3ef7e4bd 100755 --- a/gpsfake +++ b/gpsfake @@ -51,16 +51,6 @@ class Baton: self.stream.write("...(%2.2f sec) %s.\n" % (time.time() - self.time, msg)) return -def fakeport(): - "Find a port that isn't in use to bind to." - # Grab a random port from IANA's unassigned/private range. Not perfect, - # but at least less than in 16000 chance of a pair collision. It would - # be very hard to get this deterministically correct, since there would - # always be a window between port allocation and when the daemon picked - # it up. We'd need to do some kind of semaphore, etc., and even that - # wouldn't prevent collisions with other apps using the range. - return random.randint(49152, 65535) - def hexdump(s): rep = "" for c in s: @@ -94,7 +84,7 @@ def fakehook(linenumber, fakegps): if __name__ == '__main__': try: - (options, arguments) = getopt.getopt(sys.argv[1:], "1bc:D:fghilm:no:pP:r:s:StTuvx") + (options, arguments) = getopt.getopt(sys.argv[1:], "1bc:D:ghilm:no:pP:r:s:StTuvx") except getopt.GetoptError, msg: print "gpsfake: " + str(msg) raise SystemExit, 1 @@ -118,8 +108,6 @@ if __name__ == '__main__': for (switch, val) in options: if (switch == '-1'): singleshot = True - elif (switch == '-f'): - port = fakeport() elif (switch == '-b'): progress = True elif (switch == '-c'): -- cgit v1.2.1