chiark / gitweb /
exercise the C client a bit from tests
authorRichard Kettlewell <rjk@greenend.org.uk>
Tue, 27 Nov 2007 22:21:50 +0000 (22:21 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Tue, 27 Nov 2007 22:21:50 +0000 (22:21 +0000)
tests/dtest.py
tests/queue.py

index 7c0bae000445883bde64fcbea33e7ee77371ce4b..bedbec9a84cb33dec1203ffa235ba6453873e174 100644 (file)
@@ -41,9 +41,10 @@ else:
 sys.path.insert(0, os.path.join(top_builddir, "python"))
 import disorder
 
-# Make sure the server build directory is on the executable search path
+# Make sure the build directories are on the executable search path
 ospath = os.environ["PATH"].split(os.pathsep)
 ospath.insert(0, os.path.join(top_builddir, "server"))
+ospath.insert(0, os.path.join(top_builddir, "clients"))
 os.environ["PATH"] = os.pathsep.join(ospath)
 
 # Parse the makefile in the current directory to identify the source directory
@@ -322,6 +323,14 @@ def check_files():
             failures += 1
     return failures
 
+def command(args):
+    """Execute a command given as a list and return its stdout"""
+    p = subprocess.Popen(args, stdout=subprocess.PIPE)
+    lines = p.stdout.readlines()
+    rc = p.wait()
+    assert rc == 0, ("%s returned status %s" % (args, rc))
+    return lines
+
 # -----------------------------------------------------------------------------
 # Common setup
 
index 7f56af0e28dc7ed757c9a79cf6e38d3fb80bae8b..3be7c2a58536640199224e826d747d1864ebc2c9 100755 (executable)
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA
 #
-import dtest,time,disorder
+import dtest,time,disorder,re
 
 def test():
     """Check the queue is padded to the (default) configured length"""
     dtest.start_daemon()
     c = disorder.client()
+    print " getting queue via python module"
     q = c.queue()
     assert len(q) == 10, "queue is at proper length"
+    print " getting queue via disorder(1)"
+    q = dtest.command(["disorder", "--config", disorder._configfile, "queue"])
+    tracks = filter(lambda s: re.match("^track", s), q)
+    assert len(tracks) == 10, "queue is at proper length"
 
 if __name__ == '__main__':
     dtest.run()