Exemplo n.º 1
0
def main():
    conf.load(station_server_port='4444')
    with station_server.StationServer() as server:
        web_launcher.launch('http://localhost:4444')
        for _ in range(5):
            test = htf.Test(hello_world)
            test.add_output_callbacks(server.publish_final_state)
            test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 2
0
def main():
    conf.load(station_server_port='4444')
    with station_server.StationServer() as server:
        while True:
            tests = gather_tests()
            next_test = get_next_test()
            test = tests[next_test]()
            #test.add_output_callbacks(publish_to_db)
            test.add_output_callbacks(server.publish_final_state)
            test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 3
0
def main():
    test = htf.Test(add_numbers_fails, hello_world)
    test.add_output_callbacks(console_summary.ConsoleSummary())
    # Option 1: test.configure
    test.configure(stop_on_first_failure=True)

    # Option 2 : You can disable option 1 and enable below line
    # to get same result
    # CONF.load(stop_on_first_failure=True)

    test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 4
0
def main():
    test = htf.Test(
        htf.PhaseGroup.with_teardown(teardown)(
            hello_world,
            set_measurements,
            dimensions,
            attachments,
            skip_phase,
            measures_with_args.with_args(minimum=1, maximum=4),
            measures_with_marginal_args.with_args(marginal_minimum=4,
                                                  marginal_maximum=6),
            analysis,
        ),
        # Some metadata fields, these in particular are used by mfg-inspector,
        # but you can include any metadata fields.
        test_name='MyTest',
        test_description='OpenHTF Example Test',
        test_version='1.0.0')
    test.add_output_callbacks(
        callbacks.OutputToFile(
            './{dut_id}.{metadata[test_name]}.{start_time_millis}.pickle'))
    test.add_output_callbacks(
        json_factory.OutputToJSON(
            './{dut_id}.{metadata[test_name]}.{start_time_millis}.json',
            indent=4))
    test.add_output_callbacks(console_summary.ConsoleSummary())

    # Example of how to output to testrun protobuf format and save to disk then
    # upload.  Replace json_file with your JSON-formatted private key downloaded
    # from Google Developers Console when you created the Service Account you
    # intend to use, or name it 'my_private_key.json'.
    # inspector = (mfg_inspector.MfgInspector
    #    .from_json(json.load(json_file)))
    #    .set_converter(test_runs_converter.test_run_from_test_record))
    # test.add_output_callbacks(
    #     inspector.save_to_disk('./{dut_id}.{start_time_millis}.pb'),
    #     inspector.upload())

    test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 5
0
def main():
    # We instantiate our OpenHTF test with the phases we want to run as args.
    # Multiple phases would be passed as additional args, and additional
    # keyword arguments may be passed as well.  See other examples for more
    # complex uses.
    test = htf.Test(hello_world)

    # In order to view the result of the test, we have to output it somewhere,
    # and a local JSON file is a convenient way to do this.  Custom output
    # mechanisms can be implemented, but for now we'll just keep it simple.
    # This will always output to the same ./hello_world.json file, formatted
    # slightly for human readability.
    test.add_output_callbacks(
        json_factory.OutputToJSON('./{dut_id}.hello_world.json', indent=2))

    # prompt_for_test_start prompts the operator for a DUT ID, a unique identifier
    # for the DUT (Device Under Test).  OpenHTF requires that a DUT ID is set
    # each time a test is executed.  It may be set programmatically, but the
    # simplest way to get one is to prompt the user for it.  If test_start is
    # not provided, the test will start immediately and assume the DUT ID will
    # be set later (OpenHTF will raise an exception when the test completes if
    # a DUT ID has not been set).
    test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 6
0
        skip_phase,
        measures_with_args.with_args(min=2, max=4),
        # Some metadata fields, these in particular are used by mfg-inspector,
        # but you can include any metadata fields.
        test_name='MyTest',
        test_description='OpenHTF Example Test',
        test_version='1.0.0')
    test.add_output_callbacks(
        callbacks.OutputToFile(
            './{dut_id}.{metadata[test_name]}.{start_time_millis}.pickle'))
    test.add_output_callbacks(
        json_factory.OutputToJSON(
            './{dut_id}.{metadata[test_name]}.{start_time_millis}.json',
            indent=4))

    # Example of how to output to testrun protobuf format.
    #test.add_output_callbacks(
    #  mfg_inspector.OutputToTestRunProto('./{dut_id}.{start_time_millis}.pb'))

    # Example of how to upload to mfg-inspector.  Replace filename with your
    # JSON-formatted private key downloaded from Google Developers Console
    # when you created the Service Account you intend to use, or name it
    # 'my_private_key.json'.
    #if os.path.isfile('my_private_key.json'):
    #  with open('my_private_key.json', 'r') as json_file:
    #    test.add_output_callbacks(mfg_inspector.UploadToMfgInspector.from_json(
    #        json.load(json_file)))

    test.configure(teardown_function=teardown)
    test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 7
0
 def test_start_frontend(cls):
   """Start when frontend event comes, but get serial from USB."""
   prompt_for_test_start('Connect Android device and press ENTER.',
                         text_input=False)()
   return cls.test_start()
Exemplo n.º 8
0
if __name__ == '__main__':
  test = htf.Test(
      htf.PhaseGroup.with_teardown(teardown)(
          hello_world,
          set_measurements, dimensions, attachments, skip_phase,
          measures_with_args.with_args(min=1, max=4), analysis,
      ),
      # Some metadata fields, these in particular are used by mfg-inspector,
      # but you can include any metadata fields.
      test_name='MyTest', test_description='OpenHTF Example Test',
      test_version='1.0.0')
  test.add_output_callbacks(callbacks.OutputToFile(
      './{dut_id}.{metadata[test_name]}.{start_time_millis}.pickle'))
  test.add_output_callbacks(json_factory.OutputToJSON(
      './{dut_id}.{metadata[test_name]}.{start_time_millis}.json', indent=4))
  test.add_output_callbacks(console_summary.ConsoleSummary())

  # Example of how to output to testrun protobuf format and save to disk then
  # upload.  Replace json_file with your JSON-formatted private key downloaded
  # from Google Developers Console when you created the Service Account you
  # intend to use, or name it 'my_private_key.json'.
  # inspector = (mfg_inspector.MfgInspector
  #    .from_json(json.load(json_file)))
  #    .set_converter(test_runs_converter.test_run_from_test_record))
  # test.add_output_callbacks(
  #     inspector.save_to_disk('./{dut_id}.{start_time_millis}.pb'),
  #     inspector.upload())


  test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 9
0
def main():
    test = htf.Test(HelloWorldPhase)
    test.configure(default_dut_id=DEFAULT_DUT_ID)
    test.add_output_callbacks(
        CustomOutputToJSON('./{dut_id}.hello_world.json', indent=2))
    test.execute(test_start=user_input.prompt_for_test_start())
Exemplo n.º 10
0
 def test_start_frontend(cls):
     """Start when frontend event comes, but get serial from USB."""
     prompt_for_test_start('Connect Android device and press ENTER.',
                           text_input=False)()
     return cls.test_start()
Exemplo n.º 11
0
def main():
  test = htf.Test(HelloWorldPhase)
  test.configure(default_dut_id=DEFAULT_DUT_ID)
  test.add_output_callbacks(
      CustomOutputToJSON('./{dut_id}.hello_world.json', indent=2))
  test.execute(test_start=user_input.prompt_for_test_start())