From ba6c7a3fa1c4247e7dc3019c0d242d966f41e4de Mon Sep 17 00:00:00 2001 From: Sylvain Pineau Date: Mon, 13 Jul 2020 11:55:23 +0200 Subject: bin:light_sensor_test -> light_sensor_test.sh --- bin/light_sensor_test | 46 ----------------------------------------- bin/light_sensor_test.sh | 46 +++++++++++++++++++++++++++++++++++++++++ units/power-management/jobs.pxu | 2 +- 3 files changed, 47 insertions(+), 47 deletions(-) delete mode 100755 bin/light_sensor_test create mode 100755 bin/light_sensor_test.sh diff --git a/bin/light_sensor_test b/bin/light_sensor_test deleted file mode 100755 index f413396..0000000 --- a/bin/light_sensor_test +++ /dev/null @@ -1,46 +0,0 @@ -#!/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 - diff --git a/bin/light_sensor_test.sh b/bin/light_sensor_test.sh new file mode 100755 index 0000000..f413396 --- /dev/null +++ b/bin/light_sensor_test.sh @@ -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 + diff --git a/units/power-management/jobs.pxu b/units/power-management/jobs.pxu index 8ba9e7c..c748924 100644 --- a/units/power-management/jobs.pxu +++ b/units/power-management/jobs.pxu @@ -345,7 +345,7 @@ id: power-management/light_sensor estimated_duration: 10.0 requires: dmi.product in ['Notebook','Laptop','Portable'] and executable.name == 'monitor-sensor' flags: also-after-suspend-manual -command: light_sensor_test +command: light_sensor_test.sh _description: _purpose: This test will check your Ambient Light Sensor work, if you don't have it, please skip this test. -- cgit v1.2.3