The branch stable/14 has been updated by christos:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e922268736817e6fe8146f46093a0153af949041

commit e922268736817e6fe8146f46093a0153af949041
Author:     Florian Walpen <d...@submerge.ch>
AuthorDate: 2025-01-23 12:38:00 +0000
Commit:     Christos Margiolis <chris...@freebsd.org>
CommitDate: 2025-01-28 14:04:52 +0000

    sound tests: Fix 32bit calculation detection in pcm_read_write
    
    Fix a mistake in the pcm_read_write test that would result in not
    properly detecting 32bit calculation on 32bit architectures like i386.
    As a consequence, the wrong values would be checked, thus failing the
    test.
    
    Reported by:    CI
    Fixes:          27ef5d48c729 ("sound: Unit test the pcm sample read and 
write macros")
    MFC after:      1 week
    Reviewed by:    christos
    Differential Revision:  https://reviews.freebsd.org/D48617
    
    (cherry picked from commit e02b579b537998495b06d02be6aa07f03db3a42a)
---
 tests/sys/sound/pcm_read_write.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/sys/sound/pcm_read_write.c b/tests/sys/sound/pcm_read_write.c
index e40ce52b67cc..7ef310a35c25 100644
--- a/tests/sys/sound/pcm_read_write.c
+++ b/tests/sys/sound/pcm_read_write.c
@@ -95,8 +95,14 @@ local_normalize(intpcm_t value, int val_bits, int norm_bits)
 static intpcm_t
 local_calc_limit(intpcm_t value, int val_bits)
 {
-       /* Avoid implementation defined behavior. */
-       if (sizeof(intpcm32_t) == 32 && val_bits == 32)
+       /*
+        * When intpcm32_t is defined to be 32bit, calculations for mixing and
+        * volume changes use 32bit integers instead of 64bit. To get some
+        * headroom for calculations, 32bit sample values are restricted to
+        * 24bit magnitude in that case. Also avoid implementation defined
+        * behavior here.
+        */
+       if (sizeof(intpcm32_t) == (32 / 8) && val_bits == 32)
                /* Divide instead of right shift (value may be negative). */
                return (value / (1 << 8));
        return value;
@@ -456,7 +462,7 @@ ATF_TC_BODY(pcm_write, tc)
                }
                local_pcm_write_calc(dst, value, test->format);
                ATF_CHECK_MSG(memcmp(dst, expected, sizeof(dst)) == 0,
-                   "pcm_write[\"%s\"].value: "
+                   "pcm_write[\"%s\"].calc: "
                    "expected={0x%02x, 0x%02x, 0x%02x, 0x%02x}, "
                    "result={0x%02x, 0x%02x, 0x%02x, 0x%02x}, ", test->label,
                    expected[0], expected[1], expected[2], expected[3],

Reply via email to