def test_greentea_update_kettle(self): uuid = "001" mbed_greentea_dlm.greentea_update_kettle(uuid) data = mbed_greentea_dlm.get_json_data_from_file( mbed_greentea_dlm.GREENTEA_KETTLE_PATH) self.assertIsNotNone(data) self.assertIn("start_time", data[uuid]) self.assertIn("cwd", data[uuid]) self.assertIn("locks", data[uuid]) self.assertEqual(data[uuid]["cwd"], os.getcwd()) self.assertEqual(data[uuid]["locks"], []) # Check greentea_kettle_info() output = mbed_greentea_dlm.greentea_kettle_info().splitlines() line = output[3] self.assertIn(os.getcwd(), line) self.assertIn(uuid, line) # Test greentea_acquire_target_id target_id = "999" mbed_greentea_dlm.greentea_acquire_target_id(target_id, uuid) data = mbed_greentea_dlm.get_json_data_from_file( mbed_greentea_dlm.GREENTEA_KETTLE_PATH) self.assertIn(uuid, data) self.assertIn("locks", data[uuid]) self.assertIn(target_id, data[uuid]["locks"]) # Test greentea_release_target_id mbed_greentea_dlm.greentea_release_target_id(target_id, uuid) data = mbed_greentea_dlm.get_json_data_from_file( mbed_greentea_dlm.GREENTEA_KETTLE_PATH) self.assertIn(uuid, data) self.assertIn("locks", data[uuid]) self.assertNotIn(target_id, data[uuid]["locks"]) # Test greentea_acquire_target_id_from_list target_id = "999" result = mbed_greentea_dlm.greentea_acquire_target_id_from_list( [target_id], uuid) data = mbed_greentea_dlm.get_json_data_from_file( mbed_greentea_dlm.GREENTEA_KETTLE_PATH) self.assertEqual(result, target_id) self.assertIn(uuid, data) self.assertIn("locks", data[uuid]) self.assertIn(target_id, data[uuid]["locks"]) # Check greentea_clean_kettle() mbed_greentea_dlm.greentea_clean_kettle(uuid) data = mbed_greentea_dlm.get_json_data_from_file( mbed_greentea_dlm.GREENTEA_KETTLE_PATH) self.assertEqual(data, {})
def main(): """ Closure for main_cli() function """ parser = optparse.OptionParser() parser.add_option( '-t', '--target', dest='list_of_targets', help= 'You can specify list of targets you want to build. Use comma to sepatate them' ) parser.add_option( '-n', '--test-by-names', dest='test_by_names', help= 'Runs only test enumerated it this switch. Use comma to separate test case names.' ) parser.add_option( '-i', '--skip-test', dest='skip_test', help= 'Skip tests enumerated it this switch. Use comma to separate test case names.' ) parser.add_option( "-O", "--only-build", action="store_true", dest="only_build_tests", default=False, help= "Only build repository and tests, skips actual test procedures (flashing etc.)" ) parser.add_option("-S", "--skip-build", action="store_true", dest="skip_yotta_build", default=False, help="Skip calling 'yotta build' on this module") copy_methods_str = "Plugin support: " + ', '.join( mbed_host_tests.host_tests_plugins.get_plugin_caps('CopyMethod')) parser.add_option("-c", "--copy", dest="copy_method", help="Copy (flash the target) method selector. " + copy_methods_str, metavar="COPY_METHOD") parser.add_option( '', '--parallel', dest='parallel_test_exec', default=1, help= 'Experimental, you execute test runners for connected to your host MUTs in parallel (speeds up test result collection)' ) parser.add_option( "-e", "--enum-host-tests", dest="enum_host_tests", help= "Define directory with yotta module local host tests. Default: ./test/host_tests" ) parser.add_option( '', '--config', dest='verbose_test_configuration_only', default=False, action="store_true", help='Displays connected boards and detected targets and exits.') parser.add_option( '', '--release', dest='build_to_release', default=False, action="store_true", help='If possible force build in release mode (yotta -r).') parser.add_option('', '--debug', dest='build_to_debug', default=False, action="store_true", help='If possible force build in debug mode (yotta -d).') parser.add_option('-l', '--list', dest='list_binaries', default=False, action="store_true", help='List available binaries') parser.add_option( '-m', '--map-target', dest='map_platform_to_yt_target', help= 'List of custom mapping between platform name and yotta target. Comma separated list of PLATFORM:TARGET tuples' ) parser.add_option( '', '--use-tids', dest='use_target_ids', help= 'Specify explicitly which devices can be used by Greentea for testing by creating list of allowed Target IDs (use comma separated list)' ) parser.add_option('-u', '--shuffle', dest='shuffle_test_order', default=False, action="store_true", help='Shuffles test execution order') parser.add_option( '', '--shuffle-seed', dest='shuffle_test_seed', default=None, help= 'Shuffle seed (If you want to reproduce your shuffle order please use seed provided in test summary)' ) parser.add_option( '', '--lock', dest='lock_by_target', default=False, action="store_true", help= 'Use simple resource locking mechanism to run multiple application instances' ) parser.add_option( '', '--digest', dest='digest_source', help= 'Redirect input from where test suite should take console input. You can use stdin or file name to get test case console output' ) parser.add_option('-H', '--hooks', dest='hooks_json', help='Load hooks used drive extra functionality') parser.add_option( '', '--test-cfg', dest='json_test_configuration', help='Pass to host test data with host test configuration') parser.add_option( '', '--run', dest='run_app', help='Flash, reset and dump serial from selected binary application') parser.add_option( '', '--report-junit', dest='report_junit_file_name', help= 'You can log test suite results in form of JUnit compliant XML report') parser.add_option('', '--report-text', dest='report_text_file_name', help='You can log test suite results to text file') parser.add_option('', '--report-json', dest='report_json', default=False, action="store_true", help='Outputs test results in JSON') parser.add_option('', '--report-fails', dest='report_fails', default=False, action="store_true", help='Prints console outputs for failed tests') parser.add_option( '', '--yotta-registry', dest='yotta_search_for_mbed_target', default=False, action="store_true", help= 'Use on-line yotta registry to search for compatible with connected mbed devices yotta targets. Default: search is done in yotta_targets directory' ) parser.add_option('-V', '--verbose-test-result', dest='verbose_test_result_only', default=False, action="store_true", help='Prints test serial output') parser.add_option('-v', '--verbose', dest='verbose', default=False, action="store_true", help='Verbose mode (prints some extra information)') parser.add_option('', '--plain', dest='plain', default=False, action="store_true", help='Do not use colours while logging') parser.add_option('', '--version', dest='version', default=False, action="store_true", help='Prints package version and exits') parser.description = """This automated test script is used to test mbed SDK 3.0 on mbed-enabled devices with support from yotta build tool""" parser.epilog = """Example: mbedgt --target frdm-k64f-gcc""" (opts, args) = parser.parse_args() cli_ret = 0 start = time() if opts.lock_by_target: # We are using Greentea proprietary locking mechanism to lock between platforms and targets gt_logger.gt_log("using (experimental) simple locking mechanism") gt_logger.gt_log_tab("kettle: %s" % GREENTEA_KETTLE_PATH) gt_file_sem, gt_file_sem_name, gt_instance_uuid = greentea_get_app_sem( ) with gt_file_sem: greentea_update_kettle(gt_instance_uuid) try: cli_ret = main_cli(opts, args, gt_instance_uuid) except KeyboardInterrupt: greentea_clean_kettle(gt_instance_uuid) gt_logger.gt_log_err("ctrl+c keyboard interrupt!") return (-2) # Keyboard interrupt except: greentea_clean_kettle(gt_instance_uuid) gt_logger.gt_log_err("unexpected error:") gt_logger.gt_log_tab(sys.exc_info()[0]) raise greentea_clean_kettle(gt_instance_uuid) else: # Standard mode of operation # Other instance must provide mutually exclusive access control to platforms and targets try: cli_ret = main_cli(opts, args) except KeyboardInterrupt: gt_logger.gt_log_err("ctrl+c keyboard interrupt!") return (-2) # Keyboard interrupt except Exception as e: gt_logger.gt_log_err("unexpected error:") gt_logger.gt_log_tab(str(e)) raise if not any([opts.list_binaries, opts.version]): delta = time() - start # Test execution time delta gt_logger.gt_log("completed in %.2f sec" % delta) if cli_ret: gt_logger.gt_log_err("exited with code %d" % cli_ret) return (cli_ret)
def main(): """ Closure for main_cli() function """ parser = optparse.OptionParser() parser.add_option('-t', '--target', dest='list_of_targets', help='You can specify list of targets you want to build. Use comma to sepatate them') parser.add_option('-n', '--test-by-names', dest='test_by_names', help='Runs only test enumerated it this switch. Use comma to separate test case names.') parser.add_option("-O", "--only-build", action="store_true", dest="only_build_tests", default=False, help="Only build repository and tests, skips actual test procedures (flashing etc.)") parser.add_option("", "--skip-build", action="store_true", dest="skip_yotta_build", default=False, help="Skip calling 'yotta build' on this module") copy_methods_str = "Plugin support: " + ', '.join(mbed_host_tests.host_tests_plugins.get_plugin_caps('CopyMethod')) parser.add_option("-c", "--copy", dest="copy_method", help="Copy (flash the target) method selector. " + copy_methods_str, metavar="COPY_METHOD") parser.add_option('', '--parallel', dest='parallel_test_exec', default=1, help='Experimental, you execute test runners for connected to your host MUTs in parallel (speeds up test result collection)') parser.add_option("-e", "--enum-host-tests", dest="enum_host_tests", help="Define directory with yotta module local host tests. Default: ./test/host_tests") parser.add_option('', '--config', dest='verbose_test_configuration_only', default=False, action="store_true", help='Displays connected boards and detected targets and exits.') parser.add_option('', '--release', dest='build_to_release', default=False, action="store_true", help='If possible force build in release mode (yotta -r).') parser.add_option('', '--debug', dest='build_to_debug', default=False, action="store_true", help='If possible force build in debug mode (yotta -d).') parser.add_option('', '--list', dest='list_binaries', default=False, action="store_true", help='List available binaries') parser.add_option('-m', '--map-target', dest='map_platform_to_yt_target', help='List of custom mapping between platform name and yotta target. Comma separated list of PLATFORM:TARGET tuples') parser.add_option('', '--use-tids', dest='use_target_ids', help='Specify explicitly which devices can be used by Greentea for testing by creating list of allowed Target IDs (use comma separated list)') parser.add_option('', '--lock', dest='lock_by_target', default=False, action="store_true", help='Use simple resource locking mechanism to run multiple application instances') parser.add_option('', '--digest', dest='digest_source', help='Redirect input from where test suite should take console input. You can use stdin or file name to get test case console output') parser.add_option('', '--test-cfg', dest='json_test_configuration', help='Pass to host test data with host test configuration') parser.add_option('', '--run', dest='run_app', help='Flash, reset and dump serial from selected binary application') parser.add_option('', '--report-junit', dest='report_junit_file_name', help='You can log test suite results in form of JUnit compliant XML report') parser.add_option('', '--report-text', dest='report_text_file_name', help='You can log test suite results to text file') parser.add_option('', '--report-json', dest='report_json', default=False, action="store_true", help='Outputs test results in JSON') parser.add_option('', '--report-fails', dest='report_fails', default=False, action="store_true", help='Prints console outputs for failed tests') parser.add_option('', '--yotta-registry', dest='yotta_search_for_mbed_target', default=False, action="store_true", help='Use on-line yotta registry to search for compatible with connected mbed devices yotta targets. Default: search is done in yotta_targets directory') parser.add_option('-V', '--verbose-test-result', dest='verbose_test_result_only', default=False, action="store_true", help='Prints test serial output') parser.add_option('-v', '--verbose', dest='verbose', default=False, action="store_true", help='Verbose mode (prints some extra information)') parser.add_option('', '--version', dest='version', default=False, action="store_true", help='Prints package version and exits') parser.description = """This automated test script is used to test mbed SDK 3.0 on mbed-enabled devices with support from yotta build tool""" parser.epilog = """Example: mbedgt --target frdm-k64f-gcc""" (opts, args) = parser.parse_args() cli_ret = 0 start = time() if opts.lock_by_target: # We are using Greentea proprietary locking mechanism to lock between platforms and targets gt_log("using (experimental) simple locking mechanism") gt_log_tab("kettle: %s"% GREENTEA_KETTLE_PATH) gt_file_sem, gt_file_sem_name, gt_instance_uuid = greentea_get_app_sem() with gt_file_sem: greentea_update_kettle(gt_instance_uuid) try: cli_ret = main_cli(opts, args, gt_instance_uuid) except KeyboardInterrupt: greentea_clean_kettle(gt_instance_uuid) gt_log_err("ctrl+c keyboard interrupt!") return(-2) # Keyboard interrupt except: greentea_clean_kettle(gt_instance_uuid) gt_log_err("unexpected error:") gt_log_tab(sys.exc_info()[0]) raise greentea_clean_kettle(gt_instance_uuid) else: # Standard mode of operation # Other instance must provide mutually exclusive access control to platforms and targets try: cli_ret = main_cli(opts, args) except KeyboardInterrupt: gt_log_err("ctrl+c keyboard interrupt!") return(-2) # Keyboard interrupt except Exception as e: gt_log_err("unexpected error:") gt_log_tab(str(e)) raise if not any([opts.list_binaries, opts.version]): print "completed in %.2f sec"% (time() - start) return(cli_ret)
def main(): """ Closure for main_cli() function """ parser = optparse.OptionParser() parser.add_option( "-t", "--target", dest="list_of_targets", help="You can specify list of yotta targets you want to build. Use comma to separate them." + "Note: If --test-spec switch is defined this list becomes optional list of builds you want to filter in your test:" + "Comma separated list of builds from test specification. Applicable if --test-spec switch is specified", ) parser.add_option( "-n", "--test-by-names", dest="test_by_names", help="Runs only test enumerated it this switch. Use comma to separate test case names.", ) parser.add_option( "-i", "--skip-test", dest="skip_test", help="Skip tests enumerated it this switch. Use comma to separate test case names.", ) parser.add_option( "-O", "--only-build", action="store_true", dest="only_build_tests", default=False, help="Only build repository and tests, skips actual test procedures (flashing etc.)", ) parser.add_option( "-S", "--skip-build", action="store_true", dest="skip_yotta_build", default=True, help="Skip calling 'yotta build' on this module", ) copy_methods_str = "Plugin support: " + ", ".join(mbed_host_tests.host_tests_plugins.get_plugin_caps("CopyMethod")) parser.add_option( "-c", "--copy", dest="copy_method", help="Copy (flash the target) method selector. " + copy_methods_str, metavar="COPY_METHOD", ) parser.add_option( "", "--parallel", dest="parallel_test_exec", default=1, help="Experimental, you execute test runners for connected to your host MUTs in parallel (speeds up test result collection)", ) parser.add_option( "-e", "--enum-host-tests", dest="enum_host_tests", help="Define directory with yotta module local host tests. Default: ./test/host_tests", ) parser.add_option( "", "--config", dest="verbose_test_configuration_only", default=False, action="store_true", help="Displays connected boards and detected targets and exits.", ) parser.add_option( "", "--release", dest="build_to_release", default=False, action="store_true", help="If possible force build in release mode (yotta -r).", ) parser.add_option( "", "--debug", dest="build_to_debug", default=False, action="store_true", help="If possible force build in debug mode (yotta -d).", ) parser.add_option( "-l", "--list", dest="list_binaries", default=False, action="store_true", help="List available binaries" ) parser.add_option( "-g", "--grm", dest="global_resource_mgr", help="Global resource manager service query: platrform name, remote mgr module name, IP address and port, example K64F:module_name:10.2.123.43:3334", ) parser.add_option( "-m", "--map-target", dest="map_platform_to_yt_target", help="List of custom mapping between platform name and yotta target. Comma separated list of YOTTA_TARGET:PLATFORM tuples", ) parser.add_option( "", "--use-tids", dest="use_target_ids", help="Specify explicitly which devices can be used by Greentea for testing by creating list of allowed Target IDs (use comma separated list)", ) parser.add_option( "-u", "--shuffle", dest="shuffle_test_order", default=False, action="store_true", help="Shuffles test execution order", ) parser.add_option( "", "--shuffle-seed", dest="shuffle_test_seed", default=None, help="Shuffle seed (If you want to reproduce your shuffle order please use seed provided in test summary)", ) parser.add_option( "", "--lock", dest="lock_by_target", default=False, action="store_true", help="Use simple resource locking mechanism to run multiple application instances", ) parser.add_option( "", "--digest", dest="digest_source", help="Redirect input from where test suite should take console input. You can use stdin or file name to get test case console output", ) parser.add_option("-H", "--hooks", dest="hooks_json", help="Load hooks used drive extra functionality") parser.add_option("", "--test-spec", dest="test_spec", help="Test specification generated by build system.") parser.add_option( "", "--test-cfg", dest="json_test_configuration", help="Pass to host test data with host test configuration" ) parser.add_option("", "--run", dest="run_app", help="Flash, reset and dump serial from selected binary application") parser.add_option( "", "--report-junit", dest="report_junit_file_name", help="You can log test suite results in form of JUnit compliant XML report", ) parser.add_option( "", "--report-text", dest="report_text_file_name", help="You can log test suite results to text file" ) parser.add_option( "", "--report-json", dest="report_json_file_name", help="You can log test suite results to JSON formatted file" ) parser.add_option( "", "--report-html", dest="report_html_file_name", help="You can log test suite results in the form of a HTML page", ) parser.add_option( "", "--report-fails", dest="report_fails", default=False, action="store_true", help="Prints console outputs for failed tests", ) parser.add_option( "", "--yotta-registry", dest="yotta_search_for_mbed_target", default=False, action="store_true", help="Use on-line yotta registry to search for compatible with connected mbed devices yotta targets. Default: search is done in yotta_targets directory", ) parser.add_option( "-V", "--verbose-test-result", dest="verbose_test_result_only", default=False, action="store_true", help="Prints test serial output", ) parser.add_option( "-v", "--verbose", dest="verbose", default=False, action="store_true", help="Verbose mode (prints some extra information)", ) parser.add_option( "", "--plain", dest="plain", default=False, action="store_true", help="Do not use colours while logging" ) parser.add_option( "", "--version", dest="version", default=False, action="store_true", help="Prints package version and exits" ) parser.description = """This automated test script is used to test mbed SDK 3.0 on mbed-enabled devices with support from yotta build tool""" parser.epilog = """Example: mbedgt --target frdm-k64f-gcc""" (opts, args) = parser.parse_args() cli_ret = 0 if not opts.version: # This string should not appear when fetching plain version string gt_logger.gt_log(get_hello_string()) start = time() if opts.lock_by_target: # We are using Greentea proprietary locking mechanism to lock between platforms and targets gt_logger.gt_log("using (experimental) simple locking mechanism") gt_logger.gt_log_tab("kettle: %s" % GREENTEA_KETTLE_PATH) gt_file_sem, gt_file_sem_name, gt_instance_uuid = greentea_get_app_sem() with gt_file_sem: greentea_update_kettle(gt_instance_uuid) try: cli_ret = main_cli(opts, args, gt_instance_uuid) except KeyboardInterrupt: greentea_clean_kettle(gt_instance_uuid) gt_logger.gt_log_err("ctrl+c keyboard interrupt!") return -2 # Keyboard interrupt except: greentea_clean_kettle(gt_instance_uuid) gt_logger.gt_log_err("unexpected error:") gt_logger.gt_log_tab(sys.exc_info()[0]) raise greentea_clean_kettle(gt_instance_uuid) else: # Standard mode of operation # Other instance must provide mutually exclusive access control to platforms and targets try: cli_ret = main_cli(opts, args) except KeyboardInterrupt: gt_logger.gt_log_err("ctrl+c keyboard interrupt!") return -2 # Keyboard interrupt except Exception as e: gt_logger.gt_log_err("unexpected error:") gt_logger.gt_log_tab(str(e)) raise if not any([opts.list_binaries, opts.version]): delta = time() - start # Test execution time delta gt_logger.gt_log("completed in %.2f sec" % delta) if cli_ret: gt_logger.gt_log_err("exited with code %d" % cli_ret) return cli_ret
# We are using Greentea proprietary locking mechanism to lock between platforms and targets <<<<<<< HEAD gt_log("using (experimental) simple locking mechanism") gt_log_tab("kettle: %s"% GREENTEA_KETTLE_PATH) ======= >>>>>>> princeofdarkness76/devel_test_flow gt_file_sem, gt_file_sem_name, gt_instance_uuid = greentea_get_app_sem() gt_log("using (experimental) simple locking mechanism") gt_log_tab("kettle: %s"% GREENTEA_KETTLE_PATH) gt_log_tab("greentea lock uuid '%s'"% gt_instance_uuid) with gt_file_sem: greentea_update_kettle(gt_instance_uuid) try: cli_ret = main_cli(opts, args, gt_instance_uuid) except KeyboardInterrupt: greentea_clean_kettle(gt_instance_uuid) gt_log_err("ctrl+c keyboard interrupt!") <<<<<<< HEAD return(-2) # Keyboard interrupt except: greentea_clean_kettle(gt_instance_uuid) gt_log_err("unexpected error:") gt_log_tab(sys.exc_info()[0]) ======= exit(-2) # Keyboard interrupt except Exception as e: greentea_clean_kettle(gt_instance_uuid) gt_log_err("Unexpected error:") gt_log_tab(str(e)) cli_ret = -3 >>>>>>> princeofdarkness76/devel_test_flow