From 32b4e848aeddaf1dc57a6fbb9327df216162a410 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Fri, 26 Oct 2012 16:39:11 +0530 Subject: [PATCH] tests: Allow off-by-one error in sconv test With some optimised sconv implementations (read NEON), rounding inaccuracy might lead to a difference of 1 with the reference implementation. The inaccuracy is worth the performance gain. Also increases floating-point accuracy while printing errors to make errors easier to analyse. --- src/tests/cpu-test.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c index 3c7ad7d..dd21607 100644 --- a/src/tests/cpu-test.c +++ b/src/tests/cpu-test.c @@ -231,8 +231,8 @@ static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_func_t func(nsamples, floats, samples); for (i = 0; i < nsamples; i++) { - if (samples[i] != samples_ref[i]) { - pa_log_debug("%d: %04x != %04x (%f)\n", i, samples[i], samples_ref[i], floats[i]); + if (abs(samples[i] - samples_ref[i]) > 1) { + pa_log_debug("%d: %04x != %04x (%.24f)\n", i, samples[i], samples_ref[i], floats[i]); fail(); } } @@ -248,8 +248,6 @@ static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_func_t PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) { orig_func(nsamples, floats, samples_ref); } PA_CPU_TEST_RUN_STOP - - fail_unless(memcmp(samples_ref, samples, sizeof(nsamples)) == 0); } } @@ -277,8 +275,8 @@ static void run_conv_test_s16_to_float(pa_convert_func_t func, pa_convert_func_t func(nsamples, samples, floats); for (i = 0; i < nsamples; i++) { - if (floats[i] != floats_ref[i]) { - pa_log_debug("%d: %f != %f (%d)\n", i, floats[i], floats_ref[i], samples[i]); + if (abs(floats[i] - floats_ref[i]) > 1) { + pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]); fail(); } } @@ -294,8 +292,6 @@ static void run_conv_test_s16_to_float(pa_convert_func_t func, pa_convert_func_t PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) { orig_func(nsamples, samples, floats_ref); } PA_CPU_TEST_RUN_STOP - - fail_unless(memcmp(floats_ref, floats, nsamples * sizeof(float)) == 0); } } -- 2.7.4