def focusTests(pf): print "Focus Tests" try: # try getting a focus template ri = ResourceIndex() build = Resource("mybuild","build") env = Resource("myenv", "environment") lib = Resource(env.name+"|libmpi.so","environment|module") ri.addResource(lib) lib = Resource(env.name+"|libelf.so","environment|module") ri.addResource(lib) compiler = Resource("theCompiler","compiler") execution = Execution("myexec") process0 = Resource(execution.name+"|Process-0","execution|process") ri.addResources([compiler,build,env]) metric = Resource("MFLOPS","metric") pt = Resource("Paradyn","performanceTool") ri.addResources([build,env,process0,metric,pt]) fl = ri.createContextTemplate() except: pf.failed("non-PTexception raised when getting focusTemplate") raise else: if len(fl) != 4: pf.failed("wrong number of resources. %d" % len(fl)) else: pf.passed("got focus template successfully") try: # try getting a focus template with two top-level resources withthe # same type ri =ResourceIndex() build = Resource("mybuild","build") env = Resource("myenv", "environment") lib = Resource(env.name+"|libmpi.so","environment|module") ri.addResource(lib) lib = Resource(env.name+"|libelf.so","environment|module") ri.addResource(lib) compiler = Resource("theCompiler","compiler") execution = Execution("myexec") process0 = Resource(execution.name+"|Process-0","execution|process") ri.addResources([compiler,build,env]) compiler = Resource("theOtherCompiler","compiler") process1 = Resource(execution.name+"|Process-1","execution|process") ri.addResources([compiler,build,env]) ri.addResources([build,env,process0,process1]) fl = ri.createContextTemplate() except: pf.failed("non-PTexception raised when getting focusTemplate same types") raise else: if len(fl) != 6: pf.failed("wrong number of resources same types. %d" % len(fl)) else: pf.passed("got focus template successfully same types") try: # try adding a specific focus resources that is a child of a resource # in the template ri = ResourceIndex() build = Resource("mybuild","build") env = Resource("myenv", "environment") lib = Resource(env.name+"|libmpi.so","environment|module") ri.addResource(lib) lib = Resource(env.name+"|libelf.so","environment|module") ri.addResource(lib) compiler = Resource("theCompiler","compiler") execution = Execution("myexec") process0 = Resource(execution.name+"|Process-0","execution|process") ri.addResources([compiler,build,env]) ri.addResources([build,env,process0]) fl = ri.createContextTemplate() newfl = ri.addSpecificContextResource(fl,process0) except: pf.failed("non-PTexception raised when adding specific focus child") raise else: if len(newfl) != 4: pf.failed("wrong number of resources when adding specific focus child. %d" % len(newfl)) else: pf.passed("got focus template successfully when adding specific focus child") try: # try adding a list of specific focus resources that is a child of # a resource in the template ri = ResourceIndex() build = Resource("mybuild","build") env = Resource("myenv", "environment") lib = Resource(env.name+"|libmpi.so","environment|module") ri.addResource(lib) lib = Resource(env.name+"|libelf.so","environment|module") ri.addResource(lib) compiler = Resource("theCompiler","compiler") execution = Execution("myexec") process0 = Resource(execution.name+"|Process-0","execution|process") ri.addResources([compiler,build,env]) process1 = Resource(execution.name+"|Process-1","execution|process") ri.addResources([compiler,build,env]) ri.addResources([build,env,process0,process1]) fl = ri.createContextTemplate() newfl = ri.addSpecificContextResources(fl,[process0,process1]) except: pf.failed("non-PTexception raised when adding specific focus child list") raise else: if len(newfl) != 5: pf.failed("wrong number of resources when adding specific focus child list. %d" % len(newfl)) else: pf.passed("got focus template successfully when adding specific focus child list")
def focusTests(pf): print "Focus Tests" try: # try getting a focus template ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) metric = Resource("MFLOPS", "metric") pt = Resource("Paradyn", "performanceTool") ri.addResources([build, env, process0, metric, pt]) fl = ri.createContextTemplate() except: pf.failed("non-PTexception raised when getting focusTemplate") raise else: if len(fl) != 4: pf.failed("wrong number of resources. %d" % len(fl)) else: pf.passed("got focus template successfully") try: # try getting a focus template with two top-level resources withthe # same type ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) compiler = Resource("theOtherCompiler", "compiler") process1 = Resource(execution.name + "|Process-1", "execution|process") ri.addResources([compiler, build, env]) ri.addResources([build, env, process0, process1]) fl = ri.createContextTemplate() except: pf.failed( "non-PTexception raised when getting focusTemplate same types") raise else: if len(fl) != 6: pf.failed("wrong number of resources same types. %d" % len(fl)) else: pf.passed("got focus template successfully same types") try: # try adding a specific focus resources that is a child of a resource # in the template ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) ri.addResources([build, env, process0]) fl = ri.createContextTemplate() newfl = ri.addSpecificContextResource(fl, process0) except: pf.failed("non-PTexception raised when adding specific focus child") raise else: if len(newfl) != 4: pf.failed( "wrong number of resources when adding specific focus child. %d" % len(newfl)) else: pf.passed( "got focus template successfully when adding specific focus child" ) try: # try adding a list of specific focus resources that is a child of # a resource in the template ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) process1 = Resource(execution.name + "|Process-1", "execution|process") ri.addResources([compiler, build, env]) ri.addResources([build, env, process0, process1]) fl = ri.createContextTemplate() newfl = ri.addSpecificContextResources(fl, [process0, process1]) except: pf.failed( "non-PTexception raised when adding specific focus child list") raise else: if len(newfl) != 5: pf.failed( "wrong number of resources when adding specific focus child list. %d" % len(newfl)) else: pf.passed( "got focus template successfully when adding specific focus child list" )
pf.failed("non-PTexception when try isChild actual child") else: if theVerdict == True: pf.passed("isChild pass actual child") else: pf.failed("isChild fail actual child") try: # try finding a static library ri = ResourceIndex() build = Resource("mybuild","build") lib = Resource(build.name+"|libmpi.a","build|module") ri.addResource(lib) env = Resource("myenv", "environment") execution = Execution("myexec") ri.addResources([build,env]) resList = ri.findResourcesByShortType("module") libname = "" for r in resList: if r.name.find("libmpi") >= 0: libname = r.name break except PTexception, a: pf.failed("PTexception raised when trying to find good static lib with findResourceByShortType: " + a.value) except: pf.failed("non-PTexception raised when trying to find good static lib with findResourceByShortType") raise else: if libname == "": pf.failed("found empty library name when trying to find good static lib with findResourceByShortType") elif not libname.endswith("|libmpi.a"):
pf.failed("non-PTexception when try isChild actual child") else: if theVerdict == True: pf.passed("isChild pass actual child") else: pf.failed("isChild fail actual child") try: # try finding a static library ri = ResourceIndex() build = Resource("mybuild", "build") lib = Resource(build.name + "|libmpi.a", "build|module") ri.addResource(lib) env = Resource("myenv", "environment") execution = Execution("myexec") ri.addResources([build, env]) resList = ri.findResourcesByShortType("module") libname = "" for r in resList: if r.name.find("libmpi") >= 0: libname = r.name break except PTexception, a: pf.failed( "PTexception raised when trying to find good static lib with findResourceByShortType: " + a.value) except: pf.failed( "non-PTexception raised when trying to find good static lib with findResourceByShortType" ) raise