diff --git a/sched/wd_nresults_changing.php b/sched/wd_nresults_changing.php
index 660a102ac9..498033d81b 100755
--- a/sched/wd_nresults_changing.php
+++ b/sched/wd_nresults_changing.php
@@ -1,4 +1,4 @@
-#! /usr/local/bin/php
+#! /usr/local/bin/php -q
%s%s>\n" % (key, dic[key], key)
- return s
+ s += " <%s>%s%s>\n" % (key, dic[key], key)
+ return s[:-1]
+
+class STARTS_WITH(str):
+ pass
def dict_match(dict, resultdict):
'''match values in DICT against RESULTDICT'''
@@ -177,7 +191,11 @@ def dict_match(dict, resultdict):
except KeyError:
error("Database query result didn't have key '%s'!" % key)
continue
- if found != expected:
+ if isinstance(expected,STARTS_WITH):
+ match = found.startswith(expected)
+ else:
+ match = found == expected
+ if not match:
id = resultdict.get('id', '?')
if str(found).count('\n') or str(expected).count('\n'):
format = """result %s: unexpected %s:
@@ -425,12 +443,10 @@ class Project:
verbose_echo(1, "Setting up server files: writing config files");
- config = '\n'
- config += map_xml(self,
- [ 'db_name', 'db_passwd', 'shmem_key',
- 'key_dir', 'download_url', 'download_dir',
- 'upload_url', 'upload_dir', 'project_dir', 'user_name' ])
- config += '\n'
+ config = map_xml(self,
+ [ 'db_name', 'db_passwd', 'shmem_key',
+ 'key_dir', 'download_url', 'download_dir',
+ 'upload_url', 'upload_dir', 'project_dir', 'user_name' ])
self.append_config(config)
# put a file with the database name and other info in each HTML
@@ -505,11 +521,12 @@ class Project:
def _run_cgi_onepass(self, prog, args=''):
self._run_cgi_prog(prog, '-d 3 -one_pass '+args)
def start_servers(self):
+ self.restart()
self._run_cgi_prog('start_servers')
verbose_sleep("Starting servers for project '%s'" % self.short_name, 1)
def _install_prog(self, prog, args=''):
- self.append_config('./%s -d 3 -asynch %s >>%s.out 2>&1\n' % (
+ self.append_config('./%s -d 3 -asynch %s >>%s.out 2>&1' % (
prog, args, prog))
def install_feeder(self):
self._install_prog('feeder')
@@ -537,10 +554,10 @@ class Project:
self._run_cgi_onepass('file_deleter')
def install_assimilator(self):
for app_version in self.app_versions:
- self._install_prog('assimilator', app_version.app.name)
+ self._install_prog('assimilator', '-app %s' % app_version.app.name)
def assimilate(self):
for app_version in self.app_versions:
- self._run_cgi_onepass('assimilator', app_version.app.name)
+ self._run_cgi_onepass('assimilator', '-app %s' % app_version.app.name)
def start_stripcharts(self):
map(lambda l: self.copy(os.path.join('stripchart', l), 'cgi/'),
@@ -568,12 +585,18 @@ class Project:
def restart(self):
'''remove the stop_server trigger'''
- os.unlink(self.dir('cgi', 'stop_server'))
+ try:
+ os.unlink(self.dir('cgi', 'stop_server'))
+ except OSError:
+ pass
+ configlines = ''
def append_config(self, line):
- f = open(self.dir('cgi/.htconfig.xml'), 'a')
- print >>f, line
- f.close()
+ self.configlines += '\n' + line
+ f = open(self.dir('cgi/.htconfig.xml'), 'w')
+ print >>f, ''
+ print >>f, self.configlines
+ print >>f, ''
def remove_config(self, pattern):
config = self.dir('cgi/.htconfig.xml')
@@ -609,29 +632,29 @@ class Project:
self.db_open(self.db_name)
return self.db_query("select count(*) from result where server_state=4")[0][0]
- def check_files_match(self, result, correct):
- if not check_exists(result):
- return 0
- if os.system("diff %s %s" % (self.dir(result), correct)):
- error("File mismatch for project '%s': %s %s" % (self.short_name, result, correct))
- return 1
- else:
- verbose_echo(2, "Files match for project '%s': %s %s" % (self.short_name, result, correct))
- return 0
- def check_all_files_match(self, num, result, correct):
- '''result should contain a "%d" which is replaced by [0,NUM)'''
- for i in range(num):
- self.check_files_match(result%i, correct)
- def check_deleted(self, file):
- check_deleted(self.dir(file))
- def check_all_deleted(self, num, file):
- for i in range(num):
- self.check_deleted(file%i)
- def check_exists(self, file):
+ def check_files_match(self, result, correct, count=None):
+ '''if COUNT is specified then [0,COUNT) is mapped onto the %d in RESULT'''
+ if count != None:
+ errs = 0
+ for i in range(count):
+ errs += self.check_files_match(result%i, correct)
+ return errs
+ return check_files_match(self.dir(result),
+ correct, " for project '%s'"%self.short_name)
+ def check_deleted(self, file, count=None):
+ if count != None:
+ errs = 0
+ for i in range(count):
+ errs += self.check_deleted(file%i)
+ return errs
+ return check_deleted(self.dir(file))
+ def check_exists(self, file, count=None):
+ if count != None:
+ errs = 0
+ for i in range(count):
+ errs += self.check_exists(file%i)
+ return errs
return check_exists(self.dir(file))
- def check_all_exist(self, file):
- for i in range(num):
- self.check_exists(file%i)
class User:
'''represents an account on a particular project'''
@@ -666,18 +689,19 @@ class Host:
verbose_echo(2, "Setting up host '%s': writing %s" % (self.name, filename))
f = open(filename, "w")
- print >>f, "\n"
+ print >>f, ""
print >>f, map_xml(project, ['master_url'])
print >>f, map_xml(user, ['authenticator'])
print >>f, user.project_prefs
- print >>f, "\n"
+ print >>f, ""
f.close()
# copy log flags and global prefs, if any
if self.log_flags:
shutil.copy(self.log_flags, self.dir('log_flags.xml'))
if self.global_prefs:
- shutil.copy(self.global_prefs, self.dir('global_prefs.xml'))
+ shell_call("cp %s %s" % (self.global_prefs, self.dir('global_prefs.xml')))
+ # shutil.copy(self.global_prefs, self.dir('global_prefs.xml'))
def run(self, args, asynch=False):
if asynch:
@@ -778,11 +802,15 @@ def test_msg(msg):
def test_done():
global errors
if sys.__dict__.get('last_traceback'):
- errors += 1
- sys.stderr.write("\nException thrown - bug in test scripts?\n")
+ if sys.last_type == KeyboardInterrupt:
+ errors += 0.1
+ sys.stderr.write("\nTest canceled by user\n")
+ else:
+ errors += 1
+ sys.stderr.write("\nException thrown - bug in test scripts?\n")
if errors:
verbose_echo(0, "ERRORS: %d" % errors)
- sys.exit(errors)
+ sys.exit(int(errors))
else:
verbose_echo(1, "Passed test!")
if VERBOSE == 1:
diff --git a/test/test_uc.py b/test/test_uc.py
index 67856942bd..f85a1cd787 100755
--- a/test/test_uc.py
+++ b/test/test_uc.py
@@ -14,15 +14,14 @@ class ProjectUC(Project):
self.add_core_version()
self.add_app_and_version("upper_case")
self.user = User()
- self.user.project_prefs = "\nfoobar\n\n"
+ self.user.project_prefs = "\nfoobar\n"
self.user.global_prefs = """
0
2
1
400000
-
-"""
+"""
self.add_user(self.user)
# must install projects before adding hosts (WHY?)
self.install()
@@ -53,16 +52,16 @@ class ProjectUC(Project):
self.validate(self.work.redundancy)
result = {}
result['server_state'] = RESULT_SERVER_STATE_OVER
- result['stderr_out'] = """APP: upper_case: starting, argc 1
+ result['stderr_out'] = STARTS_WITH("""APP: upper_case: starting, argc 1
APP: upper_case: argv[0] is upper_case
-APP: upper_case ending, wrote """
- result['exit_status'] = 0
+APP: upper_case ending, wrote """)
+ # result['exit_status'] = 0
self.check_results(2, result)
- self.check_all_files_match(2, "uc_wu_%d_0", "uc_correct_output")
+ self.check_files_match("upload/uc_wu_%d_0", "uc_correct_output", count=2)
self.assimilate()
self.file_delete()
- self.check_server_deleted("download/input")
- self.check_all_deleted(2, "upload/uc_wu_%d_0")
+ self.check_deleted("download/input")
+ self.check_deleted("upload/uc_wu_%d_0", count=2)
self.stop()
if __name__ == '__main__':