chiark / gitweb /
sync with trunk
authorRichard Kettlewell <rjk@greenend.org.uk>
Thu, 22 Nov 2007 13:17:54 +0000 (13:17 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Thu, 22 Nov 2007 13:17:54 +0000 (13:17 +0000)
1  2 
server/trackdb.c
tests/dbversion.py
tests/dtest.py
tests/files.py

Simple merge
index 78788b1e0ca45a090bb3e5e5ef1e7ae082883c0e,0000000000000000000000000000000000000000..d7f58a59f6a5b3a8e63a5bb5d1724301544c9efb
mode 100755,000000..100755
--- /dev/null
@@@ -1,41 -1,0 +1,39 @@@
-     time.sleep(2)
 +#! /usr/bin/env python
 +#
 +# This file is part of DisOrder.
 +# Copyright (C) 2007 Richard Kettlewell
 +#
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
 +# the Free Software Foundation; either version 2 of the License, or
 +# (at your option) any later version.
 +#
 +# This program is distributed in the hope that it will be useful, but
 +# WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 +# General Public License for more details.
 +#
 +# You should have received a copy of the GNU General Public License
 +# along with this program; if not, write to the Free Software
 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 +# USA
 +#
 +import dtest,time,disorder,sys,re,subprocess
 +
 +def test():
 +    """Database version tests"""
 +    # Start up with dbversion 1
 +    config = "%s/config" % dtest.testroot
 +    configsave = "%s.save" % config
 +    dtest.copyfile(config, configsave)
 +    open(config, "a").write("dbversion 1\n")
 +    dtest.start_daemon()
-     time.sleep(4)
 +    dtest.stop_daemon()
 +    # Revert to default configuration
 +    dtest.copyfile(configsave, config)
 +    print "Testing daemon manages to upgrade..."
 +    dtest.start_daemon()
 +    assert dtest.check_files() == 0
 +
 +if __name__ == '__main__':
 +    dtest.run()
diff --cc tests/dtest.py
index 00c5ead8b6af810ad727ca7195dfd8a47bb1874f,6ae9fd74cdde2f4de9fcff120fca7ee0444d6a2d..ab76991b8e04568c7d56c4888b8d0c62996f4ec8
@@@ -21,7 -21,7 +21,7 @@@
  
  """Utility module used by tests"""
  
- import os,os.path,subprocess,sys,re,unicodedata
 -import os,os.path,subprocess,sys,re,time
++import os,os.path,subprocess,sys,re,time,unicodedata
  
  def fatal(s):
      """Write an error message and exit"""
@@@ -181,6 -147,24 +187,22 @@@ Start the daemon.""
                                 "--foreground",
                                 "--config", "%s/config" % testroot],
                                stderr=errs)
 -    disorder._configfile = "%s/config" % testroot
 -    disorder._userconf = False
+     # Wait for the socket to be created
+     waited = 0
+     while not os.path.exists(socket):
+         rc = daemon.poll()
+         if rc is not None:
+             print "FATAL: daemon failed to start up"
+             sys.exit(1)
+         waited += 1
+         if waited == 1:
+             print "  waiting for socket..."
+         elif waited >= 60:
+             print "FATAL: took too long for socket to appear"
+             sys.exit(1)
+         time.sleep(1)
+     if waited > 0:
+         print "  took about %ds for socket to appear" % waited
  
  def stop_daemon():
      """stop_daemon()
diff --cc tests/files.py
index 24d4ea458f5d3781dc66aaa67b059fef2fe91aaf,0000000000000000000000000000000000000000..3fc19f4577d3c427bbeac17e98b10ccc4737d2fe
mode 100755,000000..100755
--- /dev/null
@@@ -1,30 -1,0 +1,29 @@@
-     time.sleep(2)                       # give rescan a chance
 +#! /usr/bin/env python
 +#
 +# This file is part of DisOrder.
 +# Copyright (C) 2007 Richard Kettlewell
 +#
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
 +# the Free Software Foundation; either version 2 of the License, or
 +# (at your option) any later version.
 +#
 +# This program is distributed in the hope that it will be useful, but
 +# WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 +# General Public License for more details.
 +#
 +# You should have received a copy of the GNU General Public License
 +# along with this program; if not, write to the Free Software
 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 +# USA
 +#
 +import dtest,time,disorder,sys
 +
 +def test():
 +    """Check that the file listing comes out right"""
 +    dtest.start_daemon()
 +    assert dtest.check_files() == 0
 +
 +if __name__ == '__main__':
 +    dtest.run()