Merge lp:~pieq/checkbox/fix-1595380 into lp:checkbox

Proposed by Pierre Equoy
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 4409
Merged at revision: 4409
Proposed branch: lp:~pieq/checkbox/fix-1595380
Merge into: lp:checkbox
Diff against target: 44 lines (+17/-2)
2 files modified
checkbox-support/checkbox_support/scripts/audio_settings.py (+1/-1)
checkbox-support/checkbox_support/scripts/tests/test_audio_settings.py (+16/-1)
To merge this branch: bzr merge lp:~pieq/checkbox/fix-1595380
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+298210@code.launchpad.net

Description of the change

checkbox-support: Adapt audio_settings script to Xenial

We use `pactl` output to store and restore several audio values, such as the volume. Unfortunately, `pactl` output format changes from one release to another. The version shipped with Xenial was breaking out scripts and some of our audio jobs, resulting in false positive issues when performing QA testing.

This commit fixes this while remaining compatible with the `pactl` versionshipping with Trusty.

To test, you can, on Xenial, run the audio jobs that call audio_settings to store and restore the volume (e.g. audio/playback_auto, audio/playback_headphones, audio/{index}_playback_hdmi_{product_slug} ... )

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

+1 for the fix and +1 for the additional unit tests.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-support/checkbox_support/scripts/audio_settings.py'
2--- checkbox-support/checkbox_support/scripts/audio_settings.py 2015-09-02 04:01:31 +0000
3+++ checkbox-support/checkbox_support/scripts/audio_settings.py 2016-06-23 10:18:24 +0000
4@@ -38,7 +38,7 @@
5 default_pattern = "(?<=Default %s: ).*"
6 index_regex = re.compile("(?<=index: )[0-9]*")
7 muted_regex = re.compile("(?<=Mute: ).*")
8-volume_regex = re.compile("Volume: (?:0|front-left):\s*([0-9]*)")
9+volume_regex = re.compile("Volume: (?:0|front-left):[\s\/0-9]*\s([0-9]*)")
10 name_regex = re.compile("(?<=Name:).*")
11
12 entry_pattern = "Name: %s.*?(?=Properties)"
13
14=== modified file 'checkbox-support/checkbox_support/scripts/tests/test_audio_settings.py'
15--- checkbox-support/checkbox_support/scripts/tests/test_audio_settings.py 2014-05-20 18:54:24 +0000
16+++ checkbox-support/checkbox_support/scripts/tests/test_audio_settings.py 2016-06-23 10:18:24 +0000
17@@ -24,7 +24,7 @@
18 import os
19 import unittest
20
21-from checkbox_support.scripts.audio_settings import _guess_hdmi_profile
22+from checkbox_support.scripts.audio_settings import _guess_hdmi_profile, volume_regex
23 from checkbox_support.parsers.tests.test_pactl import PactlDataMixIn
24
25
26@@ -154,3 +154,18 @@
27 _guess_hdmi_profile(self.get_text(
28 "desktop-raring-t430s-dp-available")),
29 ('2', 'output:hdmi-stereo'))
30+
31+class RegexTest(unittest.TestCase):
32+
33+ def test_volume_regex_trusty(self):
34+ """Testing pactl 4.0 output"""
35+ pactl_volume = " Volume: 0: 47% 1: 47%"
36+ volume = int(volume_regex.search(pactl_volume).group(1).strip())
37+ self.assertEqual(volume, 47)
38+
39+ def test_volume_regex_xenial(self):
40+ """Testing pactl 8.0 output"""
41+ # See lp:1595380 for more info
42+ pactl_volume = " Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB"
43+ volume = int(volume_regex.search(pactl_volume).group(1).strip())
44+ self.assertEqual(volume, 100)

Subscribers

People subscribed via source and target branches