From: Richard Kettlewell Date: Thu, 22 Nov 2007 13:17:54 +0000 (+0000) Subject: sync with trunk X-Git-Tag: debian-1_5_99dev9~1^2~9 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/f0c20432f8c9dffd049c785f21cc85d98ff628fd sync with trunk --- f0c20432f8c9dffd049c785f21cc85d98ff628fd diff --cc tests/dbversion.py index 78788b1,0000000..d7f58a5 mode 100755,000000..100755 --- a/tests/dbversion.py +++ b/tests/dbversion.py @@@ -1,41 -1,0 +1,39 @@@ +#! /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(2) + dtest.stop_daemon() + # Revert to default configuration + dtest.copyfile(configsave, config) + print "Testing daemon manages to upgrade..." + dtest.start_daemon() - time.sleep(4) + assert dtest.check_files() == 0 + +if __name__ == '__main__': + dtest.run() diff --cc tests/dtest.py index 00c5ead,6ae9fd7..ab76991 --- a/tests/dtest.py +++ b/tests/dtest.py @@@ -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 24d4ea4,0000000..3fc19f4 mode 100755,000000..100755 --- a/tests/files.py +++ b/tests/files.py @@@ -1,30 -1,0 +1,29 @@@ +#! /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() - time.sleep(2) # give rescan a chance + assert dtest.check_files() == 0 + +if __name__ == '__main__': + dtest.run()