Skip to contentSkip to conversation

selftest: alsa: check if user has alsa installed

PATCH In review Abdul Rahim 3 participants 3 messages Sep 22, 2024 – Sep 30, 2024 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 selftest: alsa: check if user has alsa installed

Currently, if alsa development package is not installed on the user's system then the make command would print a pagefull of errors. In particular one error message is repeated 3 times. This error is returned by pkg-config and since it is not being handeled appropriately, repeated calls to pkg-config prints the same message again.

This patch adds check for alsa package installation. If alsa is not installed, a short and consize error is returned. Also, it does not affect the compilation of other tests.

---

Current output:

```
make[3]: Entering directory '/mnt/ubuntu/abdul_linux/mainline_dev/tools/testing/selftests/alsa'
Makefile:4: *** Package alsa not found, please install alsa development package or add directory containing `alsa.pc` in PKG_CONFIG_PATH.  Stop.
make[3]: Leaving directory '/mnt/ubuntu/abdul_linux/mainline_dev/tools/testing/selftests/alsa'
make[3]: Entering directory '/mnt/ubuntu/abdul_linux/mainline_dev/tools/testing/selftests/amd-pstate'
```

Previous output:

```
make[3]: Entering directory '/mnt/ubuntu/abdul_linux/mainline_compile/tools/testing/selftests/alsa'
Package alsa was not found in the pkg-config search path.
Perhaps you should add the directory containing `alsa.pc'
to the PKG_CONFIG_PATH environment variable
Package 'alsa', required by 'virtual:world', not found
Package alsa was not found in the pkg-config search path.
Perhaps you should add the directory containing `alsa.pc'
to the PKG_CONFIG_PATH environment variable
Package 'alsa', required by 'virtual:world', not found
Package alsa was not found in the pkg-config search path.
Perhaps you should add the directory containing `alsa.pc'
to the PKG_CONFIG_PATH environment variable
Package 'alsa', required by 'virtual:world', not found
gcc  -isystem /mnt/ubuntu/abdul_linux/mainline_compile/usr/include -L/mnt/ubuntu/abdul_linux/mainline_compile/tools/testing/selftests/alsa       -Wl,-rpath=./ -D_GNU_SOURCE=  -shared -fPIC conf.c  -lasound -lpthread -o /mnt/ubuntu/abdul_linux/mainline_compile/tools/testing/selftests/      alsa/libatest.so
In file included from conf.c:18:
alsa-local.h:11:10: fatal error: alsa/asoundlib.h: No such file or directory
   11 | #include <alsa/asoundlib.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:24: /mnt/ubuntu/abdul_linux/mainline_compile/tools/testing/selftests/alsa/libatest.so] Error 1
```
 tools/testing/selftests/alsa/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
tools/testing/selftests/alsa/Makefile +4 -0
index 25be68025290..944279160fed 100644
@@ -1,5 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
 #
+ifneq ($(shell pkg-config --exists alsa && echo 0 || echo 1),0)
+$(error Package alsa not found, please install alsa development package or \
+	add directory containing `alsa.pc` in PKG_CONFIG_PATH)
+endif
 
 CFLAGS += $(shell pkg-config --cflags alsa) $(KHDR_INCLUDES)
 LDLIBS += $(shell pkg-config --libs alsa)
Signature · 1 line
2.46.0
maintainer Reviewed-by on v1 1/1
#2 lore raw
Quoted 13 lines · Abdul Rahim

Currently, if alsa development package is not installed on the user's system then the make command would print a pagefull of errors. In particular one error message is repeated 3 times. This error is returned by pkg-config and since it is not being handeled appropriately, repeated calls to pkg-config prints the same message again.

This patch adds check for alsa package installation. If alsa is not installed, a short and consize error is returned. Also, it does not affect the compilation of other tests.

---

[snip]

Quoted 10 lines

```

  tools/testing/selftests/alsa/Makefile | 4 ++++
  1 file changed, 4 insertions(+)
tools/testing/selftests/alsa/Makefile +0 -0
index 25be68025290..944279160fed 100644

tools/testing/selftests/alsa/Makefile line 9

Quoted 9 lines
tools/testing/selftests/alsa/Makefile +4 -0
@@ -1,5 +1,9 @@
  # SPDX-License-Identifier: GPL-2.0
  #
+ifneq ($(shell pkg-config --exists alsa && echo 0 || echo 1),0)
+$(error Package alsa not found, please install alsa development package or \
+	add directory containing `alsa.pc` in PKG_CONFIG_PATH)
+endif
 
  CFLAGS += $(shell pkg-config --cflags alsa) $(KHDR_INCLUDES)
  LDLIBS += $(shell pkg-config --libs alsa)

thanks,
-- Shuah

#3 lore raw
In reply to Abdul Rahim
Quoted 7 lines · Abdul Rahim

Currently, if alsa development package is not installed on the user's system then the make command would print a pagefull of errors. In particular one error message is repeated 3 times. This error is returned by pkg-config and since it is not being handeled appropriately, repeated calls to pkg-config prints the same message again.

Quoted 5 lines

This patch adds check for alsa package installation. If alsa is not installed, a short and consize error is returned. Also, it does not affect the compilation of other tests.

Sorry for the late reply, as I've been off in the last weeks.

Now applied to for-linus branch. Thanks.

Takashi