From 007211e8705d793c2b4e7d75031d08c4d5fa250d Mon Sep 17 00:00:00 2001 From: batt Date: Fri, 29 Aug 2008 22:11:21 +0000 Subject: [PATCH] Fix ramp_test. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1764 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/algo/ramp.h | 4 +++- bertos/algo/ramp_test.c | 44 +++++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/bertos/algo/ramp.h b/bertos/algo/ramp.h index 202441f4..2ec9018a 100644 --- a/bertos/algo/ramp.h +++ b/bertos/algo/ramp.h @@ -197,7 +197,9 @@ void ramp_default(struct Ramp *ramp); /** Self test */ -void ramp_test(void); +int ramp_testSetup(void); +int ramp_testRun(void); +int ramp_testTearDown(void); #endif /* ALGO_RAMP_H */ diff --git a/bertos/algo/ramp_test.c b/bertos/algo/ramp_test.c index da09e6b0..cecea430 100644 --- a/bertos/algo/ramp_test.c +++ b/bertos/algo/ramp_test.c @@ -104,8 +104,8 @@ #include "ramp.h" #include +#include -#warning FIXME:Review and refactor this test.. static bool ramp_test_single(uint32_t minFreq, uint32_t maxFreq, uint32_t length) { @@ -120,8 +120,8 @@ static bool ramp_test_single(uint32_t minFreq, uint32_t maxFreq, uint32_t length clock = 0; oldclock = 0; - kprintf("testing ramp: (length=%lu, min=%lu, max=%lu)\n", length, minFreq, maxFreq); - kprintf(" [length=%lu, max=%04x, min=%04x]\n", r.clocksRamp, r.clocksMaxWL, r.clocksMinWL); + kprintf("testing ramp: (length=%lu, min=%lu, max=%lu)\n", (unsigned long)length, (unsigned long)minFreq, (unsigned long)maxFreq); + kprintf(" [length=%lu, max=%04x, min=%04x]\n", (unsigned long)r.clocksRamp, r.clocksMaxWL, r.clocksMinWL); int i = 0; int nonbyte = 0; @@ -141,7 +141,7 @@ static bool ramp_test_single(uint32_t minFreq, uint32_t maxFreq, uint32_t length uint16_t denom1 = FIX_MULT32((uint16_t)((~t1) + 1), r.precalc.max_div_min) + t1; uint16_t denom2 = FIX_MULT32((uint16_t)((~t2) + 1), r.precalc.max_div_min) + t2; - kprintf(" Failed: %04x @ %lu --> %04x @ %lu\n", old, oldclock, cur, clock); + kprintf(" Failed: %04x @ %lu --> %04x @ %lu\n", old, (unsigned long)oldclock, cur, (unsigned long)clock); kprintf(" T: %04x -> %04x\n", t1, t2); kprintf(" DENOM: %04x -> %04x\n", denom1, denom2); @@ -155,23 +155,41 @@ static bool ramp_test_single(uint32_t minFreq, uint32_t maxFreq, uint32_t length - kprintf("Test finished: %04x @ %lu [min=%04x, totlen=%lu, numsteps:%d, nonbyte:%d]\n", cur, clock, r.clocksMinWL, r.clocksRamp, i, nonbyte); + kprintf("Test finished: %04x @ %lu [min=%04x, totlen=%lu, numsteps:%d, nonbyte:%d]\n", cur, (unsigned long)clock, r.clocksMinWL, (unsigned long)r.clocksRamp, i, nonbyte); return true; } +int ramp_testSetup(void) +{ + kdbg_init(); + return 0; +} + +int ramp_testTearDown(void) +{ + return 0; +} -void ramp_test(void) +int ramp_testRun(void) { - bool ok = true; + #define TEST_RAMP(min, max, len) do { \ + if (!ramp_test_single(min, max, len)) \ + return -1; \ + } while(0) - ok = ramp_test_single(200, 5000, 3000000) && ok; - ok = ramp_test_single(1000, 2000, 1000000) && ok; + TEST_RAMP(200, 5000, 3000000); + TEST_RAMP(1000, 2000, 1000000); - if (ok) - kputs("Ramp test succeeded!\n"); - else - kputs("Ramp test fail!\n"); + return 0; } +#if UNIT_TEST + #include "ramp.c" + #include + #include + #include + + TEST_MAIN(ramp); +#endif -- 2.25.1