From: batt Date: Sun, 27 Sep 2009 09:25:02 +0000 (+0000) Subject: Add crc test. X-Git-Tag: 2.3.0~106 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=507cbd27346b1f046cd148cf7e94d78178ab233b;p=bertos.git Add crc test. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2974 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/algo/crc_test.c b/bertos/algo/crc_test.c new file mode 100644 index 00000000..7e2908d1 --- /dev/null +++ b/bertos/algo/crc_test.c @@ -0,0 +1,76 @@ +/** + * \file + * + * + * \brief CRC-CCITT table and support routines + * + * \version $Id: crc.c 2770 2009-08-05 07:57:59Z $ + * \author Francesco Sacchi + */ + +#include "crc_ccitt.h" +#include "crc.h" + +#include +#include + + +int crc_testSetup(void) +{ + kdbg_init(); + return 0; +} + +int crc_testTearDown(void) +{ + return 0; +} + +int crc_testRun(void) +{ + char vector[9] = "123456789"; + + uint16_t crc = CRC_CCITT_INIT_VAL; + + crc = crc_ccitt(crc, vector, sizeof(vector)); + kprintf("crc_ccitt [%04X]\n", crc); + ASSERT(crc == 0x6F91); + + crc = CRC16_INIT_VAL; + crc = crc16(crc, vector, sizeof(vector)); + kprintf("crc16 [%04X]\n", crc); + ASSERT(crc == 0x31C3); + + return 0; +} + +TEST_MAIN(crc); diff --git a/test/run_tests.sh b/test/run_tests.sh index fde41fc1..e925ebcb 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -28,7 +28,7 @@ TESTS=${TESTS:-`find . \ -o -name "*_test.c" -print` } TESTOUT="testout" -SRC_LIST="bertos/algo/ramp.c bertos/drv/kdebug.c bertos/drv/timer.c bertos/fs/battfs.c bertos/kern/coop.c bertos/kern/idle.c bertos/kern/kfile.c bertos/kern/monitor.c bertos/kern/proc.c bertos/kern/signal.c bertos/kern/sem.c bertos/mware/event.c bertos/mware/formatwr.c bertos/mware/hex.c bertos/mware/sprintf.c bertos/os/hptime.c bertos/struct/kfile_fifo.c bertos/fs/fatfs/ff.c bertos/emul/diskio_emul.c bertos/fs/fat.c bertos/emul/switch_ctx_emul.S bertos/mware/ini_reader.c bertos/emul/kfile_posix.c" +SRC_LIST="bertos/algo/ramp.c bertos/drv/kdebug.c bertos/drv/timer.c bertos/fs/battfs.c bertos/kern/coop.c bertos/kern/idle.c bertos/kern/kfile.c bertos/kern/monitor.c bertos/kern/proc.c bertos/kern/signal.c bertos/kern/sem.c bertos/mware/event.c bertos/mware/formatwr.c bertos/mware/hex.c bertos/mware/sprintf.c bertos/os/hptime.c bertos/struct/kfile_fifo.c bertos/fs/fatfs/ff.c bertos/emul/diskio_emul.c bertos/fs/fat.c bertos/emul/switch_ctx_emul.S bertos/mware/ini_reader.c bertos/emul/kfile_posix.c bertos/algo/crc_ccitt.c bertos/algo/crc.c" buildout='/dev/null' runout='/dev/null'