buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_ats3.py
changeset 628 7c4a911dc066
parent 588 c7c26511138f
child 645 b8d81fa19e7d
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
    18 #
    18 #
    19 #Description:
    19 #Description:
    20 #===============================================================================
    20 #===============================================================================
    21 
    21 
    22 """ Testing ATS3 framework. """
    22 """ Testing ATS3 framework. """
    23 # pylint: disable-msg=E1101,C0302,w0142,w0603,R0912,R0902,R0903,R0201,W0404, R0915
    23 # pylint: disable=E1101,C0302,w0142,w0603,R0912,R0902,R0903,R0201,W0404, R0915
    24 #w0142 => * and ** were used
    24 #w0142 => * and ** were used
    25 #w0603 => global variables used TSRC_PATH etc
    25 #w0603 => global variables used TSRC_PATH etc
    26 #R*    => will be fixed while refactoring
    26 #R*    => will be fixed while refactoring
    27 #E1101 => Mocker shows mockery
    27 #E1101 => Mocker shows mockery
    28 #R0915 => too many statements
    28 #R0915 => too many statements
    38 import os
    38 import os
    39 import re
    39 import re
    40 import subprocess
    40 import subprocess
    41 import fileutils
    41 import fileutils
    42 
    42 
    43 from path import path # pylint: disable-msg=F0401
    43 from path import path # pylint: disable=F0401
    44 import amara
    44 import amara
    45 import mocker # pylint: disable-msg=F0401
    45 import mocker # pylint: disable=F0401
    46 
    46 
    47 import ats3
    47 import ats3
    48 import ats3.testconfigurator as atc
    48 import ats3.testconfigurator as atc
    49 import ats3.dropgenerator as adg
    49 import ats3.dropgenerator as adg
    50 import ats3.parsers as parser
    50 import ats3.parsers as parser
   558                                        src_dst=[],
   558                                        src_dst=[],
   559                                        pmd_files=self.pmd_files,
   559                                        pmd_files=self.pmd_files,
   560                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set0", "tracelog.blx"),
   560                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set0", "tracelog.blx"),
   561                                        trace_activation_files=self.trace_activation_files,
   561                                        trace_activation_files=self.trace_activation_files,
   562                                        ctc_enabled=self.atp["ctc_enabled"],
   562                                        ctc_enabled=self.atp["ctc_enabled"],
   563                                        custom_dir=None,
   563                                        custom_dir=None, 
       
   564                                        dll_files={},
   564                                        component_path=self.component_path)
   565                                        component_path=self.component_path)
   565         assert self.atp.sets[1] == dict(name="set1",
   566         assert self.atp.sets[1] == dict(name="set1",
   566                                        image_files=self.image_files,
   567                                        image_files=self.image_files,
   567                                        engine_ini_file=self.engine_ini_file,
   568                                        engine_ini_file=self.engine_ini_file,
   568                                        sis_files=self.sis_files,
   569                                        sis_files=self.sis_files,
   572                                        pmd_files=self.pmd_files,
   573                                        pmd_files=self.pmd_files,
   573                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set1", "tracelog.blx"),
   574                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set1", "tracelog.blx"),
   574                                        trace_activation_files=self.trace_activation_files,
   575                                        trace_activation_files=self.trace_activation_files,
   575                                        ctc_enabled=self.atp["ctc_enabled"],
   576                                        ctc_enabled=self.atp["ctc_enabled"],
   576                                        custom_dir=None,
   577                                        custom_dir=None,
       
   578                                        dll_files={},                                        
   577                                        component_path=self.component_path)
   579                                        component_path=self.component_path)
   578 
   580 
   579         assert self.atp.sets[2] == dict(name="set2",
   581         assert self.atp.sets[2] == dict(name="set2",
   580                                        data_files=self.data_files,
   582                                        data_files=self.data_files,
   581                                        config_files=self.config_files,
   583                                        config_files=self.config_files,
   589                                        pmd_files=self.pmd_files,
   591                                        pmd_files=self.pmd_files,
   590                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set2", "tracelog.blx"),
   592                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set2", "tracelog.blx"),
   591                                        trace_activation_files=self.trace_activation_files,
   593                                        trace_activation_files=self.trace_activation_files,
   592                                        ctc_enabled=self.atp["ctc_enabled"],
   594                                        ctc_enabled=self.atp["ctc_enabled"],
   593                                        custom_dir=None,
   595                                        custom_dir=None,
       
   596                                        dll_files={}, 
   594                                        component_path=self.component_path)
   597                                        component_path=self.component_path)
   595         assert self.atp.sets[3] == dict(name="set3",
   598         assert self.atp.sets[3] == dict(name="set3",
   596                                        data_files=[],
   599                                        data_files=[],
   597                                        config_files=[],
   600                                        config_files=[],
   598                                        engine_ini_file=self.engine_ini_file,
   601                                        engine_ini_file=self.engine_ini_file,
   605                                        pmd_files=self.pmd_files,
   608                                        pmd_files=self.pmd_files,
   606                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set3", "tracelog.blx"),
   609                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set3", "tracelog.blx"),
   607                                        trace_activation_files=self.trace_activation_files,
   610                                        trace_activation_files=self.trace_activation_files,
   608                                        ctc_enabled=self.atp["ctc_enabled"],
   611                                        ctc_enabled=self.atp["ctc_enabled"],
   609                                        custom_dir=None,
   612                                        custom_dir=None,
       
   613                                        dll_files={},                                        
   610                                        component_path=self.component_path)
   614                                        component_path=self.component_path)
   611 
   615 
   612         assert self.atp.sets[4] == dict(name="set4",
   616         assert self.atp.sets[4] == dict(name="set4",
   613                                        data_files=[],
   617                                        data_files=[],
   614                                        config_files=[],
   618                                        config_files=[],
   622                                        pmd_files=self.pmd_files,
   626                                        pmd_files=self.pmd_files,
   623                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set4", "tracelog.blx"),
   627                                        trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set4", "tracelog.blx"),
   624                                        trace_activation_files=self.trace_activation_files,
   628                                        trace_activation_files=self.trace_activation_files,
   625                                        ctc_enabled=self.atp["ctc_enabled"],
   629                                        ctc_enabled=self.atp["ctc_enabled"],
   626                                        custom_dir=None,
   630                                        custom_dir=None,
       
   631                                        dll_files={},                                        
   627                                        component_path=self.component_path)
   632                                        component_path=self.component_path)
   628         
   633         
   629     def test_post_actions_email(self):
   634     def test_post_actions_email(self):
   630         """ Testing the send email post-action. """        
   635         """ Testing the send email post-action. """        
   631         assert not self.atp.post_actions
   636         assert not self.atp.post_actions
  1153         self.src_dst0 = []
  1158         self.src_dst0 = []
  1154         self.custom_dir = None
  1159         self.custom_dir = None
  1155         self.component_path = None
  1160         self.component_path = None
  1156         self.custom_files = None
  1161         self.custom_files = None
  1157         self.ctc_run_process_params = None
  1162         self.ctc_run_process_params = None
       
  1163         self.dll_files = {}
  1158         
  1164         
  1159     def generate_xml(self, harness, trace_enabled="False"):
  1165     def generate_xml(self, harness, trace_enabled="False"):
  1160         """Generates XML"""
  1166         """Generates XML"""
  1161         def files(*paths):
  1167         def files(*paths):
  1162             """generates paths for the files"""
  1168             """generates paths for the files"""
  1163             return [TEST_PATH.joinpath("tsrc", tpath) for tpath in paths]
  1169             return [TEST_PATH.joinpath("tsrc", tpath) for tpath in paths]
  1164         self.src_dst1 = []
  1170         self.src_dst1 = []
  1165         self.data_files = files("data/file1", "data/file2", "data/file3")
  1171         self.data_files = files("data/file1", "data/file2", "data/file3")
  1166         self.config_files = files("conf/file1.cfg", "conf/file2.cfg")
  1172         self.config_files = files("conf/file1.cfg", "conf/file2.cfg")
  1167         self.testmodule_files = files("testmodules/file1.dll", "testmodules/file2.dll")
  1173         self.testmodule_files = files("testmodules/file1.dll", "testmodules/file2.dll")
       
  1174         self.dll_files["file1.dll"] = "EUNIT"
       
  1175         self.dll_files["file2.dll"] = ""
  1168         self.image_files = files("output/images/file1.fpsx", "output/images/file2.fpsx")
  1176         self.image_files = files("output/images/file1.fpsx", "output/images/file2.fpsx")
  1169         self.engine_ini_file = files("init/TestFramework.ini")[0]
  1177         self.engine_ini_file = files("init/TestFramework.ini")[0]
  1170         self.report_email = "test.receiver@company.com"
  1178         self.report_email = "test.receiver@company.com"
  1171         self.file_store = path("path/to/reports")
  1179         self.file_store = path("path/to/reports")
  1172         self.diamonds_build_url = "http://diamonds.nmp.company.com/diamonds/builds/1234"
  1180         self.diamonds_build_url = "http://diamonds.nmp.company.com/diamonds/builds/1234"
  1236             mocker.expect(test_plan.sets).result([
  1244             mocker.expect(test_plan.sets).result([
  1237                 dict(name="set0", image_files=self.image_files, data_files=self.data_files,
  1245                 dict(name="set0", image_files=self.image_files, data_files=self.data_files,
  1238                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1246                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1239                      engine_ini_file=self.engine_ini_file, test_harness=harness0,src_dst=self.src_dst0,
  1247                      engine_ini_file=self.engine_ini_file, test_harness=harness0,src_dst=self.src_dst0,
  1240                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1248                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1241                      custom_dir = self.custom_dir, component_path=self.component_path),
  1249                      custom_dir = self.custom_dir, dll_files = self.dll_files, component_path=self.component_path),
  1242                 dict(name="set1", image_files=self.image_files, data_files=self.data_files,
  1250                 dict(name="set1", image_files=self.image_files, data_files=self.data_files,
  1243                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1251                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1244                      engine_ini_file=self.engine_ini_file, test_harness=harness1, src_dst=self.src_dst1,
  1252                      engine_ini_file=self.engine_ini_file, test_harness=harness1, src_dst=self.src_dst1,
  1245                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1253                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1246                      custom_dir = self.custom_dir, component_path=self.component_path),
  1254                      custom_dir = self.custom_dir, dll_files = self.dll_files, component_path=self.component_path),
  1247             ])
  1255             ])
  1248         else:
  1256         else:
  1249             mocker.expect(test_plan.sets).result([
  1257             mocker.expect(test_plan.sets).result([
  1250                 dict(name="set0", image_files=self.image_files, data_files=self.data_files,
  1258                 dict(name="set0", image_files=self.image_files, data_files=self.data_files,
  1251                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1259                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1252                      engine_ini_file=self.engine_ini_file, test_harness=harness0, src_dst=self.src_dst0,
  1260                      engine_ini_file=self.engine_ini_file, test_harness=harness0, src_dst=self.src_dst0,
  1253                      pmd_files=self.pmd_files, trace_activation_files=self.trace_activation_files,
  1261                      pmd_files=self.pmd_files, trace_activation_files=self.trace_activation_files,
  1254                      trace_path=self.file_store.joinpath("traces", "set0", "tracelog.blx"),
  1262                      trace_path=self.file_store.joinpath("traces", "set0", "tracelog.blx"),
  1255                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1263                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1256                      custom_dir = self.custom_dir, component_path=self.component_path),
  1264                      custom_dir = self.custom_dir, dll_files = self.dll_files, component_path=self.component_path),
  1257                 dict(name="set1", image_files=self.image_files, data_files=self.data_files,
  1265                 dict(name="set1", image_files=self.image_files, data_files=self.data_files,
  1258                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1266                      config_files=self.config_files, testmodule_files=self.testmodule_files,
  1259                      engine_ini_file=self.engine_ini_file, test_harness=harness1, src_dst=self.src_dst1,
  1267                      engine_ini_file=self.engine_ini_file, test_harness=harness1, src_dst=self.src_dst1,
  1260                      pmd_files=self.pmd_files, trace_activation_files=self.trace_activation_files,
  1268                      pmd_files=self.pmd_files, trace_activation_files=self.trace_activation_files,
  1261                      trace_path=self.file_store.joinpath("traces", "set1", "tracelog.blx"),
  1269                      trace_path=self.file_store.joinpath("traces", "set1", "tracelog.blx"),
  1262                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1270                      ctc_enabled=self.ctc_enabled, eunitexerunner_flags=self.eunitexerunner_flags,
  1263                      custom_dir = self.custom_dir, component_path=self.component_path),
  1271                      custom_dir = self.custom_dir, dll_files = self.dll_files, component_path=self.component_path),
  1264             ])
  1272             ])
  1265         mocker.expect(test_plan.post_actions).result([
  1273         mocker.expect(test_plan.post_actions).result([
  1266             ("SendEmailAction", (("subject", "email subject"),
  1274             ("SendEmailAction", (("subject", "email subject"),
  1267                                  ("type", "ATS3_REPORT"),
  1275                                  ("type", "ATS3_REPORT"),
  1268                                  ("send-files", "true"),
  1276                                  ("send-files", "true"),
  1415                 assert step.findtext("./command") == "execute"
  1423                 assert step.findtext("./command") == "execute"
  1416                 params = step.findall("./params/param")
  1424                 params = step.findall("./params/param")
  1417                 assert params[0].get("file") == path(r"z:" + os.sep + "sys" + os.sep + "bin" + os.sep + "EUNITEXERUNNER.EXE")
  1425                 assert params[0].get("file") == path(r"z:" + os.sep + "sys" + os.sep + "bin" + os.sep + "EUNITEXERUNNER.EXE")
  1418                 assert params[1].get("result-file") == path(r"c:" + os.sep + "Shared" + os.sep + "EUnit" + os.sep + "logs" + os.sep + "file1_log.xml")
  1426                 assert params[1].get("result-file") == path(r"c:" + os.sep + "Shared" + os.sep + "EUnit" + os.sep + "logs" + os.sep + "file1_log.xml")
  1419                 assert params[2].get("parameters") == "/E S60AppEnv /R Off /F file1 /l xml file1.dll"
  1427                 assert params[2].get("parameters") == "/E S60AppEnv /R Off /F file1 /l xml file1.dll"
  1420                 assert params[3].get("timeout") == "60"
  1428                 assert params[3].get("timeout") == "60"              
  1421                 step = steps.next()
       
  1422                 file_ = self.testmodule_files[1]
       
  1423                 assert step.get("name") == "Execute test: %s" % file_.name
       
  1424                 assert step.findtext("./command") == "execute"
       
  1425                 params = step.findall("./params/param")
       
  1426                 assert params[0].get("file") == path(r"z:" + os.sep + "sys" + os.sep + "bin" + os.sep + "EUNITEXERUNNER.EXE")
       
  1427                 assert params[1].get("result-file") == path(r"c:" + os.sep + "Shared" + os.sep + "EUnit" + os.sep + "logs" + os.sep + "file2_log.xml")
       
  1428                 assert params[2].get("parameters") == "/E S60AppEnv /R Off /F file2 /l xml file2.dll"
       
  1429                 assert params[3].get("timeout") == "60"
       
  1430 
  1429 
  1431     def test_steps_trace_enabled(self):
  1430     def test_steps_trace_enabled(self):
  1432         """checks if traing is enabled"""
  1431         """checks if traing is enabled"""
  1433         test_harness = ["STIF"]
  1432         test_harness = ["STIF"]
  1434         for thar in test_harness:
  1433         for thar in test_harness: