firmware_TouchpadMTB: resume recording gesture files

Sometimes, it is desirable to be able to record the missing gesture
event files in a specified directory. For example, a user may exit
the test suite prematurely, and would like to continue to record
the subsequent gesture event files later. Another usage might be that
a user deletes some incorrect gesture event files and want to
re-record them again.

In this patch, we support a new command option '--resume' to resume
recording gesture event files. It will first calculate what gesture
event files are specified in the test_conf.py, and then examine if
the files exist in the specified directory. It will prompt the user
to record any missing gesture event files in order. For those gesture
event files that already exist, the programs will just replay them.
A new log file and a new test result file will be generated in the
end.

If all gesture event files already exist, the '--resume' action
degenerated to the simple '--replay' action.

BUG=chromium-os:35024
TEST=Conduct the firmware tests on a chromebook machine.
Record some gesture event files. Note that you could exit the
system after recording a few gesture event files by typing 'x'.
$ DISPLAY=:0 python main.py

Now try to resume recording gesture event files in the latest
directory that you just exit.
$ DISPLAY=:0 OPTIONS="--replay latest" python main.py
This will resume recording gesture event files in the latest
directory, and generate a new test result file and a new log file in
/var/tmp/touchpad_firmware_test/latest

You could also resume on a particular directory:
$ DISPLAY=:0 OPTIONS="--replay 20130301_050611-fw_11.27-manual"
  python main.py

Change-Id: Ic9c887e97246d9ffaed8040d86240874c8c54bed
Reviewed-on: https://gerrit.chromium.org/gerrit/44388
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
Commit-Queue: Joseph Shyh-In Hwang <josephsih@chromium.org>
Reviewed-by: Joseph Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Joseph Shyh-In Hwang <josephsih@chromium.org>
3 files changed