[igt-dev] [PATCH i-g-t v2] lib/igt_eld: introduce eld_is_supported

Simon Ser simon.ser at intel.com
Thu Sep 12 12:07:18 UTC 2019


We've seen cases in which /proc/asound doesn't exist (e.g. with the new SOF
framework). We've also seen cases in which no soundcard is exposed by ALSA (see
bugzilla link). Last, some audio drivers din't support ELDs (non-Intel
drivers). In all of these cases, skipping the tests depending on ELD support
makes more sense and makes it clearer what happens.

v2: also check that the driver supports ELDs entries in procfs

Signed-off-by: Simon Ser <simon.ser at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102370
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/igt_eld.c           | 17 +++++++++++++++++
 lib/igt_eld.h           |  1 +
 tests/kms_chamelium.c   |  2 ++
 tests/kms_hdmi_inject.c |  2 ++
 4 files changed, 22 insertions(+)

diff --git a/lib/igt_eld.c b/lib/igt_eld.c
index 16c4ac06c6f6..ab4307f1d289 100644
--- a/lib/igt_eld.c
+++ b/lib/igt_eld.c
@@ -26,6 +26,8 @@
 #include "config.h"

 #include <dirent.h>
+#include <errno.h>
+#include <glob.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
@@ -262,3 +264,18 @@ bool eld_has_igt(void)
 	struct eld_entry eld;
 	return eld_get_igt(&eld);
 }
+
+/** eld_is_supported: check whether the ALSA procfs is enabled, audio cards
+ * are found and ELDs are supported */
+bool eld_is_supported(void)
+{
+	glob_t glob_buf;
+	bool has_elds;
+
+	igt_assert_f(glob("/proc/asound/card*/" ELD_PREFIX "*",
+			  0, NULL, &glob_buf) == 0,
+		     "glob failed\n");
+	has_elds = glob_buf.gl_pathc > 0;
+	globfree(&glob_buf);
+	return has_elds;
+}
diff --git a/lib/igt_eld.h b/lib/igt_eld.h
index 7c4489f054f1..4b917a62cfaf 100644
--- a/lib/igt_eld.h
+++ b/lib/igt_eld.h
@@ -49,6 +49,7 @@ struct eld_entry {
 	struct eld_sad sads[ELD_SADS_CAP];
 };

+bool eld_is_supported(void);
 bool eld_get_igt(struct eld_entry *eld);
 bool eld_has_igt(void);

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index b122722a9ff4..523300980550 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -1968,6 +1968,8 @@ test_display_audio_edid(data_t *data, struct chamelium_port *port,
 	struct eld_entry eld;
 	struct eld_sad *sad;

+	igt_require(eld_is_supported());
+
 	reset_state(data, port);

 	output = prepare_output(data, port, edid);
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
index d9ab4095b8c5..1769df088bbc 100644
--- a/tests/kms_hdmi_inject.c
+++ b/tests/kms_hdmi_inject.c
@@ -142,6 +142,8 @@ hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
 	struct igt_fb fb;
 	struct kmstest_connector_config config;

+	igt_require(eld_is_supported());
+
 	edid = igt_kms_get_hdmi_audio_edid();
 	kmstest_force_edid(drm_fd, connector, edid);

--
2.23.0



More information about the igt-dev mailing list