GSM unit test

From Openmoko

GSM unit test is for testing the interactions between libgsmd-tool and gsmd. Here is a Python script to execute commands via libgsmd-tool. We can write our own test cases to let GSM modem execute AT commands automatically. It allows us to verify GSM basic functions, such like making phone calls, sending SMS, or registering to the network.

This python script is based on Python Expect. Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. We use this module to spawn [libgsmd-tool] and then can send commands to GSM modem via gsmd.

how to write expect list to match the result

From above real output from libgsmd-tool, it's very easy to detect the expect behavior. The first expect, it prints the command descriptions. The second expect, we can use some keywords like 'Netreg registered' for this case.

use ',' for the delimiter

always put the most matched one on the first element: There can be a lot of matched elements in an expect list. Put this list before using 'error'

append .EOF and .TIMEOUT elements to the expect list: When it reads the second expect line, it appends these two more elements to the list.

how to know it's failed or passed: there are 4 cases

correct: passed

error: failed

EOF: failed

timeout: failed

script log: It also stores the session log from 'libgsmd-tool', and the default file name is 'script.log'.