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

📄 tests.py

📁 fortran并行计算包
💻 PY
📖 第 1 页 / 共 3 页
字号:
#!/usr/bin/env python##   (C) 2001 by Argonne National Laboratory.#       See COPYRIGHT in top-level directory.#import os, sys, socket, commands, timesys.path.append("..")         # where to find mpdlib, etc.from mpdlib import MPDTest    # do this AFTER extending sys.pathclusterHosts = []# clusterHosts = ['bp400','bp401','bp402','bp403']MPI_srcdir = "/home/rbutler/mpich2"MPI_1_dir  = "/home/rbutler/mpich1i"USER_INSTALL_DIR = "/tmp/usermpd"ROOT_INSTALL_DIR = "/tmp/rootmpd"os.environ['PATH'] = "..:" + os.environ['PATH']PYEXT = ".py"HFILE = "temph"os.environ['MPD_CON_EXT'] = "testing"testsToRun = [ 0 for x in range(0,10000) ]         # init all to 0; override below# for i in range(0,10000):    testsToRun[i] = 1    # run all testsfor i in range(0,1000):     testsToRun[i] = 1    # run tests for mpd# for i in range(1000,2000):  testsToRun[i] = 1    # run tests for mpiexec# for i in range(2000,3000):  testsToRun[i] = 1    # run MPI tests# for i in range(3000,4000):  testsToRun[i] = 1    # run console pgm tests# for i in range(8000,9000):  testsToRun[i] = 1    # run misc tests# for i in range(9000,10000): testsToRun[i] = 1    # run root tests# testsToRun[3003] = 1                               # run this one testif 1 in testsToRun[0:1000]:    print "mpd tests---------------------------------------------------"if testsToRun[0]:    # test: simple with 1 mpd (mpdboot uses mpd's -e and -d options)    print "TEST -e -d"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.system("mpdboot%s -n %s" % (PYEXT,NMPDS) )    expout = 'hello\nhello\nhello\n'    mpdtest.run(cmd="mpiexec%s -n 3 /bin/echo hello" % (PYEXT), chkOut=1, expOut=expout )    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )if testsToRun[1]:    # test: simple with 2 mpds on same machine (mpdboot uses mpd's -n option)    print "TEST -n"    NMPDS = 2    if NMPDS > len(clusterHosts)+1:        print "    skipping; too few hosts"    else:        mpdtest = MPDTest()        temph = open(HFILE,'w')        for i in range(NMPDS): print >>temph, '%s' % (socket.gethostname())        temph.close()        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.system("mpdboot%s -1 -f %s -n %d" % (PYEXT,HFILE,NMPDS) )        expout = 'hello\nhello\n'        mpdtest.run(cmd="mpiexec%s -n 2 /bin/echo hello" % (PYEXT), chkOut=1, expOut=expout )        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.unlink(HFILE)if testsToRun[2]:    # test: simple with 3 mpds on 3 machines    print "TEST simple hello msg on 3 nodes"    NMPDS = 3    if NMPDS > len(clusterHosts)+1:        print "    skipping; too few hosts"    else:        mpdtest = MPDTest()        temph = open(HFILE,'w')        for host in clusterHosts: print >>temph, host        temph.close()        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.system("mpdboot%s -1 -f %s -n %d" % (PYEXT,HFILE,NMPDS) )        expout = 'hello\nhello\nhello\n'        mpdtest.run(cmd="mpiexec%s -n 3 /bin/echo hello" % (PYEXT), chkOut=1, expOut=expout )        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.unlink(HFILE)if testsToRun[3]:    # test: simple 2 mpds on local machine (-l, -h, and -p option)    print "TEST -l, -h, and -p"    NMPDS = 3    if NMPDS > len(clusterHosts)+1:        print "    skipping; too few hosts"    else:        mpdtest = MPDTest()        temph = open(HFILE,'w')        for host in clusterHosts: print >>temph, host        temph.close()        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.system("mpd%s -d -l 12345" % (PYEXT) )        os.system("mpd%s -d -n -h %s -p 12345" % (PYEXT,socket.gethostname()) )        expout = 'hello\nhello\nhello\n'        mpdtest.run(cmd="mpiexec%s -n 3 /bin/echo hello" % (PYEXT), chkOut=1, expOut=expout )        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.unlink(HFILE)if testsToRun[4]:    # test: simple with 2 mpds on 2 machines  (--ncpus option)    print "TEST --ncpus"    NMPDS = 2    if NMPDS > len(clusterHosts)+1:        print "    skipping; too few hosts"    else:        mpdtest = MPDTest()        temph = open(HFILE,'w')        for host in clusterHosts: print >>temph, "%s:2" % (host)        temph.close()        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.system("mpdboot%s -f %s -n %d --ncpus=2" % (PYEXT,HFILE,NMPDS) )        myHost = socket.gethostname()        expout = '0: %s\n1: %s\n2: %s\n3: %s\n' % (myHost,myHost,clusterHosts[0],clusterHosts[0])        mpdtest.run(cmd="mpiexec%s -l -n 4 /bin/hostname" % (PYEXT), chkOut=1, expOut=expout )        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.unlink(HFILE)if testsToRun[5]:    # test: simple with 2 mpds on 2 machines  (--ifhn option)    #   this is not a great test, but shows working with real ifhn, then failure with 127.0.0.1    print "TEST minimal use of --ifhn"    NMPDS = 2    if NMPDS > len(clusterHosts)+1:        print "    skipping; too few hosts"    else:        mpdtest = MPDTest()        temph = open(HFILE,'w')        for host in clusterHosts:            hostinfo = socket.gethostbyname_ex(host)            IP = hostinfo[2][0]            print >>temph, '%s ifhn=%s' % (host,IP)        temph.close()        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        hostinfo = socket.gethostbyname_ex(socket.gethostname())        IP = hostinfo[2][0]        os.system("mpdboot%s -f %s -n %d --ifhn=%s" % (PYEXT,HFILE,NMPDS,IP) )        expout = 'hello\nhello\n'        mpdtest.run(cmd="mpiexec%s -n 2 /bin/echo hello" % (PYEXT), chkOut=1, expOut=expout )        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        ## redo the above test with a local ifhn that should cause failure        lines = commands.getoutput("mpdboot%s -f %s -n %d --ifhn=127.0.0.1" % (PYEXT,HFILE,NMPDS) )        if len(lines) > 0:            if lines.find('failed to handshake') < 0:                print "probable error in ifhn test using 127.0.0.1; printing lines of output next:"                print lines                sys.exit(-1)        os.unlink(HFILE)if testsToRun[6]:    print "TEST MPD_CON_INET_HOST_PORT"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    import random    port = random.randrange(2000,9000)    print "    using port", port    os.environ['MPD_CON_INET_HOST_PORT'] = "localhost:%d" % (port)    os.system("mpd.py &")    time.sleep(1)  ##     time to get going    expout = ['0: hello']    rv = mpdtest.run(cmd="mpiexec%s -l -n 1 echo hello" % (PYEXT), expOut=expout,grepOut=1)    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.unsetenv('MPD_CON_INET_HOST_PORT')   # get rid of this for later testsif 1 in testsToRun[1000:2000]:    print "mpiexec tests-------------------------------------------"if testsToRun[1000]:    print "TEST -machinefile"    NMPDS = 4    if NMPDS > len(clusterHosts)+1:        print "    skipping; too few hosts"    else:        temph = open(HFILE,'w')        for host in clusterHosts: print >>temph, host        temph.close()        tempm = open('tempm','w')        for host in clusterHosts: print >>tempm, '%s:2 ifhn=%s' % (host,host)        tempm.close()        mpdtest = MPDTest()        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.system("mpdboot%s -1 -f %s -n %d" % (PYEXT,HFILE,NMPDS) )        expout = '0: bp400\n1: bp400\n2: bp401\n3: bp401\n'   # 2 per host because of :2's in tempm        mpdtest.run(cmd="mpiexec%s -l -machinefile %s -n 4 hostname" % (PYEXT,'tempm'), chkOut=1, expOut=expout)        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        os.system("rm -f tempm %s" % (HFILE))if testsToRun[1001]:    print "TEST -file"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.system("mpdboot%s -n %d" % (PYEXT,NMPDS) )    tempfilename = '/tmp/%s_tempin2' % (os.environ['USER'])    f = open(tempfilename,'w')    print >>f, """       <create-process-group totalprocs='3'>          <process-spec	       range='0-2'	       exec='/bin/echo'>            <arg idx='1' value="hello"> </arg>            <arg idx='2' value="again"> </arg>          </process-spec>       </create-process-group>    """    f.close()    expout = 'hello again\nhello again\nhello again\n'    mpdtest.run(cmd="mpiexec%s -file %s" % (PYEXT,tempfilename),chkOut=1,expOut=expout)    os.unlink(tempfilename)    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    if testsToRun[1002]:    print "TEST -configfile"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.system("mpdboot%s -n %d" % (PYEXT,NMPDS) )    tempfilename = '/tmp/%s_tempin2' % (os.environ['USER'])    f = open(tempfilename,'w')    print >>f, "-l\n-n 1 echo hello there\n-n 1 echo hello again"    f.close()    expout = '0: hello there\n1: hello again\n'    mpdtest.run(cmd="mpiexec%s -configfile %s" % (PYEXT,tempfilename),chkOut=1,expOut=expout)    os.unlink(tempfilename)    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    if testsToRun[1003]:    print "TEST -l"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.system("mpdboot%s -n %d" % (PYEXT,NMPDS) )    expout = '0: hello\n1: bye\n'    mpdtest.run(cmd="mpiexec%s -l -n 1 echo hello : -n 1 echo bye" % (PYEXT),chkOut=1,expOut=expout)    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )if testsToRun[1004]:    print "TEST -m"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.system("mpdboot%s -n %d" % (PYEXT,NMPDS) )    expout = '0-1:  hello\n'    mpdtest.run(cmd="mpiexec%s -m -n 2 echo hello" % (PYEXT),chkOut=1,expOut=expout)    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )if testsToRun[1005]:    print "TEST -ecfn"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.system("mpdboot%s -n %d" % (PYEXT,NMPDS) )    expout = 'hello\n'    rv = mpdtest.run(cmd="mpiexec%s -ecfn tempxout -n 1 echo hello" % (PYEXT),chkOut=1,expOut=expout)    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    linesAsStr = commands.getoutput("cat tempxout")    os.unlink("tempxout")    if linesAsStr.find('exit-codes') < 0:        print "ecfn: Failed to create correct contents of xml file:"        print linesAsStr        sys.exit(-1)if testsToRun[1006]:    print "TEST -s"    NMPDS = 1    mpdtest = MPDTest()    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )    os.system("mpdboot%s -n 1" % (PYEXT) )    expin = 'hello\n'    expout = '0: hello\n'    rv = mpdtest.run(cmd="mpiexec%s -l -n 4 cat -" % (PYEXT),                     expOut=expout,chkOut=1,expIn=expin)    expout = '0: hello\n1: hello\n2: hello\n3: hello\n'    rv = mpdtest.run(cmd="mpiexec%s -l -s 0-3 -n 4 cat -" % (PYEXT),                     expOut=expout,chkOut=1,expIn=expin)    expout = '0: hello\n1: hello\n2: hello\n3: hello\n'    rv = mpdtest.run(cmd="mpiexec%s -l -s all -n 4 cat -" % (PYEXT),                     expOut=expout,chkOut=1,expIn=expin)    expout = '0: hello\n2: hello\n3: hello\n'    rv = mpdtest.run(cmd="mpiexec%s -l -s 0,2-3 -n 4 cat -" % (PYEXT),                     expOut=expout,chkOut=1,expIn=expin)    os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )if testsToRun[1007]:    print "TEST -1"    NMPDS = 2    if NMPDS > len(clusterHosts)+1:        print "    skipping; too few hosts"    else:        mpdtest = MPDTest()        os.system("mpdallexit%s 1> /dev/null 2> /dev/null" % (PYEXT) )        temph = open(HFILE,'w')        for host in clusterHosts: print >>temph, host        temph.close()

⌨️ 快捷键说明

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