1
0
forked from drath/libratbag
Files
libratbag-plus/tools/test-ratbag-command.sh
Peter Hutterer 5f4b770283 tools: add a test for the ratbag commands
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:52:25 +10:00

56 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
#
# Script to test ratbag-command for valid argument parsing. Must be run
# against a device file.
#
declare -A cmds
command="`dirname $0`/ratbag-command"
device=$1
if ! [[ -e "$device" ]]; then
echo "Invalid device path or path missing"
exit 1
fi
# no device argument
cmds[0]="list"
for i in "${cmds[@]}"; do
echo "Testing arguments '$i $device'"
eval $command "$i"
if [[ $? == 2 ]]; then
echo "Invalid command: $i"
exit 1
fi
sleep 1
done
# commands with device argument
cmds[0]="info"
cmds[1]="switch-etekcity"
cmds[2]="profile active get"
cmds[3]="profile active set 0"
cmds[4]="resolution active get"
cmds[5]="resolution active set 0"
cmds[6]="dpi get"
cmds[7]="dpi set 800"
cmds[8]="profile 0 resolution active get"
cmds[9]="profile 0 resolution active set 0"
cmds[10]="resolution 0 dpi get"
cmds[11]="resolution 0 dpi set 800"
cmds[12]="resolution 0 dpi get"
cmds[13]="profile 0 resolution 0 dpi get"
cmds[14]="profile 0 resolution 0 dpi set 800"
for i in "${cmds[@]}"; do
echo "Testing arguments '$i $device'"
eval $command "$i" $device
if [[ $? == 2 ]]; then
echo "Invalid command: $i"
exit 1
fi
sleep 1
done