Skip to contentSkip to conversation

libsamplerate0: Adding ptest for libsamplerate0

PATCH In review Shaik Moin 2 participants 2 messages Mar 23 – Mar 26

lore
Share & tools
lore

Shaik Moin

author
#0 lore raw

PATCH v2 1/1 libsamplerate0: Adding ptest for libsamplerate0

Executables Description:
callback_hang_test - Verifies that callback-based processing does not hang and that the library properly returns control without deadlocks.
callback_test - Tests the callback-driven processing mode of libsamplerate (SRC's non-blocking interface).
clone_test - Ensures the SRC state objects can be cloned correctly and continue producing identical output.
downsample_test - Tests accuracy and behavior when downsampling audio (reducing sample rate).
float_short_test - Tests conversions between float and short integer sample formats.
misc_test - Runs assorted sanity and utility tests that don't fit into other categories.
multi_channel_test - Verifies correct handling of multi-channel audio (e.g., stereo, 5.1) during sample-rate conversion.
multichan_throughput_test - Measures throughput and performance for multi-channel SRC processing.
nullptr_test - Ensures libsamplerate properly rejects or handles NULL pointers and invalid state.
reset_test - Tests the reset() behavior - state clearing, flushing buffers, resetting filters.
simple_test - The most basic test of sample-rate conversion functionality - often converting a small buffer to ensure fundamental correctness.
snr_bw_test - Measures Signal - Noise Ratio (SNR) and bandwidth performance for different converter algorithms.
src-evaluate - Evaluates internal SRC filter performance, quality, and algorithmic behavior.
termination_test - Ensures end - stream / termination behavior is handled correctly without artifacts or crashes.
throughput_test - Benchmarks throughput for mono or simple use cases to measure raw processing speed.
varispeed_test - Tests variable sample-rate operation (changing SRC ratio on the fly).

Time taken to execute the ptest:- Approx ~3 mins

---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../libsamplerate/files/run-ptest             | 51 +++++++++++++++++++
 .../libsamplerate/libsamplerate0_0.2.2.bb     | 34 ++++++++++++-
 3 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-multimedia/libsamplerate/files/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
index d0c2c2816c..bf1605e78b 100644
@@ -127,6 +127,7 @@ PTESTS_SLOW = "\
     libmodule-build-perl \
     libpng \
     ${@bb.utils.contains('DISTRO_FEATURES', 'seccomp', 'libseccomp', '',d)} \
+    libsamplerate0 \
     lttng-tools \
     lz4 \
     openssh \
meta/recipes-multimedia/libsamplerate/files/run-ptest new file +51 -0

51 lines not on this page · raw message

meta/recipes-multimedia/libsamplerate/libsamplerate0_0.2.2.bb +33 -1
index 819096878b..8a0fe4e108 100644
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=336d6faf40fb600bafb0061f4052f1f4 \
 DEPENDS = "libsndfile1"
 
 SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/libsamplerate-${PV}.tar.xz \
+           file://run-ptest \
 "
 
 SRC_URI[sha256sum] = "3258da280511d24b49d6b08615bbe824d0cacc9842b0e4caf11c52cf2b043893"
@@ -18,9 +19,40 @@ GITHUB_BASE_URI = "https://github.com/libsndfile/libsamplerate/releases"
 
 S = "${UNPACKDIR}/libsamplerate-${PV}"
 
-inherit autotools pkgconfig github-releases
+inherit autotools pkgconfig github-releases ptest
 
 # FFTW and ALSA are only used in tests and examples, so they don't affect
 # normal builds. It should be safe to ignore these, but explicitly disabling
 # them adds some extra certainty that builds are deterministic.
 EXTRA_OECONF = "--disable-fftw --disable-alsa"
+do_compile:append() {
+    oe_runmake buildtest-TESTS
+}
+
+do_install_ptest() {
+    t=${D}${PTEST_PATH}
+
+    #    This lets libtool do any needed relinking and install the right binary.
+    if [ -x "${B}/libtool" ] && [ -d "${B}/tests" ]; then
+        find "${B}/tests" -maxdepth 1 -type f -perm -111 2>/dev/null \
+        | while IFS= read -r wrapper; do
+            bn=$(basename "$wrapper")
+            case "$bn" in
+                *.a|*.la|*.o|*.lo|*.la~) continue ;;
+            esac
+            [ -e "$t/$bn" ] && continue
+            # Install via libtool using the wrapper
+            "${B}/libtool" --mode=install install -c "$wrapper" "$t/$bn"
+        done
+    fi
+
+    #    install them directly.
+    if [ -d "${B}/tests/.libs" ]; then
+        find "${B}/tests/.libs" -maxdepth 1 -type f -perm -111 2>/dev/null \
+        | while IFS= read -r realbin; do
+            bn=$(basename "$realbin")
+            [ -e "$t/$bn" ] && continue
+            install -m 0755 "$realbin" "$t/$bn"
+        done
+    fi
+}
Signature · 1 line
2.34.1
#1 lore raw

Hi,

Quoted 1 line · Shaik Moin via lists.openembedded.org

First, your From address doesn’t match your Signed-off-by and isn’t obviously your address. If you have problems sending email from your @kpit.com address then I suggest you look at using b4 send instead: this lets you post patches without having to actually send email.

Quoted 5 lines
meta/recipes-multimedia/libsamplerate/files/run-ptest new file +5 -0
+find "$DIR" -maxdepth 1 -type f -perm -u+x 2>/dev/null \
+  ! -name run-ptest \
+  ! -name ".*" \
+| sed 's|^\./||' \
+| LC_ALL=C sort > "$list_tmp"

meta/recipes-multimedia/libsamplerate/files/run-ptest line 27

Quoted 10 lines
meta/recipes-multimedia/libsamplerate/files/run-ptest new file +10 -0
+
+echo "----- Executables are:-----"
+if [ -s "$list_tmp" ]; then
+    cat "$list_tmp"
+else
+    echo "(none)"
+fi
+echo "----------------------------------------------"
+
+while IFS= read -r T; do

If you just put the test binaries into a subdirectory, you can just iterate over them without needing ten lines of complex logic.

Quoted 17 lines
meta/recipes-multimedia/libsamplerate/libsamplerate0_0.2.2.bb +17 -0
+do_install_ptest() {
+    t=${D}${PTEST_PATH}
+
+    #    This lets libtool do any needed relinking and install the right binary.
+    if [ -x "${B}/libtool" ] && [ -d "${B}/tests" ]; then
+        find "${B}/tests" -maxdepth 1 -type f -perm -111 2>/dev/null \
+        | while IFS= read -r wrapper; do
+            bn=$(basename "$wrapper")
+            case "$bn" in
+                *.a|*.la|*.o|*.lo|*.la~) continue ;;
+            esac
+            [ -e "$t/$bn" ] && continue
+            # Install via libtool using the wrapper
+            "${B}/libtool" --mode=install install -c "$wrapper" "$t/$bn"
+        done
+    fi
+

meta/recipes-multimedia/libsamplerate/libsamplerate0_0.2.2.bb GITHUB_BASE_URI = "https://github.com/libsndfile/libsamplerate/releases" · line 58

Quoted 10 lines
meta/recipes-multimedia/libsamplerate/libsamplerate0_0.2.2.bb +10 -0
+    #    install them directly.
+    if [ -d "${B}/tests/.libs" ]; then
+        find "${B}/tests/.libs" -maxdepth 1 -type f -perm -111 2>/dev/null \
+        | while IFS= read -r realbin; do
+            bn=$(basename "$realbin")
+            [ -e "$t/$bn" ] && continue
+            install -m 0755 "$realbin" "$t/$bn"
+        done
+    fi
+}

Why is there a block for if libsamplerate0 was built without libtool, but also assumes the libtool directory structure? That makes no sense.

Instead of complex find/while/read loops you can just do something like:

for t in $(makefile-getvar ${B}/Makefile TESTS); do
${B}/libtool —mode=install install ${B}/$t ${D}${PTEST_DIR}/$(basename $t)
done

(makefile-getvar is a utility in oe-core/scripts to get the value of a makefile variable)

Ross