mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-08 07:33:53 +01:00
tools: add a test for the ratbag commands
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
55
tools/test-ratbag-command.sh
Executable file
55
tools/test-ratbag-command.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/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
|
||||
|
||||
Reference in New Issue
Block a user