Test cleanups and renaming.
authorGregory Maxwell <greg@xiph.org>
Thu, 27 Oct 2011 03:55:33 +0000 (23:55 -0400)
committerGregory Maxwell <greg@xiph.org>
Thu, 27 Oct 2011 10:27:13 +0000 (06:27 -0400)
Build tests in the tests/ directory instead of top, cleanup, rename,
and eliminate recursive make for the celt/ unit tests.

12 files changed:
Makefile.am
celt/tests/Makefile.am [deleted file]
celt/tests/real-fft-test.c [deleted file]
celt/tests/test_unit_cwrs32.c [moved from celt/tests/cwrs32-test.c with 96% similarity]
celt/tests/test_unit_dft.c [moved from celt/tests/dft-test.c with 95% similarity]
celt/tests/test_unit_entropy.c [moved from celt/tests/ectest.c with 99% similarity]
celt/tests/test_unit_laplace.c [moved from celt/tests/laplace-test.c with 89% similarity]
celt/tests/test_unit_mathops.c [moved from celt/tests/mathops-test.c with 100% similarity]
celt/tests/test_unit_mdct.c [moved from celt/tests/mdct-test.c with 96% similarity]
celt/tests/test_unit_rotation.c [moved from celt/tests/rotation-test.c with 100% similarity]
celt/tests/test_unit_types.c [moved from celt/tests/type-test.c with 100% similarity]
configure.ac

index 056d447..6e9f3d5 100644 (file)
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 lib_LTLIBRARIES = libopus.la
 
-SUBDIRS = . celt/tests doc
+SUBDIRS = . doc
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/celt -I$(top_srcdir)/silk -I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed
 
@@ -26,9 +26,9 @@ pkginclude_HEADERS = include/opus.h include/opus_multistream.h include/opus_type
 
 noinst_HEADERS = $(OPUS_HEAD) $(SILK_HEAD) $(CELT_HEAD)
 
-noinst_PROGRAMS = opus_demo repacketizer_demo opus_compare test_opus_api test_opus_encode test_opus_decode
+noinst_PROGRAMS = opus_demo repacketizer_demo opus_compare tests/test_opus_api tests/test_opus_encode tests/test_opus_decode celt/tests/test_unit_cwrs32 celt/tests/test_unit_dft celt/tests/test_unit_entropy celt/tests/test_unit_laplace celt/tests/test_unit_mathops celt/tests/test_unit_mdct celt/tests/test_unit_rotation celt/tests/test_unit_types
 
-TESTS = test_opus_api test_opus_decode test_opus_encode
+TESTS = celt/tests/test_unit_types celt/tests/test_unit_mathops celt/tests/test_unit_entropy celt/tests/test_unit_laplace celt/tests/test_unit_dft celt/tests/test_unit_mdct celt/tests/test_unit_rotation celt/tests/test_unit_cwrs32 tests/test_opus_api tests/test_opus_decode tests/test_opus_encode
 
 opus_demo_SOURCES = src/opus_demo.c
 
@@ -41,14 +41,38 @@ repacketizer_demo_LDADD = libopus.la -lm
 opus_compare_SOURCES = src/opus_compare.c
 opus_compare_LDADD = -lm
 
-test_opus_api_SOURCES = tests/test_opus_api.c tests/test_opus_common.h
-test_opus_api_LDADD = libopus.la -lm
+tests_test_opus_api_SOURCES = tests/test_opus_api.c tests/test_opus_common.h
+tests_test_opus_api_LDADD = libopus.la -lm
 
-test_opus_encode_SOURCES = tests/test_opus_encode.c tests/test_opus_common.h
-test_opus_encode_LDADD = libopus.la -lm
+tests_test_opus_encode_SOURCES = tests/test_opus_encode.c tests/test_opus_common.h
+tests_test_opus_encode_LDADD = libopus.la -lm
 
-test_opus_decode_SOURCES = tests/test_opus_decode.c tests/test_opus_common.h
-test_opus_decode_LDADD = libopus.la -lm
+tests_test_opus_decode_SOURCES = tests/test_opus_decode.c tests/test_opus_common.h
+tests_test_opus_decode_LDADD = libopus.la -lm
+
+celt_tests_test_unit_cwrs32_SOURCES = celt/tests/test_unit_cwrs32.c
+celt_tests_test_unit_cwrs32_LDADD = -lm
+
+celt_tests_test_unit_dft_SOURCES = celt/tests/test_unit_dft.c
+celt_tests_test_unit_dft_LDADD = -lm
+
+celt_tests_test_unit_entropy_SOURCES = celt/tests/test_unit_entropy.c
+celt_tests_test_unit_entropy_LDADD = -lm
+
+celt_tests_test_unit_laplace_SOURCES = celt/tests/test_unit_laplace.c
+celt_tests_test_unit_laplace_LDADD = -lm
+
+celt_tests_test_unit_mathops_SOURCES = celt/tests/test_unit_mathops.c
+celt_tests_test_unit_mathops_LDADD = -lm
+
+celt_tests_test_unit_mdct_SOURCES = celt/tests/test_unit_mdct.c
+celt_tests_test_unit_mdct_LDADD = -lm
+
+celt_tests_test_unit_rotation_SOURCES = celt/tests/test_unit_rotation.c
+celt_tests_test_unit_rotation_LDADD = -lm
+
+celt_tests_test_unit_types_SOURCES = celt/tests/test_unit_types.c
+celt_tests_test_unit_types_LDADD = -lm
 
 if CUSTOM_MODES
 pkginclude_HEADERS += include/opus_custom.h
diff --git a/celt/tests/Makefile.am b/celt/tests/Makefile.am
deleted file mode 100644 (file)
index 0dfdfd9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/celt
-METASOURCES = AUTO
-
-TESTS = type-test ectest cwrs32-test dft-test laplace-test mdct-test mathops-test rotation-test
-
-noinst_PROGRAMS = type-test ectest cwrs32-test dft-test laplace-test mdct-test mathops-test rotation-test
-
-type_test_SOURCES = type-test.c
-ectest_SOURCES = ectest.c
-cwrs32_test_SOURCES = cwrs32-test.c
-dft_test_SOURCES = dft-test.c
-laplace_test_SOURCES = laplace-test.c
-mdct_test_SOURCES = mdct-test.c
-mathops_test_SOURCES = mathops-test.c
-rotation_test_SOURCES = rotation-test.c
diff --git a/celt/tests/real-fft-test.c b/celt/tests/real-fft-test.c
deleted file mode 100644 (file)
index 3f3f7b2..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "kiss_fftr.h"
-#include "_kiss_fft_guts.h"
-#include <stdio.h>
-#include <string.h>
-
-#define CELT_C
-#include "../celt/stack_alloc.h"
-#include "../celt/kiss_fft.c"
-#include "../celt/kiss_fftr.c"
-
-#ifdef FIXED_DEBUG
-long long celt_mips=0;
-#endif
-int ret=0;
-
-static
-kiss_fft_scalar rand_scalar(void)
-{
-    return (rand()%32767)-16384;
-}
-
-static
-double snr_compare( kiss_fft_cpx * vec1,kiss_fft_scalar * vec2, int n)
-{
-    int k;
-    double sigpow=1e-10, noisepow=1e-10, err,snr;
-
-    vec1[0].i = vec1[n].r;
-    for (k=0;k<n;++k) {
-        sigpow += (double)vec1[k].r * (double)vec1[k].r +
-                  (double)vec1[k].i * (double)vec1[k].i;
-        err = (double)vec1[k].r - (double)vec2[2*k];
-        /*printf ("%f %f\n", (double)vec1[k].r, (double)vec2[2*k]);*/
-        noisepow += err * err;
-        err = (double)vec1[k].i - (double)vec2[2*k+1];
-        /*printf ("%f %f\n", (double)vec1[k].i, (double)vec2[2*k+1]);*/
-        noisepow += err * err;
-
-    }
-    snr = 10*log10( sigpow / noisepow );
-    if (snr<60) {
-        printf( "** poor snr: %f **\n", snr);
-        ret = 1;
-    }
-    return snr;
-}
-
-static
-double snr_compare_scal( kiss_fft_scalar * vec1,kiss_fft_scalar * vec2, int n)
-{
-    int k;
-    double sigpow=1e-10, noisepow=1e-10, err,snr;
-
-    for (k=0;k<n;++k) {
-        sigpow += (double)vec1[k] * (double)vec1[k];
-        err = (double)vec1[k] - (double)vec2[k];
-        noisepow += err * err;
-    }
-    snr = 10*log10( sigpow / noisepow );
-    if (snr<60) {
-        printf( "\npoor snr: %f\n", snr);
-        ret = 1;
-    }
-    return snr;
-}
-#ifdef RADIX_TWO_ONLY
-#define NFFT 1024
-#else
-#define NFFT 8*3*5
-#endif
-
-#ifndef NUMFFTS
-#define NUMFFTS 10000
-#endif
-
-
-int main(void)
-{
-    int i;
-    kiss_fft_cpx cin[NFFT];
-    kiss_fft_cpx cout[NFFT];
-    kiss_fft_scalar fin[NFFT];
-    kiss_fft_scalar sout[NFFT];
-    kiss_fft_cfg  kiss_fft_state;
-    kiss_fftr_cfg  kiss_fftr_state;
-
-    kiss_fft_scalar rin[NFFT+2];
-    kiss_fft_scalar rout[NFFT+2];
-    kiss_fft_scalar zero;
-    ALLOC_STACK;
-    memset(&zero,0,sizeof(zero) ); // ugly way of setting short,int,float,double, or __m128 to zero
-
-    for (i=0;i<NFFT;++i) {
-        rin[i] = rand_scalar();
-#if defined(FIXED_POINT) && defined(DOUBLE_PRECISION)
-        rin[i] *= 32768;
-#endif
-        cin[i].r = rin[i];
-        cin[i].i = zero;
-    }
-
-    kiss_fft_state = opus_fft_alloc(NFFT,0,0);
-    kiss_fftr_state = kiss_fftr_alloc(NFFT,0,0);
-    opus_fft(kiss_fft_state,cin,cout);
-    kiss_fftr(kiss_fftr_state,rin,sout);
-
-    printf( "nfft=%d, inverse=%d, snr=%g\n",
-            NFFT,0, snr_compare(cout,sout,(NFFT/2)) );
-
-    memset(cin,0,sizeof(cin));
-    cin[0].r = rand_scalar();
-    cin[NFFT/2].r = rand_scalar();
-    for (i=1;i< NFFT/2;++i) {
-        //cin[i].r = (kiss_fft_scalar)(rand()-RAND_MAX/2);
-        cin[i].r = rand_scalar();
-        cin[i].i = rand_scalar();
-    }
-
-    // conjugate symmetry of real signal
-    for (i=1;i< NFFT/2;++i) {
-        cin[NFFT-i].r = cin[i].r;
-        cin[NFFT-i].i = - cin[i].i;
-    }
-
-
-#ifdef FIXED_POINT
-#ifdef DOUBLE_PRECISION
-    for (i=0;i< NFFT;++i) {
-       cin[i].r *= 32768;
-       cin[i].i *= 32768;
-    }
-#endif
-    for (i=0;i< NFFT;++i) {
-       cin[i].r /= NFFT;
-       cin[i].i /= NFFT;
-    }
-#endif
-
-    fin[0] = cin[0].r;
-    fin[1] = cin[NFFT/2].r;
-    for (i=1;i< NFFT/2;++i)
-    {
-       fin[2*i] = cin[i].r;
-       fin[2*i+1] = cin[i].i;
-    }
-
-    opus_ifft(kiss_fft_state,cin,cout);
-    kiss_fftri(kiss_fftr_state,fin,rout);
-    /*
-    printf(" results from inverse opus_fft : (%f,%f), (%f,%f), (%f,%f), (%f,%f), (%f,%f) ...\n "
-            , (float)cout[0].r , (float)cout[0].i , (float)cout[1].r , (float)cout[1].i , (float)cout[2].r , (float)cout[2].i , (float)cout[3].r , (float)cout[3].i , (float)cout[4].r , (float)cout[4].i
-            );
-
-    printf(" results from inverse kiss_fftr: %f,%f,%f,%f,%f ... \n"
-            ,(float)rout[0] ,(float)rout[1] ,(float)rout[2] ,(float)rout[3] ,(float)rout[4]);
-*/
-    for (i=0;i<NFFT;++i) {
-        sout[i] = cout[i].r;
-    }
-
-    printf( "nfft=%d, inverse=%d, snr=%g\n",
-            NFFT,1, snr_compare_scal(rout,sout,NFFT) );
-    free(kiss_fft_state);
-    free(kiss_fftr_state);
-
-    return ret;
-}
similarity index 96%
rename from celt/tests/cwrs32-test.c
rename to celt/tests/test_unit_cwrs32.c
index ba19e4b..905714e 100644 (file)
 #endif
 
 #define CELT_C
-#include "../celt/stack_alloc.h"
-#include "../celt/entenc.c"
-#include "../celt/entdec.c"
-#include "../celt/entcode.c"
-#include "../celt/cwrs.c"
-#include "../celt/mathops.c"
-#include "../celt/rate.h"
+#include "stack_alloc.h"
+#include "entenc.c"
+#include "entdec.c"
+#include "entcode.c"
+#include "cwrs.c"
+#include "mathops.c"
+#include "rate.h"
 
 #define NMAX (240)
 #define KMAX (128)
similarity index 95%
rename from celt/tests/dft-test.c
rename to celt/tests/test_unit_dft.c
index 1bf4e74..324244f 100644 (file)
 #include "kiss_fft.h"
 
 #define CELT_C
-#include "../celt/stack_alloc.h"
-#include "../celt/kiss_fft.c"
-#include "../celt/mathops.c"
-#include "../celt/entcode.c"
+#include "stack_alloc.h"
+#include "kiss_fft.c"
+#include "mathops.c"
+#include "entcode.c"
 
 
 #ifndef M_PI
similarity index 99%
rename from celt/tests/ectest.c
rename to celt/tests/test_unit_entropy.c
index 29a82fc..f151acc 100644 (file)
@@ -11,9 +11,9 @@
 #include "entdec.h"
 #include <string.h>
 
-#include "../celt/entenc.c"
-#include "../celt/entdec.c"
-#include "../celt/entcode.c"
+#include "entenc.c"
+#include "entdec.c"
+#include "entcode.c"
 
 #ifndef M_LOG2E
 # define M_LOG2E    1.4426950408889634074
similarity index 89%
rename from celt/tests/laplace-test.c
rename to celt/tests/test_unit_laplace.c
index 3c4cbd7..5c80c19 100644 (file)
@@ -6,12 +6,12 @@
 #include <stdlib.h>
 #include "laplace.h"
 #define CELT_C
-#include "../celt/stack_alloc.h"
+#include "stack_alloc.h"
 
-#include "../celt/entenc.c"
-#include "../celt/entdec.c"
-#include "../celt/entcode.c"
-#include "../celt/laplace.c"
+#include "entenc.c"
+#include "entdec.c"
+#include "entcode.c"
+#include "laplace.c"
 
 #define DATA_SIZE 40000
 
similarity index 96%
rename from celt/tests/mdct-test.c
rename to celt/tests/test_unit_mdct.c
index 67da13a..07ac0ff 100644 (file)
 #include <stdio.h>
 #include "mdct.h"
 #define CELT_C
-#include "../celt/stack_alloc.h"
+#include "stack_alloc.h"
 
-#include "../celt/kiss_fft.c"
-#include "../celt/mdct.c"
-#include "../celt/mathops.c"
-#include "../celt/entcode.c"
+#include "kiss_fft.c"
+#include "mdct.c"
+#include "mathops.c"
+#include "entcode.c"
 
 #ifndef M_PI
 #define M_PI 3.141592653
index 207e972..656ee37 100644 (file)
@@ -227,8 +227,7 @@ fi
 AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
 AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
 
-AC_OUTPUT([Makefile celt/tests/Makefile
-           opus.pc opus-uninstalled.pc
+AC_OUTPUT([Makefile opus.pc opus-uninstalled.pc
            doc/Makefile doc/Doxyfile])
 
 AC_MSG_RESULT([