ref: b2cc20febf5d8bc50eaa4d6ad03c67d6f303d77f
parent: 4d82b20a5f76a56f9dafb714de102ab43cbd18cd
author: Erik de Castro Lopo <erikd@miles>
date: Wed Aug 10 23:59:11 EDT 2005
termination_test.c : Add sanity test to check first output sample after reset.
--- a/tests/termination_test.c
+++ b/tests/termination_test.c
@@ -28,7 +28,7 @@
#define LONG_BUFFER_LEN ((1 << 16) - 20)
static void stream_test (int converter, double ratio) ;
-static void term_test (int converter, double ratio) ;
+static void init_term_test (int converter, double ratio) ;
static int next_block_length (int reset) ;
@@ -44,7 +44,7 @@
puts ("\n Zero Order Hold interpolator:") ;
for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++)
- term_test (SRC_ZERO_ORDER_HOLD, src_ratios [k]) ;
+ init_term_test (SRC_ZERO_ORDER_HOLD, src_ratios [k]) ;
puts ("") ;
for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++)
stream_test (SRC_ZERO_ORDER_HOLD, src_ratios [k]) ;
@@ -52,7 +52,7 @@
puts ("\n Linear interpolator:") ;
for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++)
- term_test (SRC_LINEAR, src_ratios [k]) ;
+ init_term_test (SRC_LINEAR, src_ratios [k]) ;
puts ("") ;
for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++)
stream_test (SRC_LINEAR, src_ratios [k]) ;
@@ -60,7 +60,7 @@
puts ("\n Sinc interpolator:") ;
for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++)
- term_test (SRC_SINC_FASTEST, src_ratios [k]) ;
+ init_term_test (SRC_SINC_FASTEST, src_ratios [k]) ;
puts ("") ;
for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++)
stream_test (SRC_SINC_FASTEST, src_ratios [k]) ;
@@ -71,14 +71,14 @@
} /* main */
static void
-term_test (int converter, double src_ratio)
+init_term_test (int converter, double src_ratio)
{ static float input [SHORT_BUFFER_LEN], output [SHORT_BUFFER_LEN] ;
SRC_DATA src_data ;
- int input_len, output_len, error, terminate ;
+ int k, input_len, output_len, error, terminate ;
- printf ("\ttermination_test (SRC ratio = %7.4f) .......... ", src_ratio) ;
+ printf ("\tinit_term_test (SRC ratio = %7.4f) .......... ", src_ratio) ;
fflush (stdout) ;
/* Calculate maximun input and output lengths. */
@@ -94,6 +94,9 @@
/* Reduce input_len by 10 so output is longer than necessary. */
input_len -= 10 ;
+ for (k = 0 ; k < ARRAY_LEN (input) ; k++)
+ input [k] = 1.0 ;
+
if (output_len > SHORT_BUFFER_LEN)
{ printf ("\n\nLine %d : output_len > SHORT_BUFFER_LEN\n\n", __LINE__) ;
exit (1) ;
@@ -132,10 +135,16 @@
exit (1) ;
} ;
+ if (fabs (output [0]) < 0.1)
+ { printf ("\n\nLine %d : First output sample is bad.\n\n", __LINE__) ;
+ printf ("\toutput [0] == %f\n\n", output [0]) ;
+ exit (1) ;
+ }
+
puts ("ok") ;
return ;
-} /* term_test */
+} /* init_term_test */
static void
stream_test (int converter, double src_ratio)