buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_parsers.py
changeset 628 7c4a911dc066
parent 588 c7c26511138f
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
   146             r"""
   146             r"""
   147 TARGET          dependent_1.dll
   147 TARGET          dependent_1.dll
   148 TARGETTYPE      PLUGIN
   148 TARGETTYPE      PLUGIN
   149             """)
   149             """)
   150     tc1_dep1_mmp.close()
   150     tc1_dep1_mmp.close()
       
   151     
       
   152     tc1_dep2_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "dependent_1", "group", "onemore.mmp"), 'w')
       
   153     tc1_dep2_mmp.write(
       
   154             r"""
       
   155 TARGET          onemore.dll
       
   156 TARGETTYPE      PLUGIN
       
   157             """)
       
   158     tc1_dep2_mmp.close()
   151         
   159         
   152     tc1_dep2 = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "dependent_2", "group", "bld.inf"), "w")
   160     tc1_dep2 = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "dependent_2", "group", "bld.inf"), "w")
   153     tc1_dep2.write(
   161     tc1_dep2.write(
   154             r"""
   162             r"""
   155 PRJ_TESTMMPFILES
   163 PRJ_TESTMMPFILES
   405         self.bld_path = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "group"))
   413         self.bld_path = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "group"))
   406         self.bld_path_comp1 = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "tc1", "group"))
   414         self.bld_path_comp1 = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "tc1", "group"))
   407         self.tcp = ats3.parsers.CppParser()
   415         self.tcp = ats3.parsers.CppParser()
   408         upper_bld_path = os.path.dirname(self.bld_path)
   416         upper_bld_path = os.path.dirname(self.bld_path)
   409         
   417         
   410         self.dependent_paths_dictionary = {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/if_test/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/if_test/group"))): {'pkg_files': [], 'mmp_files': ['if_test.mmp'], 'harness': 'STIFUNIT', 'type': ''}}},
   418         self.dependent_paths_dictionary = {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/if_test/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/if_test/group"))): {'pkg_files': [], 'mmp_files': ['if_test.mmp'], 'dll_files': {'tc1_if.dll': 'STIFUNIT'}, 'harness': 'STIFUNIT', 'type': ''}}},
   411                                             (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2//group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2/group"))): {'pkg_files': ['tc2.pkg'], 'mmp_files': ['tc2.mmp'], 'harness': 'EUNIT', 'type': 'executable'}}}, 
   419                                             (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2//group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2/group"))): {'pkg_files': ['tc2.pkg'], 'mmp_files': ['tc2.mmp'], 'dll_files': {'tc2.dll': 'EUNIT'}, 'harness': 'EUNIT', 'type': 'executable'}}}, 
   412                                             (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group"))): {'pkg_files':[], 'mmp_files': ['tc3.mmp'], 'harness': 'EUNIT', 'type': 'executable'}}},
   420                                             (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group"))): {'pkg_files':[], 'mmp_files': ['tc3.mmp'], 'dll_files': {'tc3.dll': 'EUNIT'},  'harness': 'EUNIT', 'type': 'executable'}}},
   413                                             (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/group"))): {'pkg_files': [], 'mmp_files': ['sub_test.mmp'], 'harness': 'STIF', 'type': 'executable'}, 
   421                                             (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/group"))): {'pkg_files': [], 'mmp_files': ['sub_test.mmp'], 'dll_files': {'sub_test.dll': 'STIF'}, 'harness': 'STIF', 'type': 'executable'}, 
   414                                                                                                                                 (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/dependent_1/group"))): {'pkg_files': [], 'mmp_files': ['dependent_1.mmp', 'onemore.mmp'], 'harness': "", 'type':''}, 
   422                                                                                                                                 (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/dependent_1/group"))): {'pkg_files': [], 'mmp_files': ['dependent_1.mmp', 'onemore.mmp'],'dll_files': {'dependent_1.dll': '', 'onemore.dll': ''}, 'harness': "", 'type':'dependent'}, 
   415                                                                                                                                 (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/dependent_2/group"))): {'pkg_files': [], 'mmp_files': ['dependent_2.mmp'], 'harness': "", 'type': 'dependent'}, 
   423                                                                                                                                 (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/dependent_2/group"))): {'pkg_files': [], 'mmp_files': ['dependent_2.mmp'], 'dll_files': {'dependent_2.dll': ''}, 'harness': "", 'type': 'dependent'}, 
   416                                                                                                                                 (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group"))): {'pkg_files': ['tc1.pkg'], 'mmp_files': ['tc1.mmp'],'harness': 'STIF', 'type': 'executable'}}}} 
   424                                                                                                                                 (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group"))): {'pkg_files': ['tc1.pkg'], 'mmp_files': ['tc1.mmp'], 'dll_files': {'tc1.dll': 'STIF'}, 'harness': 'STIF', 'type': 'executable'}}}} 
   417         
   425         
   418         self.extended_path_list = [(os.path.normpath(upper_bld_path), upper_bld_path),
   426         self.extended_path_list = [(os.path.normpath(upper_bld_path), upper_bld_path),
   419                            (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group")), upper_bld_path),
   427                            (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group")), upper_bld_path),
   420                            (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_1/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group"))),
   428                            (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_1/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group"))),
   421                            (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_2/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group"))),
   429                            (os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_2/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group"))),
   547 class TestBldFileParser(mocker.MockerTestCase):
   555 class TestBldFileParser(mocker.MockerTestCase):
   548     """Testing BldFileParser Class"""
   556     """Testing BldFileParser Class"""
   549     
   557     
   550     def __init__(self, methodName="runTest"):
   558     def __init__(self, methodName="runTest"):
   551         mocker.MockerTestCase.__init__(self, methodName)
   559         mocker.MockerTestCase.__init__(self, methodName)
       
   560         self.mmp_file_path = None
       
   561         self.lst_test_mmp = []
   552     
   562     
   553     def setUp(self):
   563     def setUp(self):
   554         """Setup for BldFile parser"""
   564         """Setup for BldFile parser"""
   555 
   565 
   556         self.bld_path = path.joinpath(TSRC_DIR, "tsrc", "group", "bld.inf").normpath()
   566         self.bld_path = path.joinpath(TSRC_DIR, "tsrc", "group", "bld.inf").normpath()
   665     
   675     
   666     def test_get_harness(self):
   676     def test_get_harness(self):
   667         """Test if get_harness returns right harness for given mmp"""
   677         """Test if get_harness returns right harness for given mmp"""
   668         assert self.tc1_harness == self.tcp.get_harness(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')))
   678         assert self.tc1_harness == self.tcp.get_harness(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')))
   669     
   679     
       
   680     def test_get_mmp_harness(self):
       
   681         """ 
       
   682         Testing required combinations of libraries with get_mmp_harness method and asserting the harness.
       
   683         """
       
   684         assert self.tcp.get_mmp_harness(None) == ""
       
   685         assert self.tcp.get_mmp_harness(["foo"]) == ""  # value, but unexpected
       
   686         #single values
       
   687         assert self.tcp.get_mmp_harness(["stiftestinterface.lib"]) == "STIF"
       
   688         assert self.tcp.get_mmp_harness(["eunit.lib"]) == "EUNIT"
       
   689         assert self.tcp.get_mmp_harness(["qttest.lib"]) == "EUNIT"        
       
   690         assert self.tcp.get_mmp_harness(["testexecuteutils.lib"]) == "GENERIC"
       
   691         assert self.tcp.get_mmp_harness(["testframeworkclient.lib"]) == "GENERIC"
       
   692         assert self.tcp.get_mmp_harness(["rtest"]) == "GENERIC"        
       
   693         #tef gets priority even if other libraries exist 
       
   694         #takeout only STIFUNIT.lib then TEF
       
   695         assert self.tcp.get_mmp_harness(["stiftestinterface.lib", "eunit.lib", "qttest.lib", "testexecuteutils.lib" , "testframeworkclient.lib", "rtest"]) == "GENERIC"
       
   696         #condition stif and eunit, then harness STIF
       
   697         assert self.tcp.get_mmp_harness(["stiftestinterface.lib", "eunit.lib"]) == "STIF"
       
   698         #condition stif and not eunit, then harness STIF
       
   699         assert self.tcp.get_mmp_harness(["stiftestinterface.lib", "stifunit.lib"]) == "STIF"
       
   700         #condition eunit and not stif , then harness EUNIT
       
   701         assert self.tcp.get_mmp_harness(["eunit.lib", "qttest.lib", "stifunit.lib"]) == "EUNIT"
       
   702         #condition stifunit and not eunit and not stif
       
   703         assert self.tcp.get_mmp_harness(["stifunit.lib"]) == "STIFUNIT"
       
   704         
       
   705                                
       
   706     def test_select_harness(self):
       
   707         """Test if select_harness returns right harness for given set of Test Framework 
       
   708         tef,stif,eunit and stifunit
       
   709         tef   stif  eunit stifunit = result
       
   710         ===================================
       
   711         False,False,False,False    == ""
       
   712 
       
   713         True, False,False,False    == "GENERIC"
       
   714         True, True, False,False    == "GENERIC"
       
   715         True, False,True, False    == "GENERIC"
       
   716         True, False,False,True     == "GENERIC"
       
   717         True, False,True, True     == "GENERIC"
       
   718         True, True, True, False    == "GENERIC"
       
   719         True, True, False,True     == "GENERIC"
       
   720         True, True, True, True     == "GENERIC"
       
   721 
       
   722         False,True, False,False    == "STIF"
       
   723         False,True, True, False    == "STIF"
       
   724         False,True, False,True     == "STIF"
       
   725         False,True, True, True     == "STIF"
       
   726 
       
   727         False,False, True, False    == "EUNIT"
       
   728         False,False, True, True     == "EUNIT"
       
   729 
       
   730         False,false, False, True     == "STIFUNIT"
       
   731 
       
   732         """
       
   733 
       
   734         assert self.tcp.select_harness(False, False, False, False )   == ""
       
   735 
       
   736         assert self.tcp.select_harness(True, False, False, False )   == "GENERIC"
       
   737         assert self.tcp.select_harness(True, True, False, False )   == "GENERIC"
       
   738         assert self.tcp.select_harness(True, False, True, False )   == "GENERIC"
       
   739         assert self.tcp.select_harness(True, False, False, True  )   == "GENERIC"
       
   740         assert self.tcp.select_harness(True, False, True, True  )   == "GENERIC"
       
   741         assert self.tcp.select_harness(True, True, True, False )   == "GENERIC"
       
   742         assert self.tcp.select_harness(True, True, False, True  )   == "GENERIC"
       
   743         assert self.tcp.select_harness(True, True, True, True  )   == "GENERIC"
       
   744  
       
   745         assert self.tcp.select_harness(False, True, False, False )   == "STIF"
       
   746         assert self.tcp.select_harness(False, True, True, False )   == "STIF"
       
   747         assert self.tcp.select_harness(False, True, False, True  )   == "STIF"
       
   748         assert self.tcp.select_harness(False, True, True, True  )   == "STIF"
       
   749 
       
   750         assert self.tcp.select_harness(False, False, True, False)    == "EUNIT"
       
   751         assert self.tcp.select_harness(False, False, True, True )    == "EUNIT"
       
   752 
       
   753         assert self.tcp.select_harness(False, False, False, True)     == "STIFUNIT"
       
   754         
       
   755                                     
       
   756                                     
   670     def test_read_information_method(self):
   757     def test_read_information_method(self):
   671         """Test if read_information_from_mmp returns wanted output for given parameter and mmp-file"""
   758         """Test if read_information_from_mmp returns wanted output for given parameter and mmp-file"""
   672         assert self.tc1_all == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 0)
   759         assert self.tc1_all == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 0)
   673         assert self.tc1_no_harness == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 1)
   760         assert self.tc1_no_harness == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 1)
   674         assert self.tc1_name_type == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 2)
   761         assert self.tc1_name_type == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 2)