Updated: October 28, 2024 |
You can automate multimedia testing by executing test scripts with mmcli. Test scripts offer a convenient way of rapidly issuing media commands and logging their results.
Test scripts are text files that list one command per line. Each command invokes either a built-in mmcli function or an API function from a multimedia component. The script writer is responsible for learning the proper syntax for a command; mmcli doesn't correct the input.
To execute a test script, you must either provide its filename on the command line or execute it in the interactive session with the file command. Unlike interpreters for languages such as Python or Perl, the mmcli utility can't be named in the first line of a script to allow the file to be executed from a QNX Neutrino terminal.
trap off load mm-cli-mmplaylist.so if error echo Error loading command interface module. quit fi mmplaylist_open / %playlist if error echo Error opening playlist: echo %playlist quit fi repeat %size mmplaylist_entry_next_get 1 if error echo Error retrieving playlist entry. quit fi loop echo Playlist read complete. Exiting. quit
The if and fi keywords define error-handling branches, which each print out an error message and exit.
# mmcli -Dplaylist=/tmp/music/pl/playlists_all/M3Uv1_test.m3u \ -Dsize=10 /Users/dcarson/work/temp/misc/branching.cli
# mmcli -i mm-cli-mmplaylist.so \ -Dplaylist=/tmp/music/pl/playlists_all/M3Uv1_test.m3u \ -Dsize=10 /Users/dcarson/work/temp/misc/branching.cli
The repeat and loop keywords define the beginning and end of an iterative code section. In this case, mmplaylist_entry_next_get is called repeatedly to get playlist entries until either the script fetches the number of entries specified in size or it encounters an error. The argument to this API function is the playlist handle; its value is hardcoded to 1 because this is the first (and only) playlist handle created in the script.
The quit command on the last line causes mmcli to exit instead of going into interactive mode. You can remove this last command to keep mmcli alive so you can then enter commands interactively.