Exemplo n.º 1
0
def AssembleTestSuites():
    ''' Populates the test suites to run.

    Populates the test suites to run. At least, it should populate the suites:
    "small", "nighlty" and "all"

    Return
    ------

    suites: A dictionary of suites
        The set of suites with its test_cases added.
    '''

    suites = KratosUnittest.KratosSuites

    # Create a test suit with the selected tests
    smallSuite = suites['small']
    smallSuite.addTest(TestTools('test_normalInverseCDF'))
    smallSuite.addTest(TestTools('test_returnInput'))
    smallSuite.addTest(TestMomentEstimator('test_update'))
    smallSuite.addTest(TestMomentEstimator('test_value'))
    smallSuite.addTest(TestCombinedMomentEstimator('test_update'))
    smallSuite.addTest(TestCombinedMomentEstimator('test_value'))
    smallSuite.addTest(
        TestMultiMomentEstimator('test_estimation_deterministic'))
    smallSuite.addTest(TestMultiMomentEstimator('test_update'))
    smallSuite.addTest(
        TestMultiMomentEstimator('test_construction_isParallel'))
    smallSuite.addTest(TestMultiCombinedMomentEstimator('test_updateD0'))
    smallSuite.addTest(TestMultiCombinedMomentEstimator('test_estimationD0'))
    smallSuite.addTest(TestXMCAlgorithm('test_mc_Kratos'))

    # Create a test suit with the selected tests plus all small tests
    nightSuite = suites['nightly']
    nightSuite.addTests(smallSuite)
    nightSuite.addTest(TestMultiMomentEstimator('test_estimation_random'))
    nightSuite.addTest(
        KratosMultilevelMonteCarloGeneralTests('testMonteCarlo'))
    if (hasattr(MeshingApplication, "MmgProcess2D")):
        nightSuite.addTest(
            KratosMultilevelMonteCarloGeneralTests('testMultilevelMonteCarlo'))
        nightSuite.addTest(TestXMCAlgorithm('test_mlmc_Kratos'))
    else:
        print(
            "MMG process is not compiled and the corresponding tests will not be executed"
        )

    # Create a test suit that contains all the tests
    allSuite = suites['all']
    allSuite.addTests(nightSuite)

    return suites
Exemplo n.º 2
0
 def __init__(self, simu, testNo, ch_number) :
     threading.Thread.__init__(self)
     self.__simu = simu
     self.__testNo = int(float(testNo))
     self.__saveTestNo = self.__testNo
     self.__ch_number = ch_number
     now = datetime.datetime.now()
     report_name = str("CH" + str(int(float(self.__ch_number))) + "_" + self.__testName[self.__testNo]) + "_" + str( now.strftime("%Y_%m_%d_%H_%M") )
     report_full_path = os.path.abspath(os.path.join(config.options().output_current_dir, report_name) )
     self.__testTools = TestTools(self, self.__simu, self.__testNo, self.__ch_number, report_full_path)
     self.__testTools.writeReport(" ", now, self.__testName[self.__testNo])
Exemplo n.º 3
0
class OcpTest( threading.Thread ) :
    RUNNING   = -1
    OK        = 0
    ERROR_IINB_DIFF_IINP 		= 1   #0
    ERROR_IOUTB_DIFF_IINB               = 2   #1
    ERROR_IOUTM_DIFF_IOUTB              = 4   #2
    ERROR_PROT_SET                      = 16  #3
    ERROR_IOUTB_POSITIVE		= 32  #4
    ERROR_IOUTB_DIFF_IINB_NO_TRIGGER  	= 32  #4bis
    ERROR_IINB_EARLY    		= 64  #5
    ERROR_PROT_NSET                     = 128 #6
    ERROR_PROT_SET_NO_TRIGGER           = 128 #6bis 
    
    
    __testTools = None
    __testNo = 0
    __saveTestNo = 0
    __simu = None
    __ch_number = 0
    __result_data = None
    __testName = ["OCP_complete_autotest", "OCP_+-0.1A_threshold_test", 
                    "OCP_+-0.01A_threshold_test", "OCP_+-0.001A_threshold_test",
                    "OCP_+-0.4A_threshold_test", "OCP_+-0.04A_threshold_test",
                    "OCP_delay_test_without_trigger", "OCP_delay_test_with_trigger"]
    __ocpParam = []
    __paramCount = 0

    def __init__(self, simu, testNo, ch_number) :
        threading.Thread.__init__(self)
        self.__simu = simu
        self.__testNo = int(float(testNo))
        self.__saveTestNo = self.__testNo
        self.__ch_number = ch_number
        now = datetime.datetime.now()
        report_name = str("CH" + str(int(float(self.__ch_number))) + "_" + self.__testName[self.__testNo]) + "_" + str( now.strftime("%Y_%m_%d_%H_%M") )
        report_full_path = os.path.abspath(os.path.join(config.options().output_current_dir, report_name) )
        self.__testTools = TestTools(self, self.__simu, self.__testNo, self.__ch_number, report_full_path)
        self.__testTools.writeReport(" ", now, self.__testName[self.__testNo])

        
        
    def run(self):
        # go to normal state
        self.__simu.CallAlgo('IF_HLP.algo.Normal_State')
        
        print self.__testName[self.__testNo] + " started"
        self.__result_data = dict()
        
        try:    
            self.__ocpParam = map(float, self.__testTools.readConfFile("OCP"))
            
            if (self.__testNo==0):
                self.__paramCount = -1
                for i in range(0, 7):
                    self.__testNo = i+1
                    self.__testTools.writeReport("######## Starting: " + self.__testName[self.__testNo] + " ########")
                    print "######## Starting: " + self.__testName[self.__testNo] + " ########"
                    
                    if(i<5):
                        self.__threshold(self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()])
                    else:
                        self.__delay((0 if(i==5) else 1), self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()])
                    errors = 0
                    for self.__testNo in self.__result_data.keys():
                        if (self.__result_data[self.__testNo] != self.OK):
                            errors+= 1
                    self.__testTools.writeReport("\n"+self.__testName[self.__testNo]+" ended: GLOBAL" + (" OK\n" if(errors==0) else " NOK\n" ))
                    
                self.__testNo = 0
                
            elif (self.__testNo>0 and self.__testNo<6):
                
                self.__paramCount = 7*int(self.__testNo) -7
                
                self.__threshold(self.__ocpParam[self.__paramCount], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()])
                
            elif (self.__testNo>5  and self.__testNo<8):
                # 35 et 45
                self.__paramCount = self.__testNo*5 + 5 + 5*(self.__testNo-6)
                
                self.__delay(0 if(self.__testNo==6) else 1, self.__ocpParam[self.__paramCount], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()], self.__ocpParam[self.inc()])
            
            else:
                raise ValueError(str(self.__testNo) + " is not a correct test number!")
            
            # parse result data and interpret it
            if (self.__simu.getAutotestResult() == self.RUNNING):
                errors = 0
                for self.__testNo in self.__result_data.keys():
                    if (self.__result_data[self.__testNo] != self.OK):
                        errors+= 1
                self.__simu.setAutotestResult(errors)
            self.__testNo = self.__saveTestNo
            self.__testTools.writeReport("\n"+self.__testName[self.__testNo]+" ended: GLOBAL" + (" OK" if(errors==0) else " NOK" ))
            self.__testTools.printAutotestResult()
        except Exception, e:
            # otherwise if we stop ATOOM, RemoteSimulatorThread tries to join() a thread that is already stopped
            self.__simu.setAutotestResult(-2)
            print "\nAutotest interrupted -- reason : " + str(e)
        finally:
Exemplo n.º 4
0
def run_testcases(testcases, timer=None):
	"""
	run list of testcases
	:param testcases: list of testcases
	:param timer: a timer, if included will take interval between every test
	"""
	for testcase in testcases:
		testcase.run_test(True)
		if timer != None:
			timer.interval()
		print "  "


# included testcases in this test
testcases = [
	TestPlayer(),
	TestTools(),
	TestBuffer()]


timer = Timer()
print "________ start test all testcases"
import tools

timer.start()
run_testcases(testcases)
timer.stop()
print "________ finished test all testcases"

print "total duration: " + Timer.secondsToStr(timer.get_startstop_diff())