Changeset: 03fa4565f425 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=03fa4565f425 Modified Files: testing/Mtest.py.in Branch: Jan2014 Log Message:
Make sure we remove /var/tmp/mtest-*, no matter what. That's what try/finally is for. diffs (truncated from 802 to 300 lines): diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in --- a/testing/Mtest.py.in +++ b/testing/Mtest.py.in @@ -3753,314 +3753,315 @@ def main(argv) : URLPREFIX = None global SOCK, HOST - if SOCK: - # we cannot put the UNIX socket in the mtest root, because that - # makes the UNIX socket too long on most platforms, so use - # /var/tmp/mtest and try not to forget to clean that up - sockdir = "/var/tmp/mtest-%d" % os.getpid() - try: - os.mkdir(sockdir); - SOCK = "--set mapi_usock=%s/.s.monetdb.%s" % \ - (sockdir, env['MAPIPORT']) - HOST = sockdir - os.environ['MAPIHOST'] = HOST - except: - SOCK = "" - else: - SOCK = "" - - # check for executables, set their standard options and export them - if THISFILE == "Mtest.py": - exe = {} - exe['Mtimeout'] = CheckExec('Mtimeout') , 'Mtimeout -timeout %d ' % par['TIMEOUT'] - exe['Mserver'] = CheckExec('mserver5') , '%s mserver5 %s --debug=%s --set gdk_nr_threads=%s %s --set mapi_open=true --set mapi_port=%s %s --set monet_prompt= --forcemito --set mal_listing=2 %s' % \ - (env['setDBG'], config, env['GDK_DEBUG'], env['GDK_NR_THREADS'], env['setMONETDB_MOD_PATH'], env['MAPIPORT'], SOCK, env['MSERVER_SET']) - exe['Mdiff'] = CheckExec('Mdiff') , 'Mdiff' - exe['python'] = CheckExec(sys.executable) , sys.executable - exe['MAL_Client'] = CheckExec(env['MALCLIENT'].split(None, 1)[0]) , '%s -i -e --host=%s --port=%s' % (env['MALCLIENT'], HOST, env['MAPIPORT']) - exe['SQL_Client'] = CheckExec(env['SQLCLIENT'].split(None, 1)[0]) , '%s -i -e --host=%s --port=%s' % (env['SQLCLIENT'], HOST, env['MAPIPORT']) - exe['SQL_Dump'] = CheckExec(env['SQLDUMP'].split(None, 1)[0]) , '%s --host=%s --port=%s' % (env['SQLDUMP'], HOST, env['MAPIPORT']) - exe['JAQL_Client'] = CheckExec(env['JAQLCLIENT'].split(None, 1)[0]) , '%s -i -e --host=%s --port=%s' % (env['JAQLCLIENT'], HOST, env['MAPIPORT']) - if par['TIMEOUT'] == 0 or not exe['Mtimeout'][0]: - exe['Mtimeout'] = '', '' - env['exe'] = exe - if not quiet: - SetExecEnv(exe,1) + try: # try/finally to clean up sockdir + # check for executables, set their standard options and export them + if THISFILE == "Mtest.py": + if SOCK: + # we cannot put the UNIX socket in the mtest root, because that + # makes the UNIX socket too long on most platforms, so use + # /var/tmp/mtest and try not to forget to clean that up + sockdir = "/var/tmp/mtest-%d" % os.getpid() + try: + os.mkdir(sockdir); + SOCK = "--set mapi_usock=%s/.s.monetdb.%s" % \ + (sockdir, env['MAPIPORT']) + HOST = sockdir + os.environ['MAPIHOST'] = HOST + except: + SOCK = "" + else: + SOCK = "" + + exe = {} + exe['Mtimeout'] = CheckExec('Mtimeout') , 'Mtimeout -timeout %d ' % par['TIMEOUT'] + exe['Mserver'] = CheckExec('mserver5') , '%s mserver5 %s --debug=%s --set gdk_nr_threads=%s %s --set mapi_open=true --set mapi_port=%s %s --set monet_prompt= --forcemito --set mal_listing=2 %s' % \ + (env['setDBG'], config, env['GDK_DEBUG'], env['GDK_NR_THREADS'], env['setMONETDB_MOD_PATH'], env['MAPIPORT'], SOCK, env['MSERVER_SET']) + exe['Mdiff'] = CheckExec('Mdiff') , 'Mdiff' + exe['python'] = CheckExec(sys.executable) , sys.executable + exe['MAL_Client'] = CheckExec(env['MALCLIENT'].split(None, 1)[0]) , '%s -i -e --host=%s --port=%s' % (env['MALCLIENT'], HOST, env['MAPIPORT']) + exe['SQL_Client'] = CheckExec(env['SQLCLIENT'].split(None, 1)[0]) , '%s -i -e --host=%s --port=%s' % (env['SQLCLIENT'], HOST, env['MAPIPORT']) + exe['SQL_Dump'] = CheckExec(env['SQLDUMP'].split(None, 1)[0]) , '%s --host=%s --port=%s' % (env['SQLDUMP'], HOST, env['MAPIPORT']) + exe['JAQL_Client'] = CheckExec(env['JAQLCLIENT'].split(None, 1)[0]) , '%s -i -e --host=%s --port=%s' % (env['JAQLCLIENT'], HOST, env['MAPIPORT']) + if par['TIMEOUT'] == 0 or not exe['Mtimeout'][0]: + exe['Mtimeout'] = '', '' + env['exe'] = exe + if not quiet: + SetExecEnv(exe,1) + else: + SetExecEnv(exe,0) + + #TODO: + #exe['JAVA'] = 'java' + #exe['JAVAC'] = 'javac' + + # parse commandline arguments + testdirs = [] + testlist = [] + dirlist = [] + if len(args) == 1: + if os.path.isdir(args[0]): + d = os.path.realpath(args[0]) + if startswithpath(d + os.sep, TSTSRCBASE + os.sep): + dirlist.append(d) + #TODO: + #else: + # WARNING/ERROR + elif args[0].find(os.sep) != -1: + ErrXit("'%s` is neither a valid directory in %s nor a valid test-name!" % (args[0], os.getcwd())) + elif args[0] != "All": + #TODO: + # check, whether args[0] in All + testlist.append(args[0]) + elif len(args) > 1: + i = 0 + while i < len(args) and os.path.isdir(args[i]): + d = os.path.realpath(args[i]) + if startswithpath(d + os.sep, TSTSRCBASE + os.sep): + dirlist.append(os.path.realpath(args[i])) + #TODO: + #else: + # WARNING/ERROR + i = i + 1 + if len(dirlist) == 1 and i < len(args) and args[i] != "All": + while i < len(args): + if args[i].find(os.sep) == -1: + #TODO: + # check, whether args[i] in All + testlist.append(args[i]) + #TODO + #else: + # ERROR/WARNING + i = i + 1 + else: + if i < len(args) and args[i] == "All": + i = i + 1 + #TODO: + #if i < len(args): + #if len(dirlist) > 1: + # Warn: dirlist => ignore testlist, assume All + #else: + # Warn: All => ignore testlist else: - SetExecEnv(exe,0) - - #TODO: - #exe['JAVA'] = 'java' - #exe['JAVAC'] = 'javac' - - # parse commandline arguments - testdirs = [] - testlist = [] - dirlist = [] - if len(args) == 1: - if os.path.isdir(args[0]): - d = os.path.realpath(args[0]) - if startswithpath(d + os.sep, TSTSRCBASE + os.sep): - dirlist.append(d) - #TODO: - #else: - # WARNING/ERROR - elif args[0].find(os.sep) != -1: - ErrXit("'%s` is neither a valid directory in %s nor a valid test-name!" % (args[0], os.getcwd())) - elif args[0] != "All": - #TODO: - # check, whether args[0] in All - testlist.append(args[0]) - elif len(args) > 1: - i = 0 - while i < len(args) and os.path.isdir(args[i]): - d = os.path.realpath(args[i]) - if startswithpath(d + os.sep, TSTSRCBASE + os.sep): - dirlist.append(os.path.realpath(args[i])) - #TODO: - #else: - # WARNING/ERROR - i = i + 1 - if len(dirlist) == 1 and i < len(args) and args[i] != "All": - while i < len(args): - if args[i].find(os.sep) == -1: - #TODO: - # check, whether args[i] in All - testlist.append(args[i]) - #TODO - #else: - # ERROR/WARNING - i = i + 1 + # len(args) == 0: no explicit tests specified so do all + recursive = True + + if not dirlist: + dirlist.append(os.getcwd()) + if recursive: + #TODO + #if testlist: + # WARNING + testlist = [] + for d in dirlist: + test_dirs = find_test_dirs(d) + test_dirs.sort() + for t in test_dirs: + if t not in testdirs: + testdirs.append(t) else: - if i < len(args) and args[i] == "All": - i = i + 1 - #TODO: - #if i < len(args): - #if len(dirlist) > 1: - # Warn: dirlist => ignore testlist, assume All - #else: - # Warn: All => ignore testlist - else: - # len(args) == 0: no explicit tests specified so do all - recursive = True - - if not dirlist: - dirlist.append(os.getcwd()) - if recursive: - #TODO - #if testlist: + for d in dirlist: + if os.path.basename(d) == TSTSUFF and os.path.isfile(os.path.join(d,"All")): + testdirs.append(os.path.dirname(os.path.realpath(d))) + elif os.path.isdir(os.path.join(d,TSTSUFF)) and os.path.isfile(os.path.join(d,TSTSUFF,"All")): + testdirs.append(os.path.realpath(d)) + else: + Warn("No tests found in '%s`; skipping directory!" % d) + + if len(testdirs) > 1 and testlist: + testlist = [] + #TODO # WARNING - testlist = [] - for d in dirlist: - test_dirs = find_test_dirs(d) - test_dirs.sort() - for t in test_dirs: - if t not in testdirs: - testdirs.append(t) - else: - for d in dirlist: - if os.path.basename(d) == TSTSUFF and os.path.isfile(os.path.join(d,"All")): - testdirs.append(os.path.dirname(os.path.realpath(d))) - elif os.path.isdir(os.path.join(d,TSTSUFF)) and os.path.isfile(os.path.join(d,TSTSUFF,"All")): - testdirs.append(os.path.realpath(d)) + if not testdirs: + Warn("No tests found in %s!" % ', '.join(dirlist)) + sys.exit(1) + + BusyPorts = [] + + if THISFILE == "Mtest.py": + if not env.get('NOCLEAN') and os.path.exists(os.path.join(TSTTRGBASE, TSTPREF)): + try: + shutil.rmtree(os.path.join(TSTTRGBASE, TSTPREF)) + except: + ErrXit("Failed to remove %s" % os.path.join(TSTTRGBASE, TSTPREF)) + if not os.path.exists(env['GDK_DBFARM']): + #TODO: set mode to umask + os.makedirs(env['GDK_DBFARM']) + + if not env.get('NOCLEAN') and os.path.exists(os.path.join(env['GDK_DBFARM'], TSTPREF)): + try: + shutil.rmtree(os.path.join(env['GDK_DBFARM'], TSTPREF)) + except: + ErrXit("Failed to remove %s" % os.path.join(env['GDK_DBFARM'], TSTPREF)) + try: + os.makedirs(os.path.join(env['GDK_DBFARM'], TSTPREF)) + except os.error: + if not env.get('NOCLEAN'): + ErrXit("Failed to create %s" % os.path.join(env['GDK_DBFARM'], TSTPREF)) + + try: + os.makedirs(os.path.join(TSTTRGBASE, TSTPREF)) + except os.error: + if not env.get('NOCLEAN'): + ErrXit("Failed to create %s" % os.path.join(TSTTRGBASE, TSTPREF)) + + # write .monetdb file for mclient to do authentication with + dotmonetdbfile = os.path.join(TSTTRGBASE, ".monetdb") + dotmonetdb = open(dotmonetdbfile, 'w') + dotmonetdb.write('user=monetdb\n') + dotmonetdb.write('password=monetdb\n') + dotmonetdb.close() + # and make mclient find it + os.environ['DOTMONETDBFILE'] = dotmonetdbfile + + env['TST_MODS'] = [] + env['TST_BITS'] = "" + env['TST_OIDS'] = "" + env['TST_SINGLE'] = "" + env['TST_STATIC'] = "" + if Check(splitcommand(env['exe']['Mserver'][1]) + ['--dbpath=%s' % os.path.join(env['GDK_DBFARM'], TSTPREF)], 'clients.quit();\n'): + sys.exit(1) + if GetBitsAndOIDsAndModsAndStaticAndThreads(env): + sys.exit(1) + STDERR.flush() + if not quiet: + print "Bits: ", env['TST_BITS'] + print "OIDs: ", env['TST_OIDS'] + print "Modules: ", env['TST_MODS'] + STDOUT.flush() + + port = int(env['MAPIPORT']) + busy, host, Serrno, Serrstr, S = CheckPort(port) + S[0].close() + S[1].close() + if busy: + Warn("Skipping MAPI tests as MAPIPORT=%s is not available on %s (Error #%d: '%s')!" % (env['MAPIPORT'],host,Serrno,Serrstr)) + BusyPorts.append('MAPI') + + # create '.Mapprove.rc' + env['SYST'] = os.environ['SYST'] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list