View source for GSM unit test
From Openmoko
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Return to GSM unit test.
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Return to GSM unit test.
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.
code is here sample test case is here
usage: python UnivTestv1.py -t casename -c libgsmd-tool -m shell -t : testcase file -c : libgsmd-tool -m : atcmd or shell
it should be written as below: C:r E:Register,error E:Netreg registered(home network),error,OK
From above case, it sends 'r' command to libgsmd-tool and it tries to register the network.
below texts are copied from libgsmd-tool shell mode r # Register EVENT: Netreg searching for network EVENT: Signal Quality: 22 EVENT: Netreg registered (home network) LocationAreaCode = 0x2C27 CellID = 0x498C
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.
There can be a lot of matched elements in an expect list. For this python script, please put the most matched element on the expect list.
When it reads the second expect line, it appends these two more elements to the list.
After sending a command, it will print 'correct' if it's passed. If it's failed, it will print 'Timeout' on the screen
It also stores the session log from 'libgsmd-tool', and the default file name is 'script.log'.