[beast: 1/17] BSE: tests: use TPASS/TCHECK for test output
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 1/17] BSE: tests: use TPASS/TCHECK for test output
- Date: Fri, 20 Nov 2015 22:07:15 +0000 (UTC)
commit f52c28ca8c2f49bbfbc43f0662121e8fc3b86177
Author: Tim Janik <timj gnu org>
Date: Mon Nov 9 10:18:27 2015 +0100
BSE: tests: use TPASS/TCHECK for test output
Signed-off-by: Tim Janik <timj gnu org>
bse/bsemain.cc | 2 +-
bse/tests/blocktests.cc | 8 ++--
bse/tests/firhandle.cc | 18 ++++----
bse/tests/resamplehandle.cc | 17 +++----
bse/tests/subnormals.cc | 12 +++---
bse/tests/testfft.cc | 99 +++++++++++--------------------------------
6 files changed, 52 insertions(+), 104 deletions(-)
---
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 68fe745..bc9e071 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -185,7 +185,7 @@ bse_init_intern()
{
StringVector sv = Rapicorn::string_split (Rapicorn::cpu_info(), " ");
String machine = sv.size() >= 2 ? sv[1] : "Unknown";
- TMSG (" NOTE Running on: %s+%s", machine.c_str(), bse_block_impl_name());
+ Test::tprintout (" NOTE Running on: %s+%s", machine.c_str(), bse_block_impl_name());
}
}
diff --git a/bse/tests/blocktests.cc b/bse/tests/blocktests.cc
index f2933c2..11c1237 100644
--- a/bse/tests/blocktests.cc
+++ b/bse/tests/blocktests.cc
@@ -6,7 +6,7 @@
static void
report_usecs (const char *what, double usecs)
{
- TMSG (" %-28s : %+.14f µseconds", what, usecs);
+ TPASS (" %-28s : %+.14f µseconds", what, usecs);
}
template<typename T> static bool
@@ -155,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);
- TOUT ("sine wave: energy = %f, energy_db = %f\n", energy, energy_db);
+ TPASS ("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);
@@ -163,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);
- TOUT ("square wave: energy = %f, energy_db = %f\n", energy, energy_db);
+ TPASS ("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);
@@ -530,7 +530,7 @@ main (int argc,
Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
Rapicorn::StringVector sv = Rapicorn::string_split (Rapicorn::cpu_info(), " ");
Rapicorn::String machine = sv.size() >= 2 ? sv[1] : "Unknown";
- TMSG (" NOTE Running on: %s+%s", machine.c_str(), bse_block_impl_name()); // usually done by
bse_init_test
+ printout (" NOTE Running on: %s+%s\n", machine.c_str(), bse_block_impl_name()); // usually done by
bse_init_test
TSTART ("Running Default Block Ops");
TASSERT (Bse::Block::default_singleton() == Bse::Block::current_singleton());
diff --git a/bse/tests/firhandle.cc b/bse/tests/firhandle.cc
index 40cd6d4..5e6c9ed 100644
--- a/bse/tests/firhandle.cc
+++ b/bse/tests/firhandle.cc
@@ -252,12 +252,12 @@ test_with_sine_sweep (FirHandleType type)
m = e;
}
samples_per_second = sweep_sin.size() / (m / dups);
- TMSG (" %-28s : %+.14f samples/second",
- string_format ("%s O64 mono", handle_name (type)).c_str(),
- samples_per_second);
- TMSG (" %-28s : %+.14f streams",
- string_format ("CPU %s mono", handle_name (type)).c_str(),
- samples_per_second / 44100.0);
+ printout (" %-28s : %+.14f samples/second",
+ string_format ("%s O64 mono", handle_name (type)).c_str(),
+ samples_per_second);
+ printout (" %-28s : %+.14f streams",
+ string_format ("CPU %s mono", handle_name (type)).c_str(),
+ samples_per_second / 44100.0);
}
}
@@ -332,9 +332,9 @@ test_multi_channel (FirHandleType type)
worst_diff = max (filtered - expected[i], worst_diff);
}
double worst_diff_db = bse_db_from_factor (worst_diff, -200);
- 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);
+ double max_db = -90;
+ TCHECK (worst_diff_db < -90, "MultiChannel worst_diff check, n=%d r=%d d=%f db: %f < %f",
+ n_channels, repeat, worst_diff, worst_diff_db, max_db);
}
}
TDONE();
diff --git a/bse/tests/resamplehandle.cc b/bse/tests/resamplehandle.cc
index 2c8c0fb..dd4294f 100644
--- a/bse/tests/resamplehandle.cc
+++ b/bse/tests/resamplehandle.cc
@@ -91,7 +91,7 @@ check (const char *up_down,
worst_diff = max (fabs (resampled - expected[i]), worst_diff);
}
worst_diff_db = bse_db_from_factor (worst_diff, -200);
- TOUT ("linear(%dst read) read worst_diff = %f (%f dB)\n", repeat, worst_diff, worst_diff_db);
+ TPASS ("linear(%dst read) read worst_diff = %f (%f dB)", repeat, worst_diff, worst_diff_db);
TASSERT (worst_diff_db < max_db);
}
@@ -111,8 +111,7 @@ check (const char *up_down,
}
}
worst_diff_db = bse_db_from_factor (worst_diff, -200);
- TOUT ("seek worst_diff = %f (%f dB)\n", worst_diff, worst_diff_db);
- TASSERT (worst_diff_db < max_db);
+ TCHECK (worst_diff_db < max_db, "seeking worst_diff (%f dB) below epsilon: %f < %f", worst_diff_db,
worst_diff_db, max_db);
TDONE();
@@ -136,8 +135,8 @@ check (const char *up_down,
m = e;
}
samples_per_second = input.size() / (m / dups);
- TMSG (" %-28s : %+.14f samples/second", samplestr, samples_per_second);
- TMSG (" %-28s : %+.14f streams", streamstr, samples_per_second / 44100.0);
+ TPASS (" %-28s : %+.14f samples/second", samplestr, samples_per_second);
+ TPASS (" %-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));
@@ -285,8 +284,7 @@ test_c_api (const char *run_type)
}
double error_db = bse_db_from_factor (error, -200);
bse_resampler2_destroy (resampler);
- TOUT ("Test C API delta: %f\n", error_db);
- TASSERT (error_db < -95);
+ TCHECK (error_db < -95, "C API delta below epsilon: %f < -95\n", error_db);
TDONE();
}
static void
@@ -360,8 +358,7 @@ test_delay_compensation (const char *run_type)
/* check error against bound */
double error_db = bse_db_from_factor (error, -250);
- TOUT ("Resampler Delay Compensation delta: %f\n", error_db);
- TASSERT (error_db < -params[p].error_db);
+ TCHECK (error_db < -params[p].error_db, "Resampler Delay Compensation delta below epsilon: %f < %f\n",
error_db, -params[p].error_db);
}
TDONE();
}
@@ -479,7 +476,7 @@ main (int argc,
Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
Rapicorn::StringVector sv = Rapicorn::string_split (Rapicorn::cpu_info(), " ");
Rapicorn::String machine = sv.size() >= 2 ? sv[1] : "Unknown";
- TMSG (" NOTE Running on: %s+%s", machine.c_str(), bse_block_impl_name()); // usually done by
bse_init_test
+ printout (" NOTE Running on: %s+%s", machine.c_str(), bse_block_impl_name()); // usually done by
bse_init_test
test_c_api ("FPU");
test_delay_compensation ("FPU");
diff --git a/bse/tests/subnormals.cc b/bse/tests/subnormals.cc
index f4d0750..ca8df41 100644
--- a/bse/tests/subnormals.cc
+++ b/bse/tests/subnormals.cc
@@ -169,12 +169,12 @@ benchmark_subnormal_eliminations ()
printout ("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);
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);
+ TPASS (format, "Subnormals-keep", test1_time * 1000);
+ TPASS (format, "Subnormals-bse-zap", test2_time * 1000);
+ TPASS (format, "Subnormals-inlined-cond", test3_time * 1000);
+ TPASS (format, "Subnormals-if-cond", test4_time * 1000);
+ TPASS (format, "Subnormals-arithmetic", test5_time * 1000);
+ TPASS (format, "Subnormals-bse-flush", test6_time * 1000);
}
bool
check_denormals_are_zero()
diff --git a/bse/tests/testfft.cc b/bse/tests/testfft.cc
index b822a58..fe276ff 100644
--- a/bse/tests/testfft.cc
+++ b/bse/tests/testfft.cc
@@ -66,8 +66,6 @@ main (int argc,
{
double d;
- TSTART ("Testing fft code for size %u", i);
-
/* setup reference and work fft records */
fill_rand (i << 1, ref_fft_in);
// memset (ref_fft_aout, 0, MAX_FFT_SIZE * sizeof (ref_fft_aout[0]));
@@ -91,45 +89,21 @@ main (int argc,
/* check differences */
d = diff (i << 1, 0, ref_fft_in, work_fft_in, "Checking input record");
- if (d)
- fatal ("Reference record was modified");
- else
- TOK();
+ TCHECK (d == 0, "FFT-%u reference record is unmodified", i);
d = diff (i << 1, 0, ref_fft_aout, work_fft_aout, "Reference analysis against GSL analysis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i << 1, 0, ref_fft_sout, work_fft_sout, "Reference synthesis against GSL synthesis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i << 1, 0, ref_fft_in, ref_fft_back, "Reference analysis and re-synthesis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i << 1, 0, work_fft_in, work_fft_back, "GSL analysis and re-synthesis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i << 1, 0, work_fft_in, scaled_fft_back, "GSL analysis and scaled re-synthesis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i << 1, 0, ref_fft_back, work_fft_back, "Reference re-synthesis vs. GSL");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i << 1, 0, ref_fft_back, scaled_fft_back, "Reference re-synthesis vs. scaled GSL");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
/* test with real data */
make_real (i << 1, ref_fft_in);
extract_real (i << 1, ref_fft_in, work_fft_in);
@@ -141,21 +115,11 @@ main (int argc,
scale_block (i, work_fft_back, 1.0 / i);
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)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i, 0, work_fft_in, scaled_fft_back, "Real input vs. scaled real GSL resynthesis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
d = diff (i, 0, work_fft_in, work_fft_back, "Real input vs. real GSL resynthesis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
- TDONE();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
}
static double dft_in[MAX_DFT_SIZE] = { 0, };
static double dft_aout[MAX_DFT_SIZE] = { 0, };
@@ -163,7 +127,6 @@ main (int argc,
for (i = 2; i <= MAX_DFT_SIZE >> 1; i <<= 1)
{
double d;
- TSTART ("Checking reference fft for size %u", i);
/* setup reference and work fft records */
fill_rand (i << 1, ref_fft_in);
memcpy (dft_in, ref_fft_in, MAX_DFT_SIZE * sizeof (dft_in[0]));
@@ -171,16 +134,9 @@ main (int argc,
reference_dftc (i, dft_in, dft_aout);
/* check differences */
d = diff (i << 1, 0, ref_fft_in, dft_in, "Checking input record");
- if (d)
- fatal ("Input record was modified");
- else
- TOK();
+ TCHECK (d == 0, "FFT-%u reference record is unmodified", i);
d = diff (i << 1, 0, ref_fft_aout, dft_aout, "Reference FFT analysis against reference DFT analysis");
- if (fabs (d) > EPSILON)
- fatal ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
- else
- TOK();
- TDONE();
+ TCHECK (fabs (d) < EPSILON, "Error sum in analysis FFT-%u below epsilon: %g < %g", i, d, EPSILON);
}
return 0;
}
@@ -222,34 +178,29 @@ scale_block (guint n,
}
static double
-diff (guint m,
- guint p,
- double *a1,
- double *a2,
- const gchar *str)
+diff (uint m, uint p, double *a1, double *a2, const char *str)
{
double d = 0, max = 0, min = 1e+32;
guint n;
- TMSG ("%s\n", str);
for (n = 0; n < m; n++)
{
double a = ABS (a1[n] - a2[n]);
if (n < p)
- 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],
- a1[n] / a2[n]);
+ Rapicorn::Test::tprintout (" TESTFFT %3u:%.3f) % 19.9f - % 19.9f = % 19.9f (% 19.9f)\n",
+ n, ((float) n) / (float) m,
+ a1[n], a2[n],
+ a1[n] - a2[n],
+ a1[n] / a2[n]);
d += a;
max = MAX (max, a);
min = MIN (min, a);
}
- 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));
+ Rapicorn::Test::tprintout (" TESTFFT Diff sum: %.9f, ", d);
+ Rapicorn::Test::tprintout ("min/av/max: %.9f %.9f %.9f, ", min, d / (double) m, max);
+ Rapicorn::Test::tprintout ("noise: %u %u %u\n",
+ g_bit_storage (1. / min),
+ g_bit_storage (m / d),
+ g_bit_storage (1. / max));
return d;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]