85"""
+ 86 Tells ASTE server what to test and how.
+ 87
+ 88 The ASTE test plan from which the test.xml file can be written. The test
+ 89 plan requires TestAsset(s) to perform the tests
+ 90 """
+ 91
+ 92EMAIL_SUBJECT=(u"ATS3 report for §RUN_NAME§ §RUN_START_DATE§ "
+ 93u"§RUN_START_TIME§")
+ 94REPORT_PATH=u"§RUN_NAME§\§RUN_START_DATE§_§RUN_START_TIME§"
+ 95
+
116"""
+117 Insert a test set into the test plan.
+118 """
+119ifimage_filesisNone:
+120image_files=[]
+121iftest_timeoutisNone:
+122test_timeout=[]
+123test_harness=self.harness
+124setd=dict(name="set%d"%len(self.sets),image_files=image_files)
+125setd=dict(setd,test_timeout=test_timeout,test_harness=test_harness)
+126
+127self.sets.append(setd)
+
167"""
+168 Generate test drop zip file for ATS3.
+169
+170 Generates drop zip files file from a TestPlan instance. The main
+171 responsibility of this class is to serialize the plan into a valid XML
+172 file and build a zip file for the drop.
+173
+174 Creates one <set> for ASTE tests.
+175
+176 ASTE harness, normal operation
+177 ------------------------------
+178
+179 - create logging dir for aste makedir (to C:\logs\TestFramework)
+180 - execute asset from the testasset.zip execute-asset
+181 - fetch logs fetch-log
+182
+183 """
+184
+185ASTE_LOG_DIR=r"c:\logs\testframework"
+186
+
245"""Generate the test <plan> with multiple <set>s."""
+246plan=E("plan",name="Plan %s %s"%(test_plan["test_type"],test_plan["device_type"]),**self.defaults)
+247session=SE(plan,"session",name="session",**self.defaults)
+248# One set for each component.
+249forsetdintest_plan.sets:
+250self.drop_path=self.drop_path_root.joinpath(setd["name"])
+251elem=SE(session,"set",name=setd["name"],**self.defaults)
+252SE(SE(elem,"target"),"device",rank="master",alias="DEFAULT")
+253case=SE(elem,"case",name="%s case"%setd["name"],**self.defaults)
+254self.generate_steps(setd,case,test_plan)
+255returnplan
+
258"""Generate the test plan <step>s."""
+259# Flash images.
+260images=self.drop_path_root.joinpath("images")
+261forimage_fileinsetd["image_files"]:
+262flash=SE(case,"flash",images=images.joinpath(image_file.name))
+263flash.set("target-alias","DEFAULT")
+264
+265# If tracing enabled:
+266self.generate_execute_asset_steps(case,test_plan)
+
314"""Yield a list of drop files."""
+315drop_set=set()
+316drop_files=[]
+317zip_file=path(self.generate_testasset_zip(test_plan))##check here, I changed the variable name from "zipfile" to "zip_file"
+318forsetdintest_plan.sets:
+319drop_path=self.drop_path_root.joinpath(setd["name"])
+320drop_files=((drop_path.parent,"images",setd["image_files"]),
+321(drop_path.parent,"TestAssets",[zip_file]))
+322fordrop_dir,sub_dir,filesindrop_files:
+323forfile_pathinfiles:
+324iffile_path!=None:
+325drop_file=drop_dir.joinpath(sub_dir,file_path.name)
+326drop_file=drop_file.normpath()
+327ifdrop_filenotindrop_set:
+328drop_set.add(drop_file)
+329yield(drop_file,file_path.normpath())
+
360"""Create a test drop."""
+361_logger.debug("initialize test plan")
+362
+363test_plan=AsteTestPlan(config)
+364parser=AsteComponentParser(config)
+365parser.insert_test_set(test_plan)######check here if something goes wrong, removed ", path(tsrc)"
+366generator=AsteTestDropGenerator()
+367_logger.info("generating drop file: %s"%config.drop_file)
+368generator.generate(test_plan,output_file=config.drop_file)
+
372"""Main entry point."""
+373cli=OptionParser(usage="%prog [options] TSRC1 [TSRC2 [TSRC3 ...]]")
+374cli.add_option("--build-drive",help="Build area root drive")
+375cli.add_option("--device-type",help="Device type (e.g. 'PRODUCT')",
+376default="unknown")
+377cli.add_option("--device-hwid",help="Device hwid",
+378default="")
+379cli.add_option("--diamonds-build-url",help="Diamonds build url")
+380cli.add_option("--drop-file",help="Name for the final drop zip file",
+381default="ATS3Drop.zip")
+382cli.add_option("--file-store",help="Destination path for reports.",
+383default="")
+384cli.add_option("--flash-images",help="Paths to the flash image files",
+385default="")
+386cli.add_option("--minimum-flash-images",help="Minimum amount of flash images",
+387default=2)
+388cli.add_option("--report-email",help="Email notification receivers",
+389default="")
+390cli.add_option("--plan-name",help="Name of the test plan",
+391default="plan")
+392cli.add_option("--test-timeout",help="Test execution timeout value (default: %default)",
+393default="60")
+394cli.add_option("--testrun-name",help="Name of the test run",
+395default="run")
+396cli.add_option("--testasset-location",help="Path to the ASTE test assets location",
+397default="")
+398cli.add_option("--testasset-caseids",help="Test case IDs to run",
+399default="")
+400cli.add_option("--software-version",help="Sofwtare version",
+401default="")
+402cli.add_option("--test-type",help="Sofwtare version",
+403default="smoke")
+404cli.add_option("--device-language",help="language name e.g. English",
+405default="English")
+406cli.add_option("--software-release",help="Software release or product name e.g. PPD 52.50",
+407default="")
+408cli.add_option("--verbose",help="Increase output verbosity",
+409action="store_true",default=False)
+410
+411opts,_=cli.parse_args()
+412
+413ifnotopts.flash_images:
+414cli.error("no flash image files given")
+415iflen(opts.flash_images.split(","))<int(opts.minimum_flash_images):
+416cli.error("Not enough flash files: %i defined, %i needed"%(len(opts.flash_images.split(",")),int(opts.minimum_flash_images)))
+417
+418ifopts.verbose:
+419_logger.setLevel(logging.DEBUG)
+420logging.basicConfig(level=logging.DEBUG)
+421TEMP_PATH=tempfile.mkdtemp()
+422config=Configuration(opts)
+423create_drop(config)
+