diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/light_sensor_test | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/bin/light_sensor_test b/bin/light_sensor_test new file mode 100644 index 0000000..f413396 --- /dev/null +++ b/bin/light_sensor_test @@ -0,0 +1,46 @@ +#!/bin/bash + +#Check if light sensor driver available, this section will be retired after checkbox resource jobs implement the light sensor in Device check +#Bug for reference https://bugs.launchpad.net/checkbox-support/+bug/1864960 +als_sensors=$(udevadm info --export-db|grep hid_sensor_als) + +#Check hid_sensor_als driver is loaded and available first. +if [ -z "$als_sensors" ] +then + echo "Light sensor driver not found" + exit 1 +else + echo "Light sensor driver is available" + echo "$als_sensors" +fi + +echo -e "\e[91mStart testing Ambient Light Sensor......\e[0m" +sleep 2 +echo -e "\e[92mwaiting for sensor to be covered......\e[0m" +sleep 3 + +#Output and print light sensor events 5 sec to light_sensor_test.log +timeout 5 monitor-sensor | tee $PLAINBOX_SESSION_SHARE/light_sensor_test.log & + + +#Print backlight value for 5 sec on the screen +for i in {1..10} +do + echo "Current Backlight Percentage is:" $(gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.freedesktop.DBus.Properties.Get org.gnome.SettingsDaemon.Power.Screen Brightness)| tr -d '()<>,' + sleep 0.5 +done + +# Fail when the user didn't wave their hand and no events have been collected. +if [[ $(cat $PLAINBOX_SESSION_SHARE/light_sensor_test.log | grep "Light changed" | wc -l) -lt 5 ]]; then +echo -e "\e[91mFAIL: Not enough data to be collect, Please rerun the test case and wave your hand around Light Sensor.\e[0m" +exit 1 +fi + + +#Print 5 values of the Light sensor value form log file +for i in {1..5} +do + echo "Ambient light sensor value " $i: `grep 'Light' $PLAINBOX_SESSION_SHARE/light_sensor_test.log | awk '{print $3}' | sed -n "$i"p` +done +exit 0 + |