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

Chris Wilson chris at chris-wilson.co.uk
Wed Sep 11 13:05:01 UTC 2019


Quoting Simon Ser (2019-09-11 14:00:24)
> 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)

eld? I don't see where you confirm that these sound cards could only be
provided by hmdi/eld. So alsa_is_supported() ?

> +{
> +       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;

C99 is not yet default.

Would strncmp be more succinct?

Principle holds,
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list