[igt-dev] [PATCH i-g-t] lib/igt_eld: introduce eld_is_supported
Simon Ser
simon.ser at intel.com
Wed Sep 11 13:00:24 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). In both of these cases, skipping the tests depending on ELD
makes more sense and makes it clearer what happens.
Signed-off-by: Simon Ser <simon.ser at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102370
---
lib/igt_eld.c | 30 ++++++++++++++++++++++++++++++
lib/igt_eld.h | 1 +
tests/kms_chamelium.c | 2 ++
tests/kms_hdmi_inject.c | 2 ++
4 files changed, 35 insertions(+)
diff --git a/lib/igt_eld.c b/lib/igt_eld.c
index 16c4ac06c6f6..8fdc6e8e8f0b 100644
--- a/lib/igt_eld.c
+++ b/lib/igt_eld.c
@@ -26,6 +26,7 @@
#include "config.h"
#include <dirent.h>
+#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -262,3 +263,32 @@ bool eld_has_igt(void)
struct eld_entry eld;
return eld_get_igt(&eld);
}
+
+/** eld_is_supported: check whether the ALSA procfs is enabled and audio cards
+ * are found */
+bool eld_is_supported(void)
+{
+ FILE *f;
+ char buf[1024];
+
+ f = fopen("/proc/asound/cards", "r");
+ if (f == NULL) {
+ if (errno == ENOENT) {
+ igt_debug("/proc/asound doesn't exist\n");
+ return false;
+ }
+ igt_assert_f(false,
+ "Failed to open /proc/asound/cards "
+ "(but the file exists)\n");
+ }
+
+ igt_assert_f(fgets(buf, sizeof(buf), f) != NULL,
+ "fgets failed\n");
+ igt_assert_f(buf[0] != '\0', "/proc/asound/cards is empty\n");
+ fclose(f);
+
+ bool has_card = strstr(buf, "no soundcards") == NULL;
+ if (!has_card)
+ igt_debug("No sound card found by ALSA\n");
+ return has_card;
+}
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