⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mtest.py.in

📁 这个是内存数据库中的一个管理工具
💻 IN
📖 第 1 页 / 共 5 页
字号:
            if bodyline is not None:                body.append(bodyline)        TIMES.append([TSTDIR,'',"%7.3f" % td,td,FdOut,FdErr])        if THISFILE in ["Mtest.py", "Mprofile.py"]:            CreateHtmlIndex(env, *body)            elem = AddSubToHtmlIndex(env, TSTDIR, max(FdOut,FdErr))        # HACK: remove large data-/input- files to save disk space        for f in 'tcpip2.init.bat', 'ascii_io.4MBload', 'test100k', 'no.145.k100_unique1', 'test_00.k100_unique1', 'VOCrightpages.xml', 'VOCleftpages.xml':            p = os.path.join(TSTTRGDIR,f)            if os.path.isfile(p):                os.remove(p)    else: # THISFILE == "Mapprove.py"        if not os.path.exists(TSTTRGDIR):            Warn("Output directory '"+TSTTRGDIR+"` missing; skipping directory!")            return td, elem        for TST,COND in testlist:            td = td + ApproveOutput(env, TST)    return td, elem### PerformDir(env, testdir, testlist, BusyPorts) #def ApproveOutput (env, TST) :    sem = 0    TSTDB = env['TSTDB']    TSTDIR  = env['TSTDIR']    TSTSRCDIR = env['TSTSRCDIR']    TSTTRGDIR = env['TSTTRGDIR']    os.chdir(TSTSRCDIR)    EXTENSIONS = par['EXTENSION']    FORCE = par['FORCE']#       filter = re.compile( "^!WARNING: TCPlisten\([0-9]*\): stopped.$"        "|"#                            "^!WARNING: TCPepilogue: terminate [01] listeners$", re.MULTILINE)    for WHAT in EXTENSIONS:        testOUTPUT = os.path.join(TSTTRGDIR,TST+".test."+WHAT)        TSTSRCDIRTST = os.path.join(TSTSRCDIR,TST)        stableOUT  = TSTSRCDIRTST+".stable."+WHAT        if par['SYSTEM']:            SYSTEM = par['SYSTEM']            stableOUTPUT = stableOUT+SYSTEM        else:            if WHAT == 'out':                w = 0            else: # WHAT == 'err'                w = 1            stableOUTPUT = TSTSRCDIRTST+StableOutErr(env,par,TSTSRCDIRTST,OS,RELEASE)[w]            SYSTEM = stableOUTPUT.split(WHAT)[-1]        if os.path.isfile(testOUTPUT):#                       print "Approving "+testOUTPUT+" -> "+stableOUTPUT            if os.path.isfile(stableOUTPUT):                oc = 'overwriting old'            else:                oc = 'creating new'                if os.path.isfile(stableOUT):                    shutil.copy(stableOUT,stableOUTPUT)                else:                    open(stableOUTPUT,"w").close()            for d in ('TMPDIR', 'TMP', 'TEMP'):                if os.environ.has_key(d):                    patch = os.environ[d]                    break            else:                patch = os.path.join(os.sep, 'tmp')            patch = os.path.join(patch, "%s.patch-%s" % (os.path.basename(stableOUTPUT), str(os.getpid())))            os.system('diff -Bb "-I^[#=]" -U0 "%s" "%s" > "%s"' % (stableOUTPUT,testOUTPUT,patch+".0"))            if os.path.getsize(patch+".0"):                print "Approving  %s  ->  stable.%s%s   (%s file)" % (os.path.join(TSTDIR,TST+".test."+WHAT), WHAT, SYSTEM, oc)                f = open(patch+".1", "w")                for l in fileinput.input(patch+".0"):                    if len(l) < 2  or  \                       ( l[:2] not in ['+!','+=']  and  l[:10] != '+ERROR = !'  and  \                         l[:8] != '+ERROR: '  and  l[:10] != '+WARNING: ' ) :        # or  filter.match(ln):                        f.write(l)                    else:                        if FORCE:                            f.write(l)                            as = 'Approving'                        else:                            f.write(l[:1]+'\n')                            as = 'Skipping'                        Warn('%s new (error) message: "%s"' % (as,l.replace(os.linesep, '')))                        sem = 1                f.flush()                f.close()                shutil.copy(stableOUTPUT,stableOUTPUT+".ORG")                os.system('patch "%s" "%s"' % (stableOUTPUT,patch+".1"))                os.system('diff -u "%s" "%s" > "%s"' % (stableOUTPUT+".ORG",stableOUTPUT,patch))                os.remove(stableOUTPUT+".ORG")                os.remove(patch+".1")            else:                print "No differences detected between  %s and  stable.%s%s  that are not ignored by Mtest.py." % (os.path.join(TSTDIR,TST+".test."+WHAT), WHAT, SYSTEM)            os.remove(patch+".0")            thefile = os.path.split(stableOUTPUT)[1]            dir,file = os.path.split(stableOUT)            test = re.compile('^%s.*$' % re.escape(file))            list = []            for f in os.listdir(dir or os.curdir):                if f != thefile and test.match(f):                    list.append(f)            if len(list) > 0:                Warn('There are other (specific) stable outputs for test  %s:\n  %s' % (os.path.join(TSTDIR,'Tests',TST), str(list)))                STDERR.write('  To propagate the changes that were just made in  %s\n' % os.path.join(TSTDIR,'Tests',thefile))                STDERR.write('  to the other (specific) stable outputs,\n')                STDERR.write('  simply apply the patch in  %s  to them.\n\n' % patch)                STDERR.flush()        else:            i = TST.rfind('.')            if i > 0:                return ApproveOutput(env, TST[:i])            Warn("Output file missing: '"+testOUTPUT+"`; skipping test!")    return sem### ApproveOutput (env, TST) #def isexecutable(TST) :    if   os.name == "nt":        for ext in ".exe", ".com", ".bat", ".cmd":            if TST.lower().endswith(ext):                tst = TST            else:                tst = TST + ext            if os.path.isfile(tst) or os.path.isfile(tst+".src"):                return [ 1, ext ]    elif os.name == "posix":        #TODO:        # check with "file", and set executable        if os.path.isfile(TST)  and  os.access(TST,os.X_OK):            return [ 1, "" ]        if os.path.isfile(TST+".src")  and  os.access(TST+".src",os.X_OK):            return [ 1, "" ]    #TODO:    #else:        # ???    return [ 0, "" ]### isexecutable(TST) ## this function is a slightly modified copy of the posixpath version# the difference is the doubling of \'s in the replacement value_varprog = Nonedef expandvars(path):    """Expand shell variables of form $var and ${var}.  Unknown variables    are left unchanged."""    global _varprog    if '$' not in path:        return path    if not _varprog:        import re        _varprog = re.compile(r'\$(\w+|\{[^}]*\})')    i = 0    while True:        m = _varprog.search(path, i)        if not m:            break        i, j = m.span(0)        name = m.group(1)        if name.startswith('{') and name.endswith('}'):            name = name[1:-1]        if name in os.environ:            tail = path[j:]            val = os.environ[name].replace('\\', '\\\\')            path = path[:i] + val            i = len(path)            path += tail        else:            i = j    return pathdef GetBitsAndOIDsAndModsAndStatic(env) :    rtrn = 0    TSTPREF = env['TSTPREF']    cmd = '%s%s --dbname=%s' % (env['exe']['Mtimeout'][1], env['exe']['Mserver'][1], TSTPREF)    pOut,pIn,pErr = popen2.popen3(cmd)    if env['VERSION'] >= 49900:        pIn.write('''\            clients.quit();        ''')    else:        pIn.write('''\            help("kunion");            {                # print a list of all modules found                # "Modules: mod1, mod2, ..."                var MODs := kunion(bat("monet_mod_nme").reverse().mark(oid(nil)),view_modules().reverse().mark(oid(nil))).kunique();                printf("\\nModules: ");                var x := "";                MODs@batloop(){                    printf("%s\'%s\'",x,$h);                    x:=",";                }                printf("\\n");            }            quit();        ''')    ##module("NoModule");    try:        pIn.close()    except IOError, (IOerrNo, IOerrStr):        Warn("Closing input pipe in GetBitsAndOIDsAndModsAndStatic failed with #%d: '%s'." % (IOerrNo, IOerrStr))    qOut, qErr = ReadMultiple([pOut, pErr])    env['TST_MODS'] = []    env['TST_BITS'] = ""    env['TST_OIDS'] = ""    env['TST_FIVE'] = ""    env['TST_STATIC'] = ""    if qOut:        tbs = re.compile("^# Compiled for .*/([63][42]bit) with ([63][42])bit OIDs;? (.*) linked", re.MULTILINE)        tm = re.compile("^Modules: (.*)$", re.MULTILINE)        #ts = re.compile("^!ERROR: DL_open: library not found \(STATIC\).$", re.MULTILINE)        for l in qOut.split('\n'):            bs = tbs.match(l)            if bs:                env['TST_BITS'] = bs.group(1)                os.environ['TST_BITS'] = env['TST_BITS']                env['TST_OIDS'] = "oid" + bs.group(2)                os.environ['TST_OIDS'] = env['TST_OIDS']                if bs.group(3) == "statically":                    env['TST_STATIC'] = "STATIC"                    os.environ['TST_STATIC'] = env['TST_STATIC']            m = tm.match(l)            if m:                env['TST_MODS'] = eval(m.group(1))            #s = ts.match(l)            #if s:            #       env['TST_STATIC'] = "1"            #       os.environ['TST_STATIC'] = env['TST_STATIC']        if not env['TST_BITS']:            ErrMsg("Checking for Bits failed!")        if not env['TST_OIDS']:            ErrMsg("Checking for OIDs failed!")        if not env['TST_MODS']:            if env['VERSION'] >= 49900:                Warn("Monet5: Check, whether required modules do exist, is not possible, yet!")                env['TST_MODS'].append("")            else:                ErrMsg("Checking for Modules failed!")        if not env['TST_BITS'] or not env['TST_OIDS'] or not env['TST_MODS']:            STDERR.write(cmd + "\n\n")            STDERR.write(qOut)            STDERR.write("\n")            STDERR.write(qErr)            STDERR.write("\n")            STDERR.flush()            rtrn = 1    else:        rtrn = 1        ErrMsg("No output from Mserver when checking for Bits, OIDs & Modules!?")        if qErr:            STDERR.write(cmd + "\n\n")            STDERR.write(qErr)            STDERR.write("\n")            STDERR.flush()    os.environ['TST_MODS'] = str(env['TST_MODS'])    if env['VERSION'] >= 49900:        env['TST_FIVE'] = "Five"    return rtrn### GetBitsAndOIDsAndModsAndStatic(env) #def CheckMods(env, TST, SERVER, CALL) :    missing = []    if env['VERSION'] >= 49900:        return missing    if os.path.isfile(TST+".modules"):        for m in fileinput.input(TST+".modules"):            m = m.strip()            if m  and  m[0] != "#"  and  m not in env['TST_MODS']:                missing.append(m)    if SERVER == "MAPI":        for m in "streams", "mapi":            if m not in env['TST_MODS']:                missing.append(m)    if SERVER == "SQL":        for m in env['SQL_SERVER'], "streams", "ascii_io", "monettime", "alarm", "xtables", "aggrX3", "blob", "txtsim", "mmath", "mkey", "bat_arith", "pcre":            if m not in env['TST_MODS']:                missing.append(m)    if SERVER == "XQUERY":        for m in "pathfinder", "pf_support", "ascii_io", "alarm", "malalgebra", "aggrX3", "xtables", "mapi":            if m not in env['TST_MODS']:                missing.append(m)    if CALL in ["x100", "x100Xs"]:        for m in "amdb", "storage":            if m not in env['TST_MODS']:                missing.append(m)    return missing### CheckMods(env, TST, SERVER, CALL) #def CheckBATs(env, TST, TSTDB) :    missing = []    if env['VERSION'] >= 49900:        # Warn("Monet5: Check, whether required BATs do exist, is not possible, yet!")        return missing    cmd = '%s%s --dbname=%s' % (env['exe']['Mtimeout'][1], env['exe']['Mserver'][1], TSTDB)    pOut,pIn,pErr = popen2.popen3(cmd)    pIn.write('''\        {            # print a list of all persistent BATs            # "BATs: bat1, bat2, ..."            var BATs := view_bbp_name();            printf("\\nBATs: ");            var x := "";            BATs@batloop(){                printf("%s\'%s\'",x,$t);                x:=",";            }            printf("\\n");        }        quit();    ''')    try:        pIn.close()    except IOError, (IOerrNo, IOerrStr):        Warn("Closing input pipe in CheckBATs failed with #%d: '%s'." % (IOerrNo, IOerrStr))    qOut, qErr = ReadMultiple([pOut, pErr])    TST_BATS = []    if qOut:        tb = re.compile("^BATs: (.*)$", re.MULTILINE)        for l in qOut.split('\n'):            b = tb.match(l)            if b:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -