Files
libratbag/tools/test-ratbag-command.sh
Peter Hutterer 24bbf4b6db tools: add test for macro arguments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 23:36:29 +10:00

72 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#
# Script to test ratbag-command for valid argument parsing. Must be run
# against a device file.
#
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=()
cmds+=("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=()
cmds+=("info")
cmds+=("switch-etekcity")
cmds+=("profile active get")
cmds+=("profile active set 0")
cmds+=("resolution active get")
cmds+=("resolution active set 0")
cmds+=("dpi get")
cmds+=("dpi set 800")
cmds+=("rate get")
cmds+=("rate set 500")
cmds+=("profile 0 resolution active get")
cmds+=("profile 0 resolution active set 0")
cmds+=("resolution 0 dpi get")
cmds+=("resolution 0 dpi set 800")
cmds+=("resolution 0 rate get")
cmds+=("resolution 0 rate set 500")
cmds+=("profile 0 resolution 0 dpi get")
cmds+=("profile 0 resolution 0 dpi set 800")
cmds+=("profile 0 resolution 0 rate get")
cmds+=("profile 0 resolution 0 rate set 500")
cmds+=("button count")
cmds+=("profile 0 button count")
cmds+=("button 0 action get")
cmds+=("button 0 action set button 1")
cmds+=("profile 0 button 0 action get")
cmds+=("profile 0 button 0 action set button 1")
cmds+=("button 0 action set key KEY_ENTER")
cmds+=("profile 0 button 0 action set key KEY_ENTER")
cmds+=("button 0 action set special doubleclick")
cmds+=("profile 0 button 0 action set special doubleclick")
cmds+=("profile 0 button 0 action set macro +KEY_ENTER t05 -KEY_ENTER")
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