Skip to contentSkip to conversation

alsa-lib: Add ptest

PATCH In review Sana Kazi 2 participants 2 messages Sep 21 – Oct 1

lore
Share & tools
lore

Sana Kazi

author
#0 lore raw

PATCH v2 1/1 alsa-lib: Add ptest

From: Sana Kazi <[email protected]>

alsa-lib is a user space library that provides audio and MIDI functionality apis for simplifying application programming and provide higher level functionality

ptest executes below binaries on target:
1.config
2.control
3.client_event_filter
4.midi_event

The following changes are introduced:

- Add the required include path to CFLAGS to resolve:

fatal error: alsa/asoundlib.h: No such file or directory

- Remove the test suite execution "make" call using sed to avoid executing tests during the build.

- Build the test sources using:
oe_runmake check

- Install the generated test binaries through do_install_ptest().

---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../alsa/alsa-lib/run-ptest                   | 14 +++++++++++
 .../alsa/alsa-lib_1.2.16.1.bb                 | 24 +++++++++++++++++--
 3 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-multimedia/alsa/alsa-lib/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
index 4012be5f49..b525f6e3a9 100644
@@ -5,6 +5,7 @@
 #
 PTESTS_FAST = "\
     acl \
+    alsa-lib \
     apr-util \
     attr \
     babeltrace2 \
meta/recipes-multimedia/alsa/alsa-lib/run-ptest new file +14 -0
new file mode 100644
index 0000000000..f6d3ac23df
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -eux
+
+for t in config control midi_event client_event_filter
+do
+    if "./$t" > "alsa-lib_$t.log" 2>&1
+    then
+        echo "PASS: $t"
+    else
+        echo "FAIL: $t"
+        cat "alsa-lib_$t.log"
+    fi
+    rm "alsa-lib_$t.log"
+done
meta/recipes-multimedia/alsa/alsa-lib_1.2.16.1.bb +22 -2
index 1033250204..fa682f31a4 100644
@@ -9,10 +9,12 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=a916467b91076e631dd8edb7424769c7 \
                     file://src/socket.c;md5=285675b45e83f571c6a957fe4ab79c93;beginline=9;endline=24 \
                     "
 
-SRC_URI = "https://www.alsa-project.org/files/pub/lib/${BP}.tar.bz2"
+SRC_URI = "https://www.alsa-project.org/files/pub/lib/${BP}.tar.bz2 \
+           file://run-ptest \
+           "
 SRC_URI[sha256sum] = "f740db7f488255944ffd4428416ee3390a96742856916433df468c281436480e"
 
-inherit autotools pkgconfig
+inherit autotools pkgconfig ptest
 
 EXTRA_OECONF += " \
     ${@bb.utils.contains('TARGET_FPU', 'soft', '--with-softfloat', '', d)} \
@@ -41,4 +43,22 @@ RPROVIDES:alsa-conf = "alsa-conf-base"
 RREPLACES:alsa-conf = "alsa-conf-base"
 RCONFLICTS:alsa-conf = "alsa-conf-base"
 
+EXTRA_OEMAKE:append = " AM_CPPFLAGS=-I${S}/include"
+
+do_compile:append() {
+        sed -i 's/^.*$(MAKE) $(AM_MAKEFLAGS) check-TESTS.*$/ /' ${S}/test/lsb/Makefile.in
+        oe_runmake check
+}
+
+do_install_ptest:append() {
+    for f in control client_event_filter namehint
+    do
+        install -m 0755 "${B}/test/.libs/$f" "${D}${PTEST_PATH}";
+    done
+
+    for f in config midi_event
+    do
+        install -m 0755 "${B}/test/lsb/.libs/$f" "${D}${PTEST_PATH}";
+    done
+}
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0
#1 lore raw
Quoted 1 line · Sana Kazi via lists.openembedded.org

+set -eux

Why -x?

Quoted 1 line

+for t in config control midi_event client_event_filter

Hardcoded list. Either put the binaries in a directory so you can just glob them, or sed the list in from the recipe.

Quoted 1 line

+EXTRA_OEMAKE:append = " AM_CPPFLAGS=-I${S}/include"

Might be neater, as this is ptest-specific, to pass this do_compile_ptest.

Quoted 1 line

+do_compile:append() {

This should be do_compile_ptest.

Quoted 1 line

+ sed -i 's/^.*$(MAKE) $(AM_MAKEFLAGS) check-TESTS.*$/ /' ${S}/test/lsb/Makefile.in

Explain this sed with a small comment.

Quoted 1 line

+ oe_runmake check

We patch into automake a "buildtest-TESTS” that just builds the tests, use that instead.

meta/recipes-multimedia/alsa/alsa-lib_1.2.16.1.bb RPROVIDES:alsa-conf = "alsa-conf-base" · line 54

Quoted 2 lines
meta/recipes-multimedia/alsa/alsa-lib_1.2.16.1.bb +2 -0
+do_install_ptest:append() {
+    for f in control client_event_filter namehint

Hard-coded list. You can use makefile-getvar to retrieve the list of tests, unless you explictly want this subset. If you do want an explicit subset then you definitely don’t want to replicate it.

meta/recipes-multimedia/alsa/alsa-lib_1.2.16.1.bb RPROVIDES:alsa-conf = "alsa-conf-base" · line 63

Quoted 9 lines
meta/recipes-multimedia/alsa/alsa-lib_1.2.16.1.bb +9 -0
+    do
+        install -m 0755 "${B}/test/.libs/$f" "${D}${PTEST_PATH}";
+    done
+
+    for f in config midi_event
+    do
+        install -m 0755 "${B}/test/lsb/.libs/$f" "${D}${PTEST_PATH}";
+    done
+}

Don’t install libtool generated binaries by assuming you know where the real binary is. Instead, use "libtool —mode=install install ${B}/test/$f …”. There are plenty of examples in oe-core.

Ross