sound_infrastructure: Skip checking record device on some boards

Refactor the test so it supports board that does not have playback or
record sound device by design.

BUG=chromium:622187
TEST=test_that --fast <veyron_mickey IP> "Sound System Validation"

Change-Id: Ica5c021e6f619802db3717dbfada613ddc777d7f
Reviewed-on: https://chromium-review.googlesource.com/355760
Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
diff --git a/client/tests/sound_infrastructure/sound_infrastructure.py b/client/tests/sound_infrastructure/sound_infrastructure.py
index 0722a78..dc8ccf2 100644
--- a/client/tests/sound_infrastructure/sound_infrastructure.py
+++ b/client/tests/sound_infrastructure/sound_infrastructure.py
@@ -9,6 +9,7 @@
 
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import test
+from autotest_lib.client.bin import utils
 
 _SND_DEV_DIR = '/dev/snd/'
 
@@ -21,6 +22,7 @@
 
     """
     version = 2
+    _NO_RECORDER_BOARDS_LIST = ['veyron_mickey', 'veyron_rialto']
 
     def check_snd_dev_perms(self, filename):
         desired_mode = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP |
@@ -29,10 +31,20 @@
         if (st.st_mode != desired_mode):
             raise error.TestError("Incorrect permissions for %s" % filename)
 
-    def check_sound_files(self):
-        patterns = {'^controlC(\d+)': False,
-                    '^pcmC(\d+)D(\d+)p$': False,
-                    '^pcmC(\d+)D(\d+)c$': False}
+    def check_sound_files(self, playback=True, record=True):
+        """Checks sound files present in snd directory.
+
+        @param playback: Checks playback device.
+        @param record: Checks record device.
+
+        @raises: error.TestError if sound file is missing.
+
+        """
+        patterns = {'^controlC(\d+)': False}
+        if playback:
+            patterns['^pcmC(\d+)D(\d+)p$'] = False
+        if record:
+            patterns['^pcmC(\d+)D(\d+)c$'] = False
 
         filenames = os.listdir(_SND_DEV_DIR)
 
@@ -46,19 +58,31 @@
             if not patterns[pattern]:
                 raise error.TestError("Missing device %s" % pattern)
 
-    def check_aplay_list(self):
+    def check_device_list(self, playback=True, record=True):
+        """Checks sound card and device list by alsa utils command.
+
+        @param playback: Checks playback sound card and devices.
+        @param record: Checks record sound card and devices.
+
+        @raises: error.TestError if no playback/record devices found.
+
+        """
         no_cards_pattern = '.*no soundcards found.*'
+        if playback:
+            aplay = subprocess.Popen(["aplay", "-l"], stderr=subprocess.PIPE)
+            aplay_list = aplay.communicate()[1]
+            if aplay.returncode or re.match(no_cards_pattern, aplay_list):
+                raise error.TestError("No playback devices found by aplay")
 
-        aplay = subprocess.Popen(["aplay", "-l"], stderr=subprocess.PIPE)
-        aplay_list = aplay.communicate()[1]
-        if aplay.returncode or re.match(no_cards_pattern, aplay_list):
-            raise error.TestError("No playback devices found by aplay")
-
-        arecord = subprocess.Popen(["arecord", "-l"], stderr=subprocess.PIPE)
-        arecord_list = arecord.communicate()[1]
-        if arecord.returncode or re.match(no_cards_pattern, arecord_list):
-            raise error.TestError("No playback devices found by arecord")
+        if record:
+            no_cards_pattern = '.*no soundcards found.*'
+            arecord = subprocess.Popen(
+                    ["arecord", "-l"], stderr=subprocess.PIPE)
+            arecord_list = arecord.communicate()[1]
+            if arecord.returncode or re.match(no_cards_pattern, arecord_list):
+                raise error.TestError("No record devices found by arecord")
 
     def run_once(self):
-        self.check_sound_files()
-        self.check_aplay_list()
+        record = utils.get_board().lower() not in self._NO_RECORDER_BOARDS_LIST
+        self.check_sound_files(True, record)
+        self.check_device_list(True, record)