--- /dev/null
- 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()
"""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"""
"--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()
--- /dev/null
- 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()