Skip to content

Structure of a test script#

Measmatic offers two types of tests: python script based and LUA script based. Python tests are universally applicable and do work with any type of instrument that can be controlled through remote control interface. LUA tests are very specific tests tailored to run on the Test Script Processor (TSP) of Keithley instruments.

Test plan processing#

A Measmatic project can contain various tests which are executed sequentially. Test sequences are special tests which can contain other tests as child elements. Test sequences can control if and how often child test are executed. Each test can define actions for those phases:

flowchart LR
    init-->test_init
    test_init-->test
    test-->test_finish
    test_finish-->finish

init#

This function is executed once for every test or test sequence when the test plan is executed. In this function general precondition should be checked. If any check fails an error can be raised to prevent any test execution.

test_init#

This function is called every time the test is about to get executed. For tests that are placed inside a test sequence this might happen multiple times within a test plan execution.

test#

This function runs the actual test. Here the main test logic should go.

test_finish#

This function is called every time the test execution was done, no matter if test execution was successful or an error occurred. For tests that are placed inside a test sequence this function might be called multiple times within a test plan execution.

finish#

This function is executed once after every test in the test plan was executed.

on_event#

This function is not part of the test plan processing. It is called when an event is raised from outside, currently through the RaiseEvent method of the JSON-RPC remote control interface. Besides the TestInterface object it receives the name of the event as a string. The function is called for every test that defines it, from the top of the test plan to the bottom. Tests that are deactivated are skipped.

Event names are case-insensitive and are always passed in lower case. The predefined names are available as constants of the Events class, so scripts and clients do not have to spell them out. Clients may raise their own events as well; those are simply passed through by name.

Python test script#

A python test may contain all of the above mentioned functions. Apart from test(measmatic: TestInterface) defining those functions is optional. As parameter every function gets an object of type TestInterface. This object offers the interface to Measmatic. A interface description can be found on page Measmatic python test interface.

from measmatic import Events

# is executed once when the test plan execution starts 
def init(measmatic):
    check_test_plan_execution_conditions()

# is executed every time before test execution
def test_init(measmatic):
    check_test_()

# runs the actual test
def test(measmatic):
    test()

# is executed every time after test execution
def test_finish(measmatic):
    do_cleanup()

# is executed once when the test plan execution ends 
def finish(measmatic):
    do_cleanup_after_test_plan_execution()

# is executed when an event is raised through the remote control interface
def on_event(measmatic, event_name):
    if event_name == Events.WAFER_TEST_STARTED:
        prepare_for_next_wafer()

LUA test script#

A test based on a LUA script is downloaded once when a test run is started in Measmatic. The script then gets executed for every time the test runs during script execution.