Package: openhtf
DISCLAIMER:This is not an official Google product.OpenHTFThe open-source hardware testing framework.OverviewOpenHTF is a Python library that provides a set of convenient abstractions
designed to remove as much boilerplate as possible from hardware test setup and
execution, so test engineers can focus primarily on test logic. It aspires to
do so in a lightweight and minimalistic fashion. It is general enough to be
useful in a variety of hardware testing scenarios, from the lab bench to the
manufacturing floor.Installing OpenHTFNOTE:We recommend usingvirtualenvto create
an isolated Python environments for your projects, so as to protect system-wide
Python packages the OS depends upon. The installation instructions assume you'vealreadycreated a virtualenv and activated it if you wish to do so.Option 1: Installing via 'pip' (recommended)The most straightforward way to get theopenhtfPython package into your
Python environment is simply to install it viapip. This will install the most recent
production release.pipinstallopenhtfOption 2: Installing from SourceIf you want to install from source instead (for example, if you want some new
feature that hasn't made it to the production release yet), you can downloadthe source codeviagitor other means, and install theopenhtfpackage
into your Python environment using the standardsetup.pyscript.pythonsetup.pyinstallUsing OpenHTFThe fastest way to get started is to take a look in theexamples/directory,
where you'll find sample test scripts and plugs. In addition, many of OpenHTF's
modules are fairly well documented inline through the use of docstrings.Note: some of theexamples/require protocol buffer code to be generated viapython setup.py buildcommand.  This requires protocol buffer compiler
library to be installed
(additional instructions).NomenclatureOpenHTF uses certain nomenclature internally for several of its core concepts.
Some of the more important terms are listed here for clarity.DUT (Device Under Test)DUT refers to an individual piece of hardware being evaluated, exercised, or
tested.TestThe top-level abstraction that OpenHTF deals with is the test. A test is just
a series of steps performed on/with a DUT, usually along with some
data-gathering or measurement steps. In the OpenHTF paradigm, tests are
expressed as regular Python programs (.py files) that import and instantiate the
'Test' class from the openhtf module. That way test code is as straightforward
as possible to read and write. This also provides for the flexibility to do
anything in a test that can normally be done in Python. Superficially, what
distinguishes an OpenHTF test from any other Python program is that the OpenHTF
test imports the openhtf package, instantiates theTestclass, and calls
itsExecute()function. From there, OpenHTF manages the setup, execution,
and teardown of the test, keeps track of anything gathered, and provides a
pass/fail result.At times it may be necessary to disambiguate between different common readings
of the wordtest. In such scenarios we use the following more precise terms:test run- A single start-to-finish execution of a specific test.test recipe- A test definition that may be executed multiple times,
each time as a distinct test run.test script- A .py file that contains a test recipe.StationStationscapture the notion that a given test ran at some point and may run
again. It loosely reflects the idea of physical test stations that process
multiple DUTs over time. OpenHTF writes a breadcrumb to the filesystem (in a
directory that can be set using the--rundirflag) each time a test runs, and
all tests that have the same name are considered to be of the same station. This
way the web frontend can display a consolidated list of known tests as a list of
stations.PhaseOpenHTF tests are broken down into logical blocks calledphases. Phases are no
more than normal Python callables (usually functions) combined with the needed
metadata. Writing an OpenHTF test is just a matter of writing a bunch of phase
functions and specifying the order in which they should be executed.MeasurementOpenHTF gathers data about a DUT in the form ofmeasurements. Usually,
measurements are declared along with a specification that describes what
constitutes a "passing" value. If OpenHTF finishes the test run and one or more
measurements were out of that spec, the result of the whole test run will be
considered a fail.AttachmentSometimes may want to capture additional data that is more complex or free-form
than a measurement. Anattachmentcan link arbitrary binary data to a
test record, along with an optional MIME type.PlugThe essence of an OpenHTF test is to interact with a DUT to exercise it in
various ways and observe the result. Sometimes this is done by communicating
directly with the DUT, and other times it's done by communicating with a piece
of test equipment to which the DUT is attached in some way. Aplugis a piece
of code written to enable OpenHTF to interact with a particular type of hardware,
whether that be a DUT itself or a piece of test equipment. OpenHTF comes
packaged with a growing collection of useful plugs, but supports the
creation of custom plugs as well.