Merge ~ray.chen/plainbox-provider-checkbox:add-ambient-light-sensor-test into plainbox-provider-checkbox:master

Proposed by Ray Chen
Status: Merged
Approved by: Pierre Equoy
Approved revision: e1359aca12d20666de5b5e4943e110e95288ad05
Merged at revision: 8f7506e1e8903ed9faf6240c709ff855c1696a0a
Proposed branch: ~ray.chen/plainbox-provider-checkbox:add-ambient-light-sensor-test
Merge into: plainbox-provider-checkbox:master
Diff against target: 116 lines (+70/-0)
3 files modified
bin/light_sensor_test (+46/-0)
units/monitor/test-plan.pxu (+4/-0)
units/power-management/jobs.pxu (+20/-0)
Reviewer Review Type Date Requested Status
Pierre Equoy Approve
Maciej Kisielewski Approve
Ray Chen (community) Needs Resubmitting
Nara Huang (community) Approve
Sylvain Pineau Pending
Review via email: mp+379950@code.launchpad.net

Commit message

power: add light sensor test

Description of the change

Add one simply script to check light sensor module and value also check
 current backlight value from userspace.

Test platform: 201911-27469 (18.04 and 20.04) and ACE platform (201911-27534)
This script deal with:
1. Check if light sensor kernel module loaded
2. Parse light sensor/backlight value and record it in log file
3. If log data not enough ask to re-run
4. output pass or failed based on script result

To post a comment you must log in.
Revision history for this message
Nara Huang (narahuang) wrote :

Looks good to me, +1

review: Approve
Revision history for this message
Pierre Equoy (pieq) wrote :

 I didn't test this on a real device, but here are my few remarks. A few typos and some ideas for the job itself.

review: Needs Fixing
Revision history for this message
Ray Chen (ray.chen) wrote :

Resubmit and modify based on @pieq previous comments

Revision history for this message
Pierre Equoy (pieq) wrote :

I've tried to run your scripts on the device with light sensor that you provided, but when I run ths job in Checkbox, it fails with the following output:

light_sensor_test: line 10: syntax error near unexpected token `then'
light_sensor_test: line 10: `else echo "Light sensor driver is avaliable "; then'

This is because the `else` command in Bash is not used the same as `elif`.

A few more comments:

- the script should be set to executable (chmod +x), so that it's versioned in Git in the same manner as the other scripts in the Checkbox provider
- instead of writing additional commits to modify your original commit, you should amend your original commit (I use Git cola when doing that because it has an easier GUI to understand, I can show you later). You can also use the `squash` command to merge several commits into one
- I spotted other typos, please see inline comments.

review: Needs Fixing
Revision history for this message
Ray Chen (ray.chen) wrote :

Modify test script based on pieq comment, please have review
Also revise job steps to make it more detail

Revision history for this message
Maciej Kisielewski (kissiel) wrote :

I recommend rephrasing some parts of the instruction(s).
Also a few comments/nitpicks inline.

As for the commit message: the colon doesn't make sense here. If we do something like

thing: message

Then the 'thing' is a domain/category/component we're changing and the message tells us what the commit does. It's not necessary to name the thing, so in this case it should be as simple as:

"add light sensor test"

Or:

"power: add light sensor test"

review: Needs Fixing
Revision history for this message
Ray Chen (ray.chen) wrote :

Thanks to Maciej on those comments, I made some modification and resubmit again.

Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Much better. Thanks for all the work!
+1

review: Approve
Revision history for this message
Ray Chen (ray.chen) wrote :

Thanks to Pierre comment on "no prefix on after-suspend job"
Add prefix "after-suspend-manual" to the test plan.

Thanks for all your reviews, it's really helpful.

Revision history for this message
Pierre Equoy (pieq) wrote :

I tested it on a XPS with light sensor, the job works fine both before and after suspend!

+1

Thanks Ray for your dedication :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/light_sensor_test b/bin/light_sensor_test
2new file mode 100644
3index 0000000..f413396
4--- /dev/null
5+++ b/bin/light_sensor_test
6@@ -0,0 +1,46 @@
7+#!/bin/bash
8+
9+#Check if light sensor driver available, this section will be retired after checkbox resource jobs implement the light sensor in Device check
10+#Bug for reference https://bugs.launchpad.net/checkbox-support/+bug/1864960
11+als_sensors=$(udevadm info --export-db|grep hid_sensor_als)
12+
13+#Check hid_sensor_als driver is loaded and available first.
14+if [ -z "$als_sensors" ]
15+then
16+ echo "Light sensor driver not found"
17+ exit 1
18+else
19+ echo "Light sensor driver is available"
20+ echo "$als_sensors"
21+fi
22+
23+echo -e "\e[91mStart testing Ambient Light Sensor......\e[0m"
24+sleep 2
25+echo -e "\e[92mwaiting for sensor to be covered......\e[0m"
26+sleep 3
27+
28+#Output and print light sensor events 5 sec to light_sensor_test.log
29+timeout 5 monitor-sensor | tee $PLAINBOX_SESSION_SHARE/light_sensor_test.log &
30+
31+
32+#Print backlight value for 5 sec on the screen
33+for i in {1..10}
34+do
35+ 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 '()<>,'
36+ sleep 0.5
37+done
38+
39+# Fail when the user didn't wave their hand and no events have been collected.
40+if [[ $(cat $PLAINBOX_SESSION_SHARE/light_sensor_test.log | grep "Light changed" | wc -l) -lt 5 ]]; then
41+echo -e "\e[91mFAIL: Not enough data to be collect, Please rerun the test case and wave your hand around Light Sensor.\e[0m"
42+exit 1
43+fi
44+
45+
46+#Print 5 values of the Light sensor value form log file
47+for i in {1..5}
48+do
49+ echo "Ambient light sensor value " $i: `grep 'Light' $PLAINBOX_SESSION_SHARE/light_sensor_test.log | awk '{print $3}' | sed -n "$i"p`
50+done
51+exit 0
52+
53diff --git a/units/monitor/test-plan.pxu b/units/monitor/test-plan.pxu
54index aa99f3f..fd4c507 100644
55--- a/units/monitor/test-plan.pxu
56+++ b/units/monitor/test-plan.pxu
57@@ -25,6 +25,7 @@ _description:
58 Monitor tests (integrated GPU) (Manual)
59 include:
60 monitor/1_powersaving_.* certification-status=blocker
61+ power-management/light_sensor
62 monitor/1_dim_brightness_.* certification-status=blocker
63 monitor/1_displayport_.* certification-status=blocker
64 audio/1_playback_displayport_.* certification-status=blocker
65@@ -51,6 +52,7 @@ _description:
66 Monitor tests (after manual suspend, integrated GPU) (Manual)
67 include:
68 after-suspend-manual-monitor/1_powersaving_.* certification-status=blocker
69+ after-suspend-manual-power-management/light_sensor
70 after-suspend-manual-monitor/1_dim_brightness_.* certification-status=blocker
71 after-suspend-manual-monitor/1_displayport_.* certification-status=blocker
72 after-suspend-manual-audio/1_playback_displayport_.* certification-status=blocker
73@@ -99,6 +101,7 @@ _description:
74 Monitor tests (discrete GPU) (Manual)
75 include:
76 monitor/2_powersaving_.* certification-status=blocker
77+ power-management/light_sensor
78 monitor/2_dim_brightness_.* certification-status=blocker
79 monitor/2_displayport_.* certification-status=blocker
80 audio/2_playback_displayport_.* certification-status=blocker
81@@ -134,6 +137,7 @@ _description:
82 Monitor tests (after manual suspend, discrete GPU) (Manual)
83 include:
84 after-suspend-manual-monitor/2_powersaving_.* certification-status=blocker
85+ after-suspend-manual-power-management/light_sensor
86 after-suspend-manual-monitor/2_dim_brightness_.* certification-status=blocker
87 after-suspend-manual-monitor/2_displayport_.* certification-status=blocker
88 after-suspend-manual-audio/2_playback_displayport_.* certification-status=blocker
89diff --git a/units/power-management/jobs.pxu b/units/power-management/jobs.pxu
90index 904c2f0..36e31c2 100644
91--- a/units/power-management/jobs.pxu
92+++ b/units/power-management/jobs.pxu
93@@ -318,3 +318,23 @@ requires: cpuinfo.platform in ('i386', 'x86_64', 'ppc64el', 'pSeries')
94 _description: Check to see if CONFIG_NO_HZ is set in the kernel (this is just a simple regression check)
95 command:
96 zgrep 'CONFIG_NO_HZ=y' /snap/{kernel}/current/config-`uname -r` >/dev/null 2>&1 || ( echo "WARNING: Tickless Idle is NOT set" >&2 && exit 1 )
97+
98+plugin: user-interact-verify
99+category_id: com.canonical.plainbox::power-management
100+id: power-management/light_sensor
101+estimated_duration: 10.0
102+requires: dmi.product in ['Notebook','Laptop','Portable'] and executable.name == 'monitor-sensor'
103+flags: also-after-suspend-manual
104+command: light_sensor_test
105+_description:
106+_purpose:
107+ This test will check your Ambient Light Sensor work, if you don't have it, please skip this test.
108+_steps:
109+ 1. Make sure "Automatic brightness" is ON in Power settings.
110+ 2. Locate Ambient Light Sensor, should be around the Camera.
111+ 3. Cover your hand on the Ambient Light Sensor.
112+ 4. When the backlight dimmed, press Enter to start testing.
113+ 5. Wait until the message "Has ambient light sensor" is printed on the screen and wave your hand slowly during testing.
114+_verification:
115+ Did the Ambient Light Sensor values change when you shaking your hands over the sensor?
116+ Did the Screen backlight also changed?

Subscribers

People subscribed via source and target branches