예제 #1
0
    def test_measurements(self):
        result = util.NonLocalResult()

        def _save_result(test_record):
            result.result = test_record

        test = htf.Test(hello_phase, again_phase, lots_of_measurements,
                        measure_seconds, measure_dimensions, inline_phase)

        if self.UPDATE_OUTPUT:
            test.add_output_callbacks(callbacks.OutputToFile(RECORD_FILENAME))
        else:
            test.add_output_callbacks(_save_result)
        test.make_uid = lambda: 'UNITTEST:MOCK:UID'
        test.execute(test_start=lambda: 'TestDUT')
        if not self.UPDATE_OUTPUT:
            data.assert_records_equal_nonvolatile(self.record, result.result,
                                                  _VOLATILE_FIELDS)
예제 #2
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())
예제 #3
0
if __name__ == '__main__':
    test = htf.Test(
        hello_world,
        set_measurements,
        dimensions,
        attachments,
        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:
예제 #4
0
        def save_to_disk_callback(test_record_obj):
            proto = self._convert(test_record_obj)
            output_to_file = callbacks.OutputToFile(pattern)

            with output_to_file.open_output_file(test_record_obj) as outfile:
                outfile.write(proto.SerializeToString())