[beast/devel: 58/77] BSE, SFI, BST, TESTS: fixup init functions, use Rapicorn test macros
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 58/77] BSE, SFI, BST, TESTS: fixup init functions, use Rapicorn test macros
- Date: Wed, 1 May 2013 17:32:12 +0000 (UTC)
commit 4d92482538d33aa1f93c28cadc1282426a3a8439
Author: Tim Janik <timj gnu org>
Date: Sun Apr 14 17:45:52 2013 +0200
BSE, SFI, BST, TESTS: fixup init functions, use Rapicorn test macros
beast-gtk/bstmain.cc | 9 +--
beast-gtk/testgui.cc | 2 +-
bse/bseautodoc.cc | 2 +-
bse/bseloader-guspatch.cc | 2 +-
bse/bsemain.cc | 10 +--
bse/bsequery.cc | 2 +-
bse/tests/blocktests.cc | 48 +++++++------
bse/tests/filtertest.cc | 155 ++++++++++++++++++++----------------------
bse/tests/firhandle.cc | 58 ++++++++--------
bse/tests/misctests.cc | 22 ++++---
bse/tests/resamplehandle.cc | 49 +++++++-------
bse/tests/subnormals.cc | 20 +++---
bse/tests/testfft.cc | 46 +++++++-------
sfi/Makefile.am | 2 +-
sfi/sfitests.hh | 107 +++++++++++++++++++++--------
sfi/sfiwrapper.cc | 61 +++++-------------
sfi/sfiwrapper.hh | 11 +---
sfi/tests/misctests.cc | 2 +-
sfi/tests/ring.cc | 2 +-
sfi/tests/testcxx.cc | 10 ++-
sfi/tests/testsfidl.cc | 12 ++--
shell/bsescm.cc | 6 +-
tests/bse/Makefile.am | 2 +-
tests/bse/filtertest.cc | 11 ++--
tests/testresampler.cc | 2 +-
tests/testresamplerq.cc | 7 ++-
tests/testwavechunk.cc | 16 ++--
tools/bsewavetool.cc | 14 ++--
28 files changed, 354 insertions(+), 336 deletions(-)
---
diff --git a/beast-gtk/bstmain.cc b/beast-gtk/bstmain.cc
index e47ade6..78e970a 100644
--- a/beast-gtk/bstmain.cc
+++ b/beast-gtk/bstmain.cc
@@ -66,7 +66,6 @@ main (int argc,
GdkPixbufAnimation *anim;
gchar *string;
GSource *source;
- guint i;
/* initialize i18n */
bindtextdomain (BST_GETTEXT_DOMAIN, BST_PATH_LOCALE);
bind_textdomain_codeset (BST_GETTEXT_DOMAIN, "UTF-8");
@@ -84,7 +83,7 @@ main (int argc,
g_thread_init (NULL);
g_type_init ();
/* initialize Birnet/Sfi */
- sfi_init (&argc, &argv, _("BEAST"), NULL); /* application name is user visible */
+ sfi_init (&argc, argv, "BEAST");
/* ensure SFI can wake us up */
/* initialize Gtk+ and go into threading mode */
bst_early_parse_args (&argc, argv);
@@ -217,7 +216,7 @@ main (int argc,
bst_splash_update_entity (beast_splash, _("Loading..."));
BstApp *app = NULL;
gboolean merge_with_last = FALSE;
- for (i = 1; i < argc; i++)
+ for (int i = 1; i < argc; i++)
{
bst_splash_update ();
/* parse non-file args */
@@ -610,12 +609,12 @@ bst_early_parse_args (int *argc_p, char **argv)
else if (strcmp ("-p", argv[i]) == 0)
{
/* modify args for BSE */
- argv[i] = "--bse-pcm-driver";
+ argv[i] = (char*) "--bse-pcm-driver";
}
else if (strcmp ("-m", argv[i]) == 0)
{
/* modify args for BSE */
- argv[i] = "--bse-midi-driver";
+ argv[i] = (char*) "--bse-midi-driver";
}
}
gxk_param_set_devel_tips (bst_developer_hints);
diff --git a/beast-gtk/testgui.cc b/beast-gtk/testgui.cc
index 3268425..15a3bdb 100644
--- a/beast-gtk/testgui.cc
+++ b/beast-gtk/testgui.cc
@@ -73,7 +73,7 @@ main (int argc,
g_thread_init (NULL);
g_type_init ();
/* initialize Sfi */
- sfi_init (&argc, &argv, "TestGUI", NULL);
+ sfi_init (&argc, argv, "TestGUI");
/* initialize Gtk+ and enter threading mode */
gtk_init (&argc, &argv);
g_set_prgname ("testgui"); /* override Gdk's program name */
diff --git a/bse/bseautodoc.cc b/bse/bseautodoc.cc
index 8a316b2..b656ead 100644
--- a/bse/bseautodoc.cc
+++ b/bse/bseautodoc.cc
@@ -496,7 +496,7 @@ main (gint argc,
const char *pluginbool = "load-core-plugins=0";
const char *scriptbool = "load-core-scripts=0";
g_thread_init (NULL);
- sfi_init (&argc, &argv, "BseAutoDoc", NULL);
+ bse_init_test (&argc, argv);
boxed_type_tag = g_quark_from_static_string ("bse-auto-doc-boxed-type-tag");
for (int i = 1; i < argc; i++)
{
diff --git a/bse/bseloader-guspatch.cc b/bse/bseloader-guspatch.cc
index 58fd756..6cfd171 100644
--- a/bse/bseloader-guspatch.cc
+++ b/bse/bseloader-guspatch.cc
@@ -304,7 +304,7 @@ struct FileInfo
case PAT_FORMAT_16BIT: return GSL_WAVE_FORMAT_SIGNED_16;
case PAT_FORMAT_UNSIGNED | PAT_FORMAT_16BIT: return GSL_WAVE_FORMAT_UNSIGNED_16;
}
- BIRNET_ASSERT_NOT_REACHED();
+ RAPICORN_ASSERT_UNREACHED();
}
int
bytes_per_frame (int wave_format)
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 17f9b91..323235f 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -90,7 +90,7 @@ _bse_init_async (int *argc, char **argv, const char *app_name, const Bse::String
/* paranoid assertions */
g_assert (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
/* initialize submodules */
- sfi_init (argc, &argv, app_name, NULL);
+ sfi_init (argc, argv, app_name);
bse_main_args = &default_main_args;
/* handle argument early*/
if (argc && argv)
@@ -252,9 +252,9 @@ bse_init_intern (int *argc, char **argv, const char *app_name, const Bse::String
g_assert (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
/* initialize submodules */
if (as_test)
- sfi_init_test (argc, &argv, NULL);
+ sfi_init_test (argc, argv);
else
- sfi_init (argc, &argv, app_name, NULL);
+ sfi_init (argc, argv, app_name);
bse_main_args = &default_main_args;
/* early argument handling */
if (argc && argv)
@@ -294,9 +294,7 @@ bse_init_intern (int *argc, char **argv, const char *app_name, const Bse::String
if (as_test)
{
Bse::CPUInfo ci = Rapicorn::cpu_info();
- char *cname = g_strdup_printf ("%s+%s", ci.machine, bse_block_impl_name());
- treport_cpu_name (cname);
- g_free (cname);
+ TMSG (" NOTE Running on: %s+%s", ci.machine, bse_block_impl_name());
}
// sfi_glue_gc_run ();
}
diff --git a/bse/bsequery.cc b/bse/bsequery.cc
index c85f327..c3baa3e 100644
--- a/bse/bsequery.cc
+++ b/bse/bsequery.cc
@@ -174,7 +174,7 @@ main (gint argc,
const char *scriptbool = "load-core-scripts=0";
f_out = stdout;
g_thread_init (NULL);
- sfi_init (&argc, &argv, "BseQuery", NULL);
+ bse_init_test (&argc, argv);
int i;
for (i = 1; i < argc; i++)
{
diff --git a/bse/tests/blocktests.cc b/bse/tests/blocktests.cc
index 2db4d15..3385dd8 100644
--- a/bse/tests/blocktests.cc
+++ b/bse/tests/blocktests.cc
@@ -1,9 +1,15 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bseblockutils.hh>
-// #define TEST_VERBOSE
#include <sfi/sfitests.hh>
#include <bse/bsemain.hh>
#include "topconfig.h"
+
+static void
+report_usecs (const char *what, double usecs)
+{
+ TMSG (" %-28s : %+.14f µseconds", what, usecs);
+}
+
template<typename T> static bool
block_check (guint n,
const T *block,
@@ -12,11 +18,12 @@ block_check (guint n,
while (n--)
if (block[n] != value)
{
- TPRINT ("%f != %f", block[n], value);
+ TCMP (block[n], ==, value);
return false;
}
return true;
}
+
/**
* Shuffles a block, using the O(n) algorithm called the Knuth shuffle
* or Fisher-Yates shuffle, for instance explained on
@@ -148,7 +155,7 @@ test_square_sum (void)
fblock[i] = sin (i * 2 * M_PI / 1024);
energy = bse_block_calc_float_square_sum (1024, fblock) / 1024.;
energy_db = 10 * log10 (energy);
- TPRINT ("sine wave: energy = %f, energy_db = %f\n", energy, energy_db);
+ TOUT ("sine wave: energy = %f, energy_db = %f\n", energy, energy_db);
TASSERT (fabs (energy - 0.5) < 0.0000001);
energy = bse_block_calc_float_range_and_square_sum (1024, fblock, &min_value, &max_value) / 1024.;
TASSERT (fabs (energy - 0.5) < 0.0000001);
@@ -156,7 +163,7 @@ test_square_sum (void)
fblock[i] = i < 512 ? -1 : 1;
energy = bse_block_calc_float_square_sum (1024, fblock) / 1024.;
energy_db = 10 * log10 (energy);
- TPRINT ("square wave: energy = %f, energy_db = %f\n", energy, energy_db);
+ TOUT ("square wave: energy = %f, energy_db = %f\n", energy, energy_db);
TASSERT (fabs (energy - 1.0) < 0.0000001);
energy = bse_block_calc_float_range_and_square_sum (1024, fblock, &min_value, &max_value) / 1024.;
TASSERT (fabs (energy - 1.0) < 0.0000001);
@@ -231,7 +238,7 @@ bench_fill (void)
if (e < m)
m = e;
}
- treport_minimized ("Block::fill", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::fill", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("FillBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -259,7 +266,7 @@ bench_copy (void)
m = e;
}
g_assert (dest_fblock[0] == 2.f);
- treport_minimized ("Block::copy", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::copy", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("CopyBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -286,7 +293,7 @@ bench_add (void)
if (e < m)
m = e;
}
- treport_minimized ("Block::add", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::add", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("AddBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -313,7 +320,7 @@ bench_sub (void)
if (e < m)
m = e;
}
- treport_minimized ("Block::sub", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::sub", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("SubBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -341,7 +348,7 @@ bench_mul (void)
m = e;
}
g_assert (fblock1[0] < 1e30); /* not close to infinity */
- treport_minimized ("Block::mul", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::mul", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("MulBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -368,7 +375,7 @@ bench_scale (void)
if (e < m)
m = e;
}
- treport_minimized ("Block::scale", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::scale", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("ScaleBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -401,7 +408,7 @@ bench_range (void)
}
g_assert (min_value == correct_min_value);
g_assert (max_value == correct_max_value);
- treport_minimized ("Block::range", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::range", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("RangeBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -427,7 +434,7 @@ bench_square_sum (void)
if (e < m)
m = e;
}
- treport_minimized ("Block::square_sum", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::square_sum", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("SquareSumBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -460,7 +467,7 @@ bench_range_and_square_sum (void)
}
g_assert (min_value == correct_min_value);
g_assert (max_value == correct_max_value);
- treport_minimized ("Block::range_and_square_sum", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+ report_usecs ("Block::range_and_square_sum", 1000000.0 * m / dups * BENCH_SCALE);
if (0)
g_print ("Range+SquareSumBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
@@ -477,7 +484,7 @@ run_tests()
/* the next two functions test the range_and_square_sum function, too */
test_range();
test_square_sum();
- if (sfi_init_settings().test_perf)
+ if (Rapicorn::Test::slow())
{
bench_fill();
bench_copy();
@@ -494,14 +501,11 @@ int
main (int argc,
char *argv[])
{
- /* usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded */
- sfi_init_test (&argc, &argv, NULL);
- { /* bse_init_test() usually does this for us */
- Bse::CPUInfo ci = Bse::cpu_info();
- char *cname = g_strdup_printf ("%s+%s", ci.machine, bse_block_impl_name());
- treport_cpu_name (cname);
- g_free (cname);
- }
+ // usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded
+ Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
+ Bse::CPUInfo ci = Rapicorn::cpu_info(); // usually done by bse_init_test
+ TMSG (" NOTE Running on: %s+%s", ci.machine, bse_block_impl_name());
+
TSTART ("Running Default Block Ops");
TASSERT (Bse::Block::default_singleton() == Bse::Block::current_singleton());
TDONE();
diff --git a/bse/tests/filtertest.cc b/bse/tests/filtertest.cc
index 7ce8267..56afd4b 100644
--- a/bse/tests/filtertest.cc
+++ b/bse/tests/filtertest.cc
@@ -172,7 +172,7 @@ noexit_dump_iir_filter_gnuplot (const BseIIRFilterRequest *fireq,
arrows[n_arrows++] = stopband_edge2;
consts[n_consts++] = 0.0;
bool success = bse_iir_filter_dump_gnuplot (fdes, fname, n_consts, consts, n_arrows, arrows, 55555);
- BIRNET_ASSERT (success == true);
+ TASSERT (success == true);
g_printerr ("Filter: %s\n", bse_iir_filter_request_string (fireq));
g_printerr ("Design: %s\n", bse_iir_filter_design_string (fdes));
g_printerr ("GnuplotDump: wrote %s.gp and %s.dat use: gnuplot %s.gp\n", fname, fname, fname);
@@ -245,16 +245,15 @@ min_band_damping (const BseIIRFilterDesign *fdes,
// double res1 = min_band_damping_ztrans (fdes, start_freq, end_freq);
return min_band_damping_zp (fdes, MIN (start_freq, end_freq), MAX (start_freq, end_freq));
}
+
static void
-print_filter_on_abort (void *data)
+print_filter_on_abort (const BseIIRFilterRequest &req, const BseIIRFilterDesign &fdes)
{
- void **adata = (void**) data;
- const BseIIRFilterRequest *req = (BseIIRFilterRequest*) adata[0];
- const BseIIRFilterDesign *fdes = (BseIIRFilterDesign*) adata[1];
- noexit_dump_iir_filter_gnuplot (req, fdes, "tmpfilter",
- -fabs(req->passband_ripple_db), req->passband_edge, req->passband_edge2,
- req->stopband_db != 0 ? req->stopband_db : NAN, req->stopband_edge, NAN);
+ noexit_dump_iir_filter_gnuplot (&req, &fdes, "tmpfilter",
+ -fabs(req.passband_ripple_db), req.passband_edge, req.passband_edge2,
+ req.stopband_db != 0 ? req.stopband_db : NAN, req.stopband_edge, NAN);
}
+
static void
butterwoth_tests ()
{
@@ -264,10 +263,7 @@ butterwoth_tests ()
BseIIRFilterDesign fdes;
BseIIRFilterRequest req = { BseIIRFilterKind (0), };
req.kind = BSE_IIR_FILTER_BUTTERWORTH;
- void *abort_data[2];
- abort_data[0] = (void*) &req;
- abort_data[1] = &fdes;
- TABORT_HANDLER (print_filter_on_abort, abort_data);
+ Test::set_assertion_hook ([&] () { print_filter_on_abort (req, fdes); });
TOK();
{
req.type = BSE_IIR_FILTER_LOW_PASS;
@@ -281,9 +277,9 @@ butterwoth_tests ()
g_printerr ("Design: %s\n", bse_iir_filter_design_string (&fdes));
}
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 0, 2000), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 0, 2000), >, -3.0103);
- TASSERT_CMP (min_band_damping (&fdes, 3500, 5000), <, -68);
+ TCMP (min_band_damping (&fdes, 0, 2000), <, gaineps);
+ TCMP (max_band_damping (&fdes, 0, 2000), >, -3.0103);
+ TCMP (min_band_damping (&fdes, 3500, 5000), <, -68);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 2000, NAN, -68, 3500);
}
@@ -294,9 +290,9 @@ butterwoth_tests ()
req.passband_edge = 2000;
success = bse_iir_filter_design (&req, &fdes);
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 2000, 5000), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 2000, 5000), >, -3.0103);
- TASSERT_CMP (min_band_damping (&fdes, 0, 600), <, -80);
+ TCMP (min_band_damping (&fdes, 2000, 5000), <, gaineps);
+ TCMP (max_band_damping (&fdes, 2000, 5000), >, -3.0103);
+ TCMP (min_band_damping (&fdes, 0, 600), <, -80);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 2000, NAN, -80, 600);
}
@@ -308,10 +304,10 @@ butterwoth_tests ()
req.passband_edge2 = 3500;
success = bse_iir_filter_design (&req, &fdes);
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 1500, 3500), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 1500, 3500), >, -3.0103);
- TASSERT_CMP (min_band_damping (&fdes, 0, 1000), <, -49.5);
- TASSERT_CMP (min_band_damping (&fdes, 4000, 5000), <, -49.5);
+ TCMP (min_band_damping (&fdes, 1500, 3500), <, gaineps);
+ TCMP (max_band_damping (&fdes, 1500, 3500), >, -3.0103);
+ TCMP (min_band_damping (&fdes, 0, 1000), <, -49.5);
+ TCMP (min_band_damping (&fdes, 4000, 5000), <, -49.5);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 1500, 3500, -49.5, 1000, 4000);
}
@@ -323,13 +319,14 @@ butterwoth_tests ()
req.passband_edge2 = 4000;
success = bse_iir_filter_design (&req, &fdes);
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 0, 1000), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 0, 1000), >, -3.0103);
- TASSERT_CMP (min_band_damping (&fdes, 1500, 3500), <, -77);
- TASSERT_CMP (max_band_damping (&fdes, 4000, 5000), >, -3.0103);
+ TCMP (min_band_damping (&fdes, 0, 1000), <, gaineps);
+ TCMP (max_band_damping (&fdes, 0, 1000), >, -3.0103);
+ TCMP (min_band_damping (&fdes, 1500, 3500), <, -77);
+ TCMP (max_band_damping (&fdes, 4000, 5000), >, -3.0103);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 1000, 4000, -77, 1500, 3500);
}
+ Test::set_assertion_hook (NULL);
TOK();
TDONE();
}
@@ -341,10 +338,7 @@ chebychev1_tests ()
BseIIRFilterDesign fdes;
BseIIRFilterRequest req = { BseIIRFilterKind (0), };
req.kind = BSE_IIR_FILTER_CHEBYSHEV1;
- void *abort_data[2];
- abort_data[0] = (void*) &req;
- abort_data[1] = &fdes;
- TABORT_HANDLER (print_filter_on_abort, abort_data);
+ Test::set_assertion_hook ([&] () { print_filter_on_abort (req, fdes); });
const double gaineps = 1e-7;
TOK();
{
@@ -355,9 +349,9 @@ chebychev1_tests ()
req.passband_edge = 3000;
success = bse_iir_filter_design (&req, &fdes);
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 0, 3000), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 0, 3000), >, -1.5501);
- TASSERT_CMP (min_band_damping (&fdes, 5000, 10000), <, -80);
+ TCMP (min_band_damping (&fdes, 0, 3000), <, gaineps);
+ TCMP (max_band_damping (&fdes, 0, 3000), >, -1.5501);
+ TCMP (min_band_damping (&fdes, 5000, 10000), <, -80);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -1.55, 3000, NAN, -80, 5000);
}
@@ -369,9 +363,9 @@ chebychev1_tests ()
req.passband_edge = 600;
success = bse_iir_filter_design (&req, &fdes);
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 600, 5000), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 600, 5000), >, -0.101);
- TASSERT_CMP (min_band_damping (&fdes, 0, 250), <, -70);
+ TCMP (min_band_damping (&fdes, 600, 5000), <, gaineps);
+ TCMP (max_band_damping (&fdes, 600, 5000), >, -0.101);
+ TCMP (min_band_damping (&fdes, 0, 250), <, -70);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -0.1, 600, NAN, -70, 250);
}
@@ -384,10 +378,10 @@ chebychev1_tests ()
req.passband_edge2 = 9500;
success = bse_iir_filter_design (&req, &fdes);
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 3500, 9500), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 3500, 9500), >, -1.801);
- TASSERT_CMP (min_band_damping (&fdes, 0, 3000), <, -55);
- TASSERT_CMP (min_band_damping (&fdes, 10200, 15000), <, -55);
+ TCMP (min_band_damping (&fdes, 3500, 9500), <, gaineps);
+ TCMP (max_band_damping (&fdes, 3500, 9500), >, -1.801);
+ TCMP (min_band_damping (&fdes, 0, 3000), <, -55);
+ TCMP (min_band_damping (&fdes, 10200, 15000), <, -55);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -1.801, 3500, 9500, -55, 3000, 10200);
}
@@ -400,13 +394,14 @@ chebychev1_tests ()
req.passband_edge2 = 12000;
success = bse_iir_filter_design (&req, &fdes);
TASSERT (success == true);
- TASSERT_CMP (min_band_damping (&fdes, 0, 8000), <, gaineps);
- TASSERT_CMP (max_band_damping (&fdes, 0, 8000), >, -1.001);
- TASSERT_CMP (min_band_damping (&fdes, 8500, 11500), <, -78);
- TASSERT_CMP (max_band_damping (&fdes, 12000, 20000), >, -1.001);
+ TCMP (min_band_damping (&fdes, 0, 8000), <, gaineps);
+ TCMP (max_band_damping (&fdes, 0, 8000), >, -1.001);
+ TCMP (min_band_damping (&fdes, 8500, 11500), <, -78);
+ TCMP (max_band_damping (&fdes, 12000, 20000), >, -1.001);
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -1.001, 8000, 12000, -78, 8500, 11500);
}
+ Test::set_assertion_hook (NULL);
TOK();
TDONE();
}
@@ -518,7 +513,7 @@ random_filter_tests ()
double pbe1;
FilterSetup filters[100000] = { { 0, }, };
uint filter_index, skip_count = 6;
- if (sfi_init_settings().test_quick)
+ if (!Test::slow())
n_orders = 9;
#define MAKE_FILTER(frequest, filter_type) do \
{ \
@@ -656,7 +651,7 @@ test_filter_catalog ()
/* include predesigned filters */
#include "filtercatalog.cc"
uint skip_count = 0, tick_count = 3;
- if (sfi_init_settings().test_quick)
+ if (!Test::slow())
{
tick_count = 1;
skip_count = 17;
@@ -675,27 +670,24 @@ generic_filter_tests (const char *test_name,
const double coefficients_epsilon = 1e-7;
const double max_gain = 0.01; // maximum gain in passband
TSTART ("%s", test_name);
- void *abort_data[2];
- TABORT_HANDLER (print_filter_on_abort, abort_data);
skip_count = MAX (1, skip_count);
for (i = 0; i < n_filters; i += 1 + g_random_int() % skip_count)
{
const BseIIRFilterRequest *req = filters[i].filter_request;
BseIIRFilterDesign fdes;
- abort_data[0] = (void*) req;
- abort_data[1] = &fdes;
+ Test::set_assertion_hook ([&] () { print_filter_on_abort (*req, fdes); });
bool success = bse_iir_filter_design (req, &fdes);
- TCHECK (success == true);
+ TASSERT (success == true);
if (filters[i].zeros)
- TCHECK_CMP (filters[i].n_zeros, ==, fdes.n_zeros);
+ TCMP (filters[i].n_zeros, ==, fdes.n_zeros);
if (filters[i].poles)
- TCHECK_CMP (filters[i].n_poles, ==, fdes.n_poles);
+ TCMP (filters[i].n_poles, ==, fdes.n_poles);
double zeps = filters[i].zeros ? compare_zeros (fdes.n_zeros, fdes.zz, filters[i].zeros) : 0;
double peps = filters[i].poles ? compare_zeros (fdes.n_poles, fdes.zp, filters[i].poles) : 0;
- TCHECK_CMP (zeps, <, coefficients_epsilon);
- TCHECK_CMP (peps, <, coefficients_epsilon);
+ TCMP (zeps, <, coefficients_epsilon);
+ TCMP (peps, <, coefficients_epsilon);
/* broad gain check */
- TCHECK_CMP (min_band_damping (&fdes, 0, 0.5 * req->sampling_frequency), <, max_gain);
+ TCMP (min_band_damping (&fdes, 0, 0.5 * req->sampling_frequency), <, max_gain);
/* finer gain checks */
double passband_ripple_db = req->kind == BSE_IIR_FILTER_BUTTERWORTH ? -3.010299956639811952 :
-req->passband_ripple_db;
double stopband_db = req->kind == BSE_IIR_FILTER_ELLIPTIC && req->stopband_db < 0.0 ? req->stopband_db
: 2.02 * passband_ripple_db;
@@ -703,61 +695,62 @@ generic_filter_tests (const char *test_name,
if (req->type == BSE_IIR_FILTER_LOW_PASS || req->type == BSE_IIR_FILTER_BAND_STOP)
{
double min_pass_damping = min_band_damping (&fdes, 0, req->passband_edge);
- TCHECK_CMP (min_pass_damping, <, max_gain);
- TCHECK_CMP (min_pass_damping, >, -0.01);
+ TCMP (min_pass_damping, <, max_gain);
+ TCMP (min_pass_damping, >, -0.01);
double max_pass_damping = max_band_damping (&fdes, 0, req->passband_edge);
- TCHECK_CMP (max_pass_damping, >, passband_ripple_db - 0.01);
- TCHECK_CMP (max_pass_damping, <, passband_ripple_db * 0.9);
+ TCMP (max_pass_damping, >, passband_ripple_db - 0.01);
+ TCMP (max_pass_damping, <, passband_ripple_db * 0.9);
}
if (req->type == BSE_IIR_FILTER_LOW_PASS)
{
double max_stop_damping = max_band_damping (&fdes, 0.5 * req->sampling_frequency, 0.5 *
req->sampling_frequency);
- TCHECK_CMP (max_stop_damping, <, stopband_db * 0.98);
+ TCMP (max_stop_damping, <, stopband_db * 0.98);
}
if (req->type == BSE_IIR_FILTER_HIGH_PASS)
{
double min_pass_damping = min_band_damping (&fdes, req->passband_edge, 0.5 *
req->sampling_frequency);
- TCHECK_CMP (min_pass_damping, <, max_gain);
- TCHECK_CMP (min_pass_damping, >, -0.01);
+ TCMP (min_pass_damping, <, max_gain);
+ TCMP (min_pass_damping, >, -0.01);
double max_pass_damping = max_band_damping (&fdes, req->passband_edge, 0.5 *
req->sampling_frequency);
- TCHECK_CMP (max_pass_damping, >, passband_ripple_db - 0.01);
- TCHECK_CMP (max_pass_damping, <, passband_ripple_db * 0.9);
+ TCMP (max_pass_damping, >, passband_ripple_db - 0.01);
+ TCMP (max_pass_damping, <, passband_ripple_db * 0.9);
double max_stop_damping = max_band_damping (&fdes, 0, 0);
- TCHECK_CMP (max_stop_damping, <, stopband_db * 0.98);
+ TCMP (max_stop_damping, <, stopband_db * 0.98);
}
if (req->type == BSE_IIR_FILTER_BAND_PASS)
{
double min_pass_damping = min_band_damping (&fdes, req->passband_edge, req->passband_edge2);
- TCHECK_CMP (min_pass_damping, <, max_gain);
- TCHECK_CMP (min_pass_damping, >, -0.01);
+ TCMP (min_pass_damping, <, max_gain);
+ TCMP (min_pass_damping, >, -0.01);
double max_pass_damping = max_band_damping (&fdes, req->passband_edge, req->passband_edge2);
- TCHECK_CMP (max_pass_damping, >, passband_ripple_db - 0.01);
- TCHECK_CMP (max_pass_damping, <, passband_ripple_db * 0.9);
+ TCMP (max_pass_damping, >, passband_ripple_db - 0.01);
+ TCMP (max_pass_damping, <, passband_ripple_db * 0.9);
double max_stop_damping0 = max_band_damping (&fdes, 0, 0);
- TCHECK_CMP (max_stop_damping0, <, stopband_db * 0.98);
+ TCMP (max_stop_damping0, <, stopband_db * 0.98);
double max_stop_damping2 = max_band_damping (&fdes, 0.5 * req->sampling_frequency, 0.5 *
req->sampling_frequency);
- TCHECK_CMP (max_stop_damping2, <, stopband_db * 0.98);
+ TCMP (max_stop_damping2, <, stopband_db * 0.98);
}
if (req->type == BSE_IIR_FILTER_BAND_STOP)
{
double min_pass_damping0 = min_band_damping (&fdes, 0, req->passband_edge);
- TCHECK_CMP (min_pass_damping0, <, max_gain);
- TCHECK_CMP (min_pass_damping0, >, -0.01);
+ TCMP (min_pass_damping0, <, max_gain);
+ TCMP (min_pass_damping0, >, -0.01);
double max_pass_damping0 = max_band_damping (&fdes, 0, req->passband_edge);
- TCHECK_CMP (max_pass_damping0, >, passband_ripple_db - 0.01);
- TCHECK_CMP (max_pass_damping0, <, passband_ripple_db * 0.9);
+ TCMP (max_pass_damping0, >, passband_ripple_db - 0.01);
+ TCMP (max_pass_damping0, <, passband_ripple_db * 0.9);
double min_pass_damping2 = min_band_damping (&fdes, req->passband_edge2, 0.5 *
req->sampling_frequency);
- TCHECK_CMP (min_pass_damping2, <, max_gain);
- TCHECK_CMP (min_pass_damping2, >, -0.01);
+ TCMP (min_pass_damping2, <, max_gain);
+ TCMP (min_pass_damping2, >, -0.01);
double max_pass_damping2 = max_band_damping (&fdes, req->passband_edge2, 0.5 *
req->sampling_frequency);
- TCHECK_CMP (max_pass_damping2, >, passband_ripple_db - 0.01);
- TCHECK_CMP (max_pass_damping2, <, passband_ripple_db * 0.9);
+ TCMP (max_pass_damping2, >, passband_ripple_db - 0.01);
+ TCMP (max_pass_damping2, <, passband_ripple_db * 0.9);
double max_stop_damping = max_band_damping (&fdes, fdes.center_frequency, fdes.center_frequency);
- TCHECK_CMP (max_stop_damping, <, stopband_db * 0.98);
+ TCMP (max_stop_damping, <, stopband_db * 0.98);
}
if (i % tick_count == 0)
TOK();
}
+ Test::set_assertion_hook (NULL);
TDONE();
}
int
diff --git a/bse/tests/firhandle.cc b/bse/tests/firhandle.cc
index 3f5f4cc..a6bda95 100644
--- a/bse/tests/firhandle.cc
+++ b/bse/tests/firhandle.cc
@@ -167,7 +167,7 @@ test_with_sine_sweep (FirHandleType type)
double theoretical_level_db = bse_data_handle_fir_response_db (fir_handle_sin, sweep_freq[i]);
double theoretical_level = bse_db_to_factor (theoretical_level_db);
// printf ("%g %.17g\n", sweep_freq[i], fabs (level - theoretical_level));
- TCHECK_CMP (fabs (level - theoretical_level), <, 0.00035);
+ TCMP (fabs (level - theoretical_level), <, 0.00035);
}
// compute phase response
std::complex<double> orig (sweep_sin[i], sweep_cos[i]);
@@ -177,39 +177,39 @@ test_with_sine_sweep (FirHandleType type)
if (type == FIR_HIGHPASS)
{
// stop band
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 0, 7050), <, -75);
+ TCMP (band_max (scanned_freq, scanned_level_db, 0, 7050), <, -75);
// transition band
- TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 7050, 9500), >, -77);
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 7050, 9500), <, -2.8);
+ TCMP (band_min (scanned_freq, scanned_level_db, 7050, 9500), >, -77);
+ TCMP (band_max (scanned_freq, scanned_level_db, 7050, 9500), <, -2.8);
// passband (1)
- TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 9500, 11000), >, -2.82);
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 9500, 11000), <, -0.002);
+ TCMP (band_min (scanned_freq, scanned_level_db, 9500, 11000), >, -2.82);
+ TCMP (band_max (scanned_freq, scanned_level_db, 9500, 11000), <, -0.002);
// passband (2)
- TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 11000, 24000), >, -0.004);
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 11000, 24000), <, 0.002);
+ TCMP (band_min (scanned_freq, scanned_level_db, 11000, 24000), >, -0.004);
+ TCMP (band_max (scanned_freq, scanned_level_db, 11000, 24000), <, 0.002);
// zero phase in passband (2)
- TASSERT_CMP (band_max (scanned_freq, scanned_abs_phase_diff, 11000, 24000), <, 0.0002);
+ TCMP (band_max (scanned_freq, scanned_abs_phase_diff, 11000, 24000), <, 0.0002);
}
else // FIR_LOWPASS
{
// passband (2)
- TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 0, 5500), >, -0.002);
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 0, 5500), <, 0.002);
+ TCMP (band_min (scanned_freq, scanned_level_db, 0, 5500), >, -0.002);
+ TCMP (band_max (scanned_freq, scanned_level_db, 0, 5500), <, 0.002);
// passband (1)
- TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 5500, 7000), >, -1.9);
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 5500, 7000), <, -0.001);
+ TCMP (band_min (scanned_freq, scanned_level_db, 5500, 7000), >, -1.9);
+ TCMP (band_max (scanned_freq, scanned_level_db, 5500, 7000), <, -0.001);
// transition band
- TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 7000, 10000), >, -81);
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 7000, 10000), <, -1.8);
+ TCMP (band_min (scanned_freq, scanned_level_db, 7000, 10000), >, -81);
+ TCMP (band_max (scanned_freq, scanned_level_db, 7000, 10000), <, -1.8);
// stop band
- TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 10000, 24000), <, -75);
+ TCMP (band_max (scanned_freq, scanned_level_db, 10000, 24000), <, -75);
// zero phase in passband (2)
- TASSERT_CMP (band_max (scanned_freq, scanned_abs_phase_diff, 0, 5500), <, 0.00002);
+ TCMP (band_max (scanned_freq, scanned_abs_phase_diff, 0, 5500), <, 0.00002);
}
TDONE();
/* test speed */
double samples_per_second = 0;
- if (sfi_init_settings().test_perf)
+ if (Rapicorn::Test::slow())
{
const guint RUNS = 10;
GTimer *timer = g_timer_new();
@@ -226,10 +226,12 @@ test_with_sine_sweep (FirHandleType type)
m = e;
}
samples_per_second = sweep_sin.size() / (m / dups);
- treport_maximized (string_printf ("%s O64 mono", handle_name (type)).c_str(),
- samples_per_second, TUNIT (SAMPLE, SECOND));
- treport_maximized (string_printf ("CPU %s mono", handle_name (type)).c_str(),
- samples_per_second / 44100.0, TUNIT_STREAM);
+ TMSG (" %-28s : %+.14f samples/second",
+ string_printf ("%s O64 mono", handle_name (type)).c_str(),
+ samples_per_second);
+ TMSG (" %-28s : %+.14f streams",
+ string_printf ("CPU %s mono", handle_name (type)).c_str(),
+ samples_per_second / 44100.0);
}
}
static double
@@ -294,8 +296,8 @@ test_multi_channel (FirHandleType type)
worst_diff = max (filtered - expected[i], worst_diff);
}
double worst_diff_db = bse_db_from_factor (worst_diff, -200);
- TPRINT ("n_channels = %d: linear(%dst read) read worst_diff = %f (%f dB)\n",
- n_channels, repeat, worst_diff, worst_diff_db);
+ TOUT ("n_channels = %d: linear(%dst read) read worst_diff = %f (%f dB)\n",
+ n_channels, repeat, worst_diff, worst_diff_db);
TASSERT (worst_diff_db < -90);
}
}
@@ -337,13 +339,13 @@ test_seek (FirHandleType type)
while (values_todo > 0)
{
int64 l = gsl_data_handle_read (fir_handle, start + offset, values_todo, &values[offset]);
- TCHECK (l > 0);
- TCHECK (l <= values_todo);
+ TASSERT (l > 0);
+ TASSERT (l <= values_todo);
values_todo -= l;
offset += l;
}
- for (size_t i = 0; i < len; i++)
- TCHECK (values[i] == output[i + start]);
+ for (size_t i = 0; i < size_t (len); i++)
+ TASSERT (values[i] == output[i + start]);
if (t % 40 == 0)
TOK();
}
diff --git a/bse/tests/misctests.cc b/bse/tests/misctests.cc
index ec9e3e2..a650860 100644
--- a/bse/tests/misctests.cc
+++ b/bse/tests/misctests.cc
@@ -13,7 +13,7 @@ check_cent_tune_fast (void)
for (int i = -100; i <= +100; i++)
{
double setpoint = pow (2.0, 1. / 1200. * i);
- TCHECK_CMP (fabs (bse_cent_tune_fast (i) - setpoint), <, epsilon);
+ TCMP (fabs (bse_cent_tune_fast (i) - setpoint), <, epsilon);
if (i % 13 == 0)
TOK();
}
@@ -28,7 +28,7 @@ check_cent_tune (void)
for (double fine_tune = -3600; fine_tune < 3600; fine_tune += g_random_double()) /* 3 octaves */
{
double expected = pow (2.0, 1. / 1200. * fine_tune);
- TCHECK_CMP (fabs (bse_cent_tune (fine_tune) - expected), <, epsilon);
+ TCMP (fabs (bse_cent_tune (fine_tune) - expected), <, epsilon);
if (i++ % 500 == 0)
TOK();
}
@@ -43,7 +43,7 @@ check_equal_tempered_tuning (void)
for (int i = -132; i <= +132; i++)
{
double setpoint = pow (2.0, 1. / 12. * i);
- TCHECK_CMP (fabs (table[i] - setpoint), <, epsilon);
+ TCMP (fabs (table[i] - setpoint), <, epsilon);
if (i % 13 == 0)
TOK();
}
@@ -57,8 +57,8 @@ check_tuning_monotony (BseMusicalTuningType musical_tuning)
for (int i = -132; i <= +132; i++)
if (ABS (i) != 132)
{
- TCHECK_CMP (table[i - 1], <, table[i]);
- TCHECK_CMP (table[i + 1], >, table[i]);
+ TCMP (table[i - 1], <, table[i]);
+ TCMP (table[i + 1], >, table[i]);
if (i % 13 == 0)
TOK();
}
@@ -80,7 +80,7 @@ check_freq_vs_notes (BseMusicalTuningType musical_tuning)
g_print ("compose : note=%4d fine_tune=%4d freq=%" FLF "f\n", j, k, freq);
f = freq;
note = bse_note_from_freq (musical_tuning, freq);
- TCHECK (note != BSE_NOTE_VOID);
+ TASSERT (note != BSE_NOTE_VOID);
fine_tune = bse_note_fine_tune_from_note_freq (musical_tuning, note, freq);
freq = bse_note_to_tuned_freq (musical_tuning, note, fine_tune);
double freq_error = freq - f;
@@ -88,11 +88,11 @@ check_freq_vs_notes (BseMusicalTuningType musical_tuning)
if (verbose)
g_print ("decompose: note=%4d fine_tune=%4d freq=%" FLF "f (diff=%" FLF "f)\n", note,
fine_tune, freq, freq - f);
if (ABS (k) < 11)
- TCHECK (note == j);
+ TASSERT (note == j);
if (musical_tuning == BSE_MUSICAL_TUNING_12_TET)
- TCHECK_CMP (fabs (freq_error), <, 0.00000000001); /* equal temperament is fairly accurate */
+ TCMP (fabs (freq_error), <, 0.00000000001); /* equal temperament is fairly accurate */
else
- TCHECK_CMP (freq_ratio, <, 1.00057778950655485930); /* detuning should be smaller than a cent */
+ TCMP (freq_ratio, <, 1.00057778950655485930); /* detuning should be smaller than a cent */
}
if (j % 3 == 0)
TOK();
@@ -109,7 +109,9 @@ main (gint argc,
check_equal_tempered_tuning();
BseMusicalTuningType last_tuning = BSE_MUSICAL_TUNING_YOUNG;
/* check last tuning value by asserting defaulting behavior of succeding values */
- TCHECK (bse_semitone_table_from_tuning (BseMusicalTuningType (last_tuning + 1)) ==
bse_semitone_table_from_tuning (BseMusicalTuningType (0)));
+ TCMP (bse_semitone_table_from_tuning (BseMusicalTuningType (last_tuning + 1)),
+ ==,
+ bse_semitone_table_from_tuning (BseMusicalTuningType (0)));
/* check monotonic musical tuning systems */
for (int j = BSE_MUSICAL_TUNING_12_TET; j <= last_tuning; j++)
{
diff --git a/bse/tests/resamplehandle.cc b/bse/tests/resamplehandle.cc
index 6b753ce..c8d6949 100644
--- a/bse/tests/resamplehandle.cc
+++ b/bse/tests/resamplehandle.cc
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bsemathsignal.hh>
#include <bse/bsemain.hh>
-// #define TEST_VERBOSE
#include <sfi/sfitests.hh>
#include <bse/gsldatautils.hh>
#include <bse/bseblockutils.hh>
@@ -9,11 +8,13 @@
#include <vector>
#include <string>
#include <map>
+
using std::vector;
using std::string;
using std::max;
using std::min;
using std::map;
+
static void
read_through (GslDataHandle *handle)
{
@@ -83,12 +84,12 @@ check (const char *up_down,
worst_diff = max (fabs (resampled - expected[i]), worst_diff);
}
worst_diff_db = bse_db_from_factor (worst_diff, -200);
- TPRINT ("linear(%dst read) read worst_diff = %f (%f dB)\n", repeat, worst_diff, worst_diff_db);
+ TOUT ("linear(%dst read) read worst_diff = %f (%f dB)\n", repeat, worst_diff, worst_diff_db);
TASSERT (worst_diff_db < max_db);
}
/* test seeking */
worst_diff = 0.0;
- const uint count = sfi_init_settings().test_slow ? 300 : 100;
+ const uint count = Rapicorn::Test::slow() ? 300 : 100;
for (uint j = 0; j < count; j++)
{
int64 start = rand() % rhandle->setup.n_values;
@@ -101,12 +102,12 @@ check (const char *up_down,
}
}
worst_diff_db = bse_db_from_factor (worst_diff, -200);
- TPRINT ("seek worst_diff = %f (%f dB)\n", worst_diff, worst_diff_db);
+ TOUT ("seek worst_diff = %f (%f dB)\n", worst_diff, worst_diff_db);
TASSERT (worst_diff_db < max_db);
TDONE();
/* test speed */
double samples_per_second = 0;
- if (sfi_init_settings().test_perf)
+ if (Rapicorn::Test::slow())
{
const guint RUNS = 10;
GTimer *timer = g_timer_new();
@@ -123,11 +124,11 @@ check (const char *up_down,
m = e;
}
samples_per_second = input.size() / (m / dups);
- treport_maximized (samplestr, samples_per_second, TUNIT (SAMPLE, SECOND));
- treport_maximized (streamstr, samples_per_second / 44100.0, TUNIT_STREAM);
- //TPRINT (" samples / second = %f\n", samples_per_second);
- //TPRINT (" which means the resampler can process %.2f 44100 Hz streams simultaneusly\n",
samples_per_second / 44100.0);
- //TPRINT (" or one 44100 Hz stream takes %f %% CPU usage\n", 100.0 / (samples_per_second / 44100.0));
+ TMSG (" %-28s : %+.14f samples/second", samplestr, samples_per_second);
+ TMSG (" %-28s : %+.14f streams", streamstr, samples_per_second / 44100.0);
+ //TOUT (" samples / second = %f\n", samples_per_second);
+ //TOUT (" which means the resampler can process %.2f 44100 Hz streams simultaneusly\n",
samples_per_second / 44100.0);
+ //TOUT (" or one 44100 Hz stream takes %f %% CPU usage\n", 100.0 / (samples_per_second / 44100.0));
}
gsl_data_handle_close (rhandle);
gsl_data_handle_unref (rhandle);
@@ -195,7 +196,7 @@ run_tests (const char *run_type)
vector<float> input;
vector<double> expected;
// mono upsampling test
- if (!sfi_init_settings().test_quick)
+ if (Rapicorn::Test::slow())
{
generate_test_signal (input, LEN, 44100, 440);
generate_test_signal (expected, LEN * 2, 88200, 440);
@@ -215,7 +216,7 @@ run_tests (const char *run_type)
// g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
}
// mono downsampling test
- if (!sfi_init_settings().test_quick)
+ if (Rapicorn::Test::slow())
{
generate_test_signal (input, LEN, 44100, 440);
generate_test_signal (expected, LEN / 2, 22050, 440);
@@ -258,7 +259,7 @@ test_c_api (const char *run_type)
}
double error_db = bse_db_from_factor (error, -200);
bse_resampler2_destroy (resampler);
- TPRINT ("Test C API delta: %f\n", error_db);
+ TOUT ("Test C API delta: %f\n", error_db);
TASSERT (error_db < -95);
TDONE();
}
@@ -323,7 +324,7 @@ test_delay_compensation (const char *run_type)
delete resampler;
/* check error against bound */
double error_db = bse_db_from_factor (error, -250);
- TPRINT ("Resampler Delay Compensation delta: %f\n", error_db);
+ TOUT ("Resampler Delay Compensation delta: %f\n", error_db);
TASSERT (error_db < -params[p].error_db);
}
TDONE();
@@ -362,9 +363,9 @@ test_state_length (const char *run_type)
* implement with a loop handle, and it is inefficient because we read the
* samples one-by-one -> usually: don't use such code, always read in blocks */
int64 read_pos = (values_done + state_length) % (period_size * 2) + (period_size * 2 - state_length);
- TCHECK (read_pos >= state_length); /* check that input signal was long enough to be for this test */
+ TASSERT (read_pos >= state_length); /* check that input signal was long enough to be for this test
*/
int64 values_read = gsl_data_handle_read (rhandle, read_pos, 1, &output[values_done]);
- TCHECK (values_read == 1);
+ TASSERT (values_read == 1);
}
double error = 0;
for (size_t i = 0; i < output.size(); i++)
@@ -405,9 +406,9 @@ test_state_length (const char *run_type)
* implement with a loop handle, and it is inefficient because we read the
* samples one-by-one -> usually: don't use such code, always read in blocks */
int64 read_pos = (values_done + state_length) % (period_size / 2) + (period_size / 2 - state_length);
- TCHECK (read_pos >= state_length); /* check that input signal was long enough to be for this test */
+ TASSERT (read_pos >= state_length); /* check that input signal was long enough to be for this test
*/
int64 values_read = gsl_data_handle_read (rhandle, read_pos, 1, &output[values_done]);
- TCHECK (values_read == 1);
+ TASSERT (values_read == 1);
}
double error = 0;
for (size_t i = 0; i < output.size(); i++)
@@ -424,13 +425,11 @@ int
main (int argc,
char *argv[])
{
- sfi_init_test (&argc, &argv, NULL);
- { /* bse_init_test() usually does this for us */
- Bse::CPUInfo ci = Bse::cpu_info();
- char *cname = g_strdup_printf ("%s+%s", ci.machine, bse_block_impl_name());
- treport_cpu_name (cname);
- g_free (cname);
- }
+ // usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded
+ Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
+ Bse::CPUInfo ci = Rapicorn::cpu_info(); // usually done by bse_init_test
+ TMSG (" NOTE Running on: %s+%s", ci.machine, bse_block_impl_name());
+
test_c_api ("FPU");
test_delay_compensation ("FPU");
test_state_length ("FPU");
diff --git a/bse/tests/subnormals.cc b/bse/tests/subnormals.cc
index f106cf0..a19fb90 100644
--- a/bse/tests/subnormals.cc
+++ b/bse/tests/subnormals.cc
@@ -2,12 +2,12 @@
#include <bse/bse.hh>
#include <bse/bseieee754.hh>
#include <bse/bsemain.hh>
-//#define TEST_VERBOSE
-#include <birnet/birnettests.h>
+#include <rapicorn-test.hh>
#include <stdio.h>
#ifdef __SSE__
#include <xmmintrin.h>
#endif
+
#if 1
inline float test1f (float v) { return v; }
inline float test2f (float v) { return bse_float_zap_denormal (v); }
@@ -167,12 +167,13 @@ benchmark_subnormal_eliminations ()
if (0)
g_print ("subnormal cancellation times: keep=%fs zap=%fs inlined-cond=%fs if-cond=%fs arithmetic=%f
bse=%f\n",
test1_time, test2_time, test3_time, test4_time, test5_time, test6_time);
- treport_minimized ("Subnormals-keep", test1_time, TUNIT_SECOND);
- treport_minimized ("Subnormals-bse-zap", test2_time, TUNIT_SECOND);
- treport_minimized ("Subnormals-inlined-cond", test3_time, TUNIT_SECOND);
- treport_minimized ("Subnormals-if-cond", test4_time, TUNIT_SECOND);
- treport_minimized ("Subnormals-arithmetic", test5_time, TUNIT_SECOND);
- treport_minimized ("Subnormals-bse-flush", test6_time, TUNIT_SECOND);
+ constexpr const char *format = " %-28s : %+.14f milliseconds";
+ TMSG (format, "Subnormals-keep", test1_time * 1000);
+ TMSG (format, "Subnormals-bse-zap", test2_time * 1000);
+ TMSG (format, "Subnormals-inlined-cond", test3_time * 1000);
+ TMSG (format, "Subnormals-if-cond", test4_time * 1000);
+ TMSG (format, "Subnormals-arithmetic", test5_time * 1000);
+ TMSG (format, "Subnormals-bse-flush", test6_time * 1000);
}
bool
check_denormals_are_zero()
@@ -208,7 +209,6 @@ main (int argc,
test_correct_subnormal_elimination<test4d> ("if-cond-double");
test_correct_subnormal_elimination<test5d> ("arithmetic-double");
}
- if (sfi_init_settings().test_perf)
- benchmark_subnormal_eliminations();
+ benchmark_subnormal_eliminations();
return 0;
}
diff --git a/bse/tests/testfft.cc b/bse/tests/testfft.cc
index 2aa77bd..d35b768 100644
--- a/bse/tests/testfft.cc
+++ b/bse/tests/testfft.cc
@@ -3,11 +3,11 @@
#include <bse/bsemath.hh>
#include <bse/bsemain.hh>
#include <bse/gslfft.hh>
-// #define TEST_VERBOSE
-#include <birnet/birnettests.h>
+#include <rapicorn-test.hh>
#include <sys/time.h>
#include <stdlib.h>
#include <string.h>
+
#define MAX_FFT_SIZE (65536 * 2) // * 8 * 8
#define MAX_DFT_SIZE (1024 * 2) // * 8 * 8
#define EPSILON (4.8e-6)
@@ -84,42 +84,42 @@ main (int argc,
/* check differences */
d = diff (i << 1, 0, ref_fft_in, work_fft_in, "Checking input record");
if (d)
- TERROR ("Reference record was modified");
+ fatal ("Reference record was modified");
else
TOK();
d = diff (i << 1, 0, ref_fft_aout, work_fft_aout, "Reference analysis against GSL analysis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i << 1, 0, ref_fft_sout, work_fft_sout, "Reference synthesis against GSL synthesis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i << 1, 0, ref_fft_in, ref_fft_back, "Reference analysis and re-synthesis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i << 1, 0, work_fft_in, work_fft_back, "GSL analysis and re-synthesis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i << 1, 0, work_fft_in, scaled_fft_back, "GSL analysis and scaled re-synthesis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i << 1, 0, ref_fft_back, work_fft_back, "Reference re-synthesis vs. GSL");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i << 1, 0, ref_fft_back, scaled_fft_back, "Reference re-synthesis vs. scaled GSL");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
/* test with real data */
@@ -134,17 +134,17 @@ main (int argc,
gsl_power2_fftsr_scale (i, work_fft_aout, scaled_fft_back);
d = diff (i, 0, ref_fft_aout, work_fft_aout, "Reference real analysis vs. real GSL");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i, 0, work_fft_in, scaled_fft_back, "Real input vs. scaled real GSL resynthesis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
d = diff (i, 0, work_fft_in, work_fft_back, "Real input vs. real GSL resynthesis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
TDONE();
@@ -164,12 +164,12 @@ main (int argc,
/* check differences */
d = diff (i << 1, 0, ref_fft_in, dft_in, "Checking input record");
if (d)
- TERROR ("Input record was modified");
+ fatal ("Input record was modified");
else
TOK();
d = diff (i << 1, 0, ref_fft_aout, dft_aout, "Reference FFT analysis against reference DFT analysis");
if (fabs (d) > EPSILON)
- TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
+ fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
TDONE();
@@ -217,12 +217,12 @@ diff (guint m,
{
double d = 0, max = 0, min = 1e+32;
guint n;
- TPRINT ("%s\n", str);
+ TMSG ("%s\n", str);
for (n = 0; n < m; n++)
{
double a = ABS (a1[n] - a2[n]);
if (n < p)
- TPRINT ("%3u:%.3f) % 19.9f - % 19.9f = % 19.9f (% 19.9f)\n",
+ TMSG ("%3u:%.3f) % 19.9f - % 19.9f = % 19.9f (% 19.9f)\n",
n, ((float) n) / (float) m,
a1[n], a2[n],
a1[n] - a2[n],
@@ -231,12 +231,12 @@ diff (guint m,
max = MAX (max, a);
min = MIN (min, a);
}
- TPRINT ("Diff sum: %.9f, ", d);
- TPRINT ("min/av/max: %.9f %.9f %.9f, ", min, d / (double) m, max);
- TPRINT ("noise: %u %u %u\n",
- g_bit_storage (1. / min),
- g_bit_storage (m / d),
- g_bit_storage (1. / max));
+ TMSG ("Diff sum: %.9f, ", d);
+ TMSG ("min/av/max: %.9f %.9f %.9f, ", min, d / (double) m, max);
+ TMSG ("noise: %u %u %u\n",
+ g_bit_storage (1. / min),
+ g_bit_storage (m / d),
+ g_bit_storage (1. / max));
return d;
}
/* --- fft implementation --- */
diff --git a/sfi/Makefile.am b/sfi/Makefile.am
index 95e4d6c..9593882 100644
--- a/sfi/Makefile.am
+++ b/sfi/Makefile.am
@@ -21,7 +21,7 @@ sfi_all_sources = $(strip \
sfivmarshal.cc sfiglue.cc sfigluecodec.cc sfiglueproxy.cc \
sfinote.cc sfiparams.cc sfiserial.cc \
sfitime.cc sfitypes.cc sfivalues.cc sfiustore.cc \
- sficxx.cc sfiring.cc sfimemory.cc sficomport.cc \
+ sfiring.cc sfimemory.cc sficomport.cc \
$(conditional_toyprof_sources) \
)
sfi_extra_sources = $(strip \
diff --git a/sfi/sfitests.hh b/sfi/sfitests.hh
index 5d37207..24a135e 100644
--- a/sfi/sfitests.hh
+++ b/sfi/sfitests.hh
@@ -1,40 +1,87 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_TESTS_H__
#define __SFI_TESTS_H__
+
#include <sfi/sfi.hh>
-#include <birnet/birnettests.h>
-/* --- test initialization --- */
+#include <rapicorn-test.hh>
+
static void BIRNET_UNUSED
-sfi_init_test (int *argcp,
- char ***argvp,
- SfiInitValue *nvalues)
+sfi_init_test (int *argcp, char **argv)
{
- SfiInitValue empty_init_value = { NULL, };
- if (!nvalues)
- nvalues = &empty_init_value;
- SfiInitValue jvalues[] = {
- { "stand-alone", "true" },
- { "birnet-test-parse-args", "true" },
- { NULL }
- };
- guint i, j = 0, n = 0;
- while (jvalues[j].value_name)
- j++;
- while (nvalues[n].value_name)
- n++;
- SfiInitValue *iv = g_new (SfiInitValue, j + n + 1);
- for (i = 0; i < j; i++)
- iv[i] = jvalues[i];
- for (i = 0; i < n; i++)
- iv[j + i] = nvalues[i];
- iv[j + n] = empty_init_value;
- sfi_init (argcp, argvp, NULL, iv);
- g_free (iv);
+ sfi_init (argcp, argv, RAPICORN_PRETTY_FILE, Bse::cstrings_to_vector ("rapicorn-test-initialization=1",
NULL));
unsigned int flags = g_log_set_always_fatal ((GLogLevelFlags) G_LOG_FATAL_MASK);
g_log_set_always_fatal ((GLogLevelFlags) (flags | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL));
- g_printerr ("TEST: %s\n", g_get_prgname());
- /* check NULL definition, especially for 64bit */
- BIRNET_ASSERT (sizeof (NULL) == sizeof (void*));
}
+
+#define TICK() TOK()
+#define TACK() TOK()
+
+#ifndef _
+# define _(x) (x)
+# define Q_(x) (x)
+# define N_(x) (x)
+# define U_(x) (x)
+#endif
+
+/** Macro for test repetitions needed to benchmark in the order of milliseconds.
+ * TEST_CALIBRATION() - This macro is used to calculate the number of
+ * repetitions needed for execution of a test routine, so that the total
+ * duration is long enough to be measured by a timer with millisecond
+ * resolution like gettimeofday().
+ * Given an upper test duration bound, this macro will return the number
+ * of inner loop repetitions needed for benchmarking a piece of code.
+ * Estimated run time: the calibration process should take somewhat
+ * less than MIN (max_calibration_time, (target_ms * 2 * 7)) milliseconds.
+ * @li @c target_ms - expected total test runtime for RUNS * dups * testfunc_time
+ * @li @c max_calibration_time - expected upper bound for test calibration runtime
+ * In this macro, "dups" is calculated appropriately for max_calibration_time,
+ * and scaled upon return to match target_ms accordingly.
+ */
+#define TEST_CALIBRATION(target_ms, CODE) ({ \
+ const uint runs = 7; \
+ const double max_calibration_time = 35.0; \
+ double factor = MAX (1.0, (runs * target_ms * 2) / max_calibration_time); \
+ double ms, scaled_target_ms = target_ms / factor; \
+ GTimer *calibration_timer = false ? g_timer_new() : NULL; \
+ if (calibration_timer) \
+ g_timer_start (calibration_timer); \
+ GTimer *timer = g_timer_new(); \
+ guint dups = 1; \
+ /* birnet_thread_yield(); * on some OSes, this can stabelize the loop benches */ \
+ do \
+ { \
+ uint i, j; \
+ ms = 9e300; \
+ for (i = 0; i < runs && ms >= scaled_target_ms; i++) \
+ { \
+ g_timer_start (timer); \
+ for (j = 0; j < dups; j++) \
+ { \
+ CODE; \
+ } \
+ g_timer_stop (timer); \
+ double current_run_ms = g_timer_elapsed (timer, NULL) * 1000; \
+ ms = MIN (current_run_ms, ms); \
+ } \
+ if (ms < scaled_target_ms) \
+ dups *= 2; \
+ } \
+ while (ms < scaled_target_ms); \
+ factor *= (scaled_target_ms / ms); \
+ g_timer_destroy (timer); \
+ if (calibration_timer) \
+ { \
+ g_timer_stop (calibration_timer); \
+ double calibration_time_ms = g_timer_elapsed (calibration_timer, NULL) * 1000; \
+ g_timer_destroy (calibration_timer); \
+ g_printerr ("TEST_CALIBRATION: this system can do %d dups in %.6f milliseconds\n",\
+ (guint) (dups * factor), ms * factor); \
+ g_printerr ("TEST_CALIBRATION: calibration took %.6f milliseconds\n", \
+ calibration_time_ms); \
+ } \
+ dups = MAX ((uint) (dups * factor), 1); \
+ dups; \
+})
+
+
#endif /* __SFI_TESTS_H__ */
-/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiwrapper.cc b/sfi/sfiwrapper.cc
index 5cb7409..027d2ab 100644
--- a/sfi/sfiwrapper.cc
+++ b/sfi/sfiwrapper.cc
@@ -1,6 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "sfiwrapper.hh"
+#include "sficxx.hh"
#include <birnet/birnet.hh>
+#include <rapicorn-test.hh>
#include <errno.h>
namespace Bse {
@@ -44,37 +46,22 @@ bse_flipper_check (const char *key)
/* --- initialization --- */
void
-sfi_init (int *argcp,
- char ***argvp,
- const char *app_name,
- SfiInitValue sivalues[])
+sfi_init (int *argcp, char **argv, const char *app_name, const Bse::StringVector &args)
{
- BIRNET_STATIC_ASSERT (sizeof (SfiInitValue) == sizeof (BirnetInitValue));
- BIRNET_STATIC_ASSERT (offsetof (SfiInitValue, value_name) == offsetof (BirnetInitValue, value_name));
- BIRNET_STATIC_ASSERT (offsetof (SfiInitValue, value_string) == offsetof (BirnetInitValue, value_string));
- BIRNET_STATIC_ASSERT (offsetof (SfiInitValue, value_num) == offsetof (BirnetInitValue, value_num));
- Birnet::birnet_init (argcp, argvp, app_name, (BirnetInitValue*) sivalues);
-}
-bool
-sfi_init_value_bool (SfiInitValue *value)
-{
- return Birnet::init_value_bool ((BirnetInitValue*) value);
-}
-double
-sfi_init_value_double (SfiInitValue *value)
-{
- return Birnet::init_value_double ((BirnetInitValue*) value);
-}
-gint64
-sfi_init_value_int (SfiInitValue *value)
-{
- return Birnet::init_value_int ((BirnetInitValue*) value);
-}
-SfiInitSettings
-sfi_init_settings (void)
-{
- return ::Birnet::init_settings();
+ char *prg_name = argcp && *argcp ? g_path_get_basename (argv[0]) : NULL;
+ if (args.size() == 1 && args[0] == "rapicorn-test-initialization=1")
+ Rapicorn::init_core_test (app_name ? app_name : prg_name, argcp, argv);
+ else
+ Rapicorn::init_core (app_name ? app_name : prg_name, argcp, argv);
+
+ g_type_init (); /* just in case this hasn't been called already */
+ _sfi_init_values ();
+ _sfi_init_params ();
+ _sfi_init_time ();
+ _sfi_init_glue ();
+ _sfi_init_file_crawler ();
}
+
/* --- file testing --- */
bool
birnet_file_check (const char *file,
@@ -114,19 +101,3 @@ sfi_url_test_show_with_cookie (const char *url,
{
return Birnet::url_test_show_with_cookie (url, url_title, cookie);
}
-
-void
-sfi_runtime_problem (char ewran_tag,
- const char *domain,
- const char *file,
- int line,
- const char *funcname,
- const char *msgformat,
- ...)
-{
- va_list args;
- va_start (args, msgformat);
- ::Birnet::birnet_runtime_problemv (ewran_tag, domain, file, line, funcname, msgformat, args);
- va_end (args);
-}
-/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiwrapper.hh b/sfi/sfiwrapper.hh
index ea4afaf..4c5fe7f 100644
--- a/sfi/sfiwrapper.hh
+++ b/sfi/sfiwrapper.hh
@@ -60,15 +60,8 @@ typedef struct
const char *value_string;
long double value_num; /* valid if value_string == NULL */
} SfiInitValue;
-void sfi_init (int *argcp,
- char ***argvp,
- const char *app_name,
- SfiInitValue sivalues[]);
-bool sfi_init_value_bool (SfiInitValue *value);
-double sfi_init_value_double (SfiInitValue *value);
-gint64 sfi_init_value_int (SfiInitValue *value);
-typedef BirnetInitSettings SfiInitSettings;
-SfiInitSettings sfi_init_settings (void);
+void sfi_init (int *argcp, char **argv, const char *app_name, const Bse::StringVector &args =
Bse::StringVector());
+
/* --- file tests --- */
bool birnet_file_check (const char *file,
const char *mode);
diff --git a/sfi/tests/misctests.cc b/sfi/tests/misctests.cc
index 83e17ec..6b7a5d2 100644
--- a/sfi/tests/misctests.cc
+++ b/sfi/tests/misctests.cc
@@ -721,7 +721,7 @@ int
main (int argc,
char *argv[])
{
- sfi_init_test (&argc, &argv, NULL);
+ sfi_init_test (&argc, argv);
test_types_init ();
if (0)
{
diff --git a/sfi/tests/ring.cc b/sfi/tests/ring.cc
index 62f355b..3303d67 100644
--- a/sfi/tests/ring.cc
+++ b/sfi/tests/ring.cc
@@ -185,7 +185,7 @@ int
main (int argc,
char *argv[])
{
- sfi_init_test (&argc, &argv, NULL);
+ sfi_init_test (&argc, argv);
test_sfi_ring();
return 0;
}
diff --git a/sfi/tests/testcxx.cc b/sfi/tests/testcxx.cc
index 01246d4..77f0169 100644
--- a/sfi/tests/testcxx.cc
+++ b/sfi/tests/testcxx.cc
@@ -1,24 +1,30 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN __FILE__
-// #define TEST_VERBOSE
-#include <birnet/birnettests.h>
+#include <sfi/sfitests.hh>
#include "../sficxx.hh"
#include <stdio.h>
+
using namespace Sfi;
+
struct Bar {
int i;
};
+
typedef Sequence<Bar> BarSeq;
typedef Sequence<Int> IntSeq;
+
typedef struct {
guint n_elements;
Int *elements;
} CIntSeq;
+
int
main (int argc,
char *argv[])
{
+ sfi_init_test (&argc, argv);
+
TSTART ("Test String");
TASSERT (sizeof (String) == sizeof (const char*));
String s1 = "huhu";
diff --git a/sfi/tests/testsfidl.cc b/sfi/tests/testsfidl.cc
index d2db830..1d189a8 100644
--- a/sfi/tests/testsfidl.cc
+++ b/sfi/tests/testsfidl.cc
@@ -1,17 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN __FILE__
-// #define TEST_VERBOSE
-#include <birnet/birnettests.h>
+#include <sfi/sfitests.hh>
#include "../sfidl-generator.hh"
#include "../sfidl-factory.hh"
#include <stdio.h>
+
using namespace Sfidl;
using namespace std;
-#define ASSERT_EQ(got,expectedcstr) do { \
- TPRINT ("{check equality: %s == %s}", expectedcstr, got.c_str()); \
- TASSERT (expectedcstr == got); \
-} while (0)
+
+#define ASSERT_EQ(got,expectedcstr) TCMP (got, ==, expectedcstr)
+
class TestCG : public CodeGenerator
{
string one, two, done;
@@ -89,6 +88,7 @@ public:
return new TestCG (parser);
}
} static_factory;
+
int
main (int argc,
char *argv[])
diff --git a/shell/bsescm.cc b/shell/bsescm.cc
index d7c4900..815f51a 100644
--- a/shell/bsescm.cc
+++ b/shell/bsescm.cc
@@ -47,7 +47,7 @@ main (int argc,
{
const gchar *env_str;
GSource *source;
- sfi_init (&argc, &argv, "BSESCM", NULL);
+ sfi_init (&argc, argv, "BSESCM");
bse_init_textdomain_only();
setlocale (LC_ALL, "");
env_str = g_getenv ("BSESCM_SLEEP4GDB");
@@ -225,12 +225,12 @@ shell_parse_args (int *argc_p, char **argv)
else if (strcmp ("-p", argv[i]) == 0)
{
/* modify args for BSE */
- argv[i] = "--bse-pcm-driver";
+ argv[i] = (char*) "--bse-pcm-driver";
}
else if (strcmp ("-m", argv[i]) == 0)
{
/* modify args for BSE */
- argv[i] = "--bse-midi-driver";
+ argv[i] = (char*) "--bse-midi-driver";
}
else if (strcmp ("--bse-override-script-path", argv[i]) == 0 && i + 1 < argc)
{
diff --git a/tests/bse/Makefile.am b/tests/bse/Makefile.am
index e307547..821cb55 100644
--- a/tests/bse/Makefile.am
+++ b/tests/bse/Makefile.am
@@ -46,7 +46,7 @@ generated: clean-generated $(GENERATED)
# test programs
#
noinst_PROGRAMS = $(ALLTESTS)
-progs_ldadd = $(top_builddir)/bse/libbse.la $(BSE_LIBS)
+progs_ldadd = $(top_builddir)/bse/libbse.la $(RAPICORN_LIBS) $(BSE_LIBS)
SLOWTESTS += cxxbinding
cxxbinding_SOURCES = cxxbinding.cc bsecxxapi.cc
diff --git a/tests/bse/filtertest.cc b/tests/bse/filtertest.cc
index 06f707c..2f827b0 100644
--- a/tests/bse/filtertest.cc
+++ b/tests/bse/filtertest.cc
@@ -7,8 +7,7 @@
#include <bse/bsemath.hh>
#include <bse/bsemathsignal.hh>
#include <bse/gslfilter.hh>
-//#define TEST_VERBOSE
-#include <birnet/birnettests.h>
+#include <rapicorn-test.hh>
#include "topconfig.h"
#include <errno.h>
#include <stdlib.h>
@@ -208,8 +207,8 @@ private:
g_printerr ("\n*** check_response_db: computed response at frequency %f is %f\n", freq, resp);
g_printerr ("*** check_response_db: but should be in interval [%f..%f]\n", min_resp_db, max_resp_db);
}
- TCHECK (resp > min_resp_db - DB_EPSILON);
- TCHECK (resp < max_resp_db + DB_EPSILON);
+ TASSERT (resp > min_resp_db - DB_EPSILON);
+ TASSERT (resp < max_resp_db + DB_EPSILON);
}
void
check_band (const Band& band,
@@ -219,8 +218,8 @@ private:
const double delta_f = (FS / 2) / scan_points;
g_return_if_fail (band.freq_start <= band.freq_end);
g_return_if_fail (band.freq_end <= FS/2);
- TPRINT ("checking band: response in interval [%f..%f] should be in interval [%f..%f] dB\n",
- band.freq_start, band.freq_end, band.min_resp_db, band.max_resp_db);
+ TOUT ("checking band: response in interval [%f..%f] should be in interval [%f..%f] dB\n",
+ band.freq_start, band.freq_end, band.min_resp_db, band.max_resp_db);
int tok = 0;
int tok_dots = int ((FS / delta_f) / 50) + 1;
for (double f = band.freq_start; f < band.freq_end; f += delta_f)
diff --git a/tests/testresampler.cc b/tests/testresampler.cc
index facbf3e..75cce73 100644
--- a/tests/testresampler.cc
+++ b/tests/testresampler.cc
@@ -2,7 +2,7 @@
#include <bse/bseresampler.hh>
#include <bse/bseresamplerimpl.hh>
#include <bse/bseblockutils.hh>
-#include <birnet/birnettests.h>
+#include <rapicorn-test.hh>
#include <bse/bsemain.hh>
#include <bse/bsemath.hh>
#include <bse/bsemathsignal.hh>
diff --git a/tests/testresamplerq.cc b/tests/testresamplerq.cc
index c9a4d65..c1c3060 100644
--- a/tests/testresamplerq.cc
+++ b/tests/testresamplerq.cc
@@ -194,7 +194,11 @@ run_tests (const char *label)
int
main (int argc, char **argv)
{
- sfi_init_test (&argc, &argv, NULL);
+ // usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded
+ Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
+ Bse::CPUInfo ci = Rapicorn::cpu_info(); // usually done by bse_init_test
+ TMSG (" NOTE Running on: %s+%s", ci.machine, bse_block_impl_name());
+
if (argc > 1)
{
options.test_size = atoi (argv[1]);
@@ -208,6 +212,7 @@ main (int argc, char **argv)
g_print ("Resampler test parameters: test_size=%zd rand_samples=%zd\n",
options.test_size, options.rand_samples);
run_tests ("FPU");
+
/* load plugins */
bse_init_test (&argc, argv, Bse::cstrings_to_vector ("load-core-plugins=1", NULL));
/* check for possible specialization */
diff --git a/tests/testwavechunk.cc b/tests/testwavechunk.cc
index 757f7eb..b0f016b 100644
--- a/tests/testwavechunk.cc
+++ b/tests/testwavechunk.cc
@@ -180,10 +180,10 @@ reversed_datahandle_test (void)
{
gfloat d1[8], d2[8];
e = gsl_data_handle_read (myhandle, o, MIN (i, l), d1);
- TCHECK (e == MIN (i, l));
+ TASSERT (e == MIN (i, l));
e = gsl_data_handle_read (rhandle2, o, MIN (i, l), d2);
- TCHECK (e == MIN (i, l));
- TCHECK (memcmp (d1, d2, sizeof (d1[0]) * e) == 0);
+ TASSERT (e == MIN (i, l));
+ TASSERT (memcmp (d1, d2, sizeof (d1[0]) * e) == 0);
l -= e;
o += e;
}
@@ -215,13 +215,13 @@ simple_loop_tests (void)
static void
brute_force_loop_tests (void)
{
- gint i, j, k, count = 6;
+ gint i, count = 6;
for (i = 1; i <= count; i++)
{
TSTART ("brute force loop test %d/%d", i, 6);
- for (j = 0; j < my_data_length - 1; j++)
+ for (uint j = 0; j < my_data_length - 1; j++)
{
- for (k = j + 1; k < my_data_length; k++)
+ for (uint k = j + 1; k < my_data_length; k++)
{
run_loop_test (GSL_WAVE_LOOP_JUMP, 1, j, k, i);
run_loop_test (GSL_WAVE_LOOP_PINGPONG, 1, j, k, i);
@@ -312,7 +312,7 @@ multi_channel_test_one (int pingpong,
max_diff = MAX (max_diff, fabs (*f - expect[pos]));
pos++;
}
- TCHECK (max_diff < 1e-10);
+ TASSERT (max_diff < 1e-10);
gsl_wave_chunk_unuse_block (wchunk, &block);
block.offset = block.next_offset;
}
@@ -365,7 +365,7 @@ main (gint argc,
reversed_datahandle_test();
simple_loop_tests();
multi_channel_tests();
- if (sfi_init_settings().test_slow)
+ if (Rapicorn::Test::slow())
brute_force_loop_tests();
return 0;
}
diff --git a/tools/bsewavetool.cc b/tools/bsewavetool.cc
index 527eaeb..2129765 100644
--- a/tools/bsewavetool.cc
+++ b/tools/bsewavetool.cc
@@ -7,7 +7,7 @@
#include <bse/gslvorbis-enc.hh>
#include <bse/gsldatahandle-vorbis.hh>
#include <bse/bseresamplerimpl.hh>
-#include <birnet/birnettests.h>
+#include <rapicorn-test.hh>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
@@ -418,10 +418,10 @@ public:
for (int i = 0; decode_test[i].key; i++)
{
WaveChunkKey key = WaveChunkKey (decode_test[i].key);
- TCHECK (key.is_valid());
- TCHECK (fabs ((decode_test[i].value - key.osc_freq()) / decode_test[i].value) < epsilon);
+ TASSERT (key.is_valid());
+ TASSERT (fabs ((decode_test[i].value - key.osc_freq()) / decode_test[i].value) < epsilon);
if (i % 2 == 0)
- TICK();
+ TOK();
}
TDONE();
TSTART ("Encoding chunk keys");
@@ -430,10 +430,10 @@ public:
{
WaveChunkKey encoded_key (value);
WaveChunkKey decoded_key (encoded_key.as_string());
- TCHECK (decoded_key.is_valid());
- TCHECK (fabs ((value - decoded_key.osc_freq()) / value) < epsilon);
+ TASSERT (decoded_key.is_valid());
+ TASSERT (fabs ((value - decoded_key.osc_freq()) / value) < epsilon);
if (i++ % 150 == 0)
- TICK();
+ TOK();
}
TDONE();
TSTART ("Invalid chunk keys");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]