Test Unit Conventions
To provide a standard solution for handling the above problems, the following conventions for Test Units within a specific device library are required.
- There must be a Test Unit number 1, referred to as TU_OPEN,
which includes functions to initialize data structures, place the
device in the correct state for diagnostics, and open the device for
testing. It does not perform any other test functions. Any error
conditions are returned as diagnostic results. The define value TU_OPEN should
be used as the numerical identifier for this Test Unit.
Specifically, TU_OPEN performs the following:
- Sees that the TU_INFO_HANDLE parameter is set to NULL, allocates a memory buffer to hold persistent data, and assigns TU_INFO_HANDLE to that address. For more information, see "Persistent Data and the TU_INFO_HANDLE".
- Reads needed device attribute information by making calls to the configuration services (pdiag_cs_get_attr), and places appropriate information into the pdiagex_dds_t structure that is passed as a parameter on the pdiag_open call.
- Calls pdiag_diagnose_state to place the device into a testable state.
- Calls pdiag_open to open the device for testing, and loads the interrupt handler, if one exists.
- Assuming all the above functions are performed without error, returns a value of "0" as the major return code.
- There must be a Test Unit number 61439 (0xEFFF hex), referred
to as TU_CLOSE, which closes the device and restores the device
to the original state it was in prior to diagnostics being invoked.
The define value TU_CLOSE should be used as the numerical
identifier for this test unit.
Specifically, TU_CLOSE performs the following:
- Calls pdiag_close to close the device, and unloads the interrupt handler.
- Calls pdiag_restore_state to return the device to the state it was in prior to TU_OPEN.
- Frees any memory buffers that were allocated by TU_OPEN. For the most part, the buffers that need to be freed are "secondary" persistent data buffers, pointed to by pointers in TU_INFO_HANDLE.
- Assuming all the above functions are performed without error, returns a value of "0" as the major return code.
- A valid diagnostic sequence consists of a call to Test Unit TU_OPEN, some arbitrary number of calls to Test Units other than TU_OPEN or TU_CLOSE, and then a final call to Test Unit TU_CLOSE.