Add crc test.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 27 Sep 2009 09:25:02 +0000 (09:25 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 27 Sep 2009 09:25:02 +0000 (09:25 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2974 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/algo/crc_test.c [new file with mode: 0644]
test/run_tests.sh

diff --git a/bertos/algo/crc_test.c b/bertos/algo/crc_test.c
new file mode 100644 (file)
index 0000000..7e2908d
--- /dev/null
@@ -0,0 +1,76 @@
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction.  Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License.  This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief CRC-CCITT table and support routines
+ *
+ * \version $Id: crc.c 2770 2009-08-05 07:57:59Z  $
+ * \author Francesco Sacchi <batt@develer.com>
+ */
+
+#include "crc_ccitt.h"
+#include "crc.h"
+
+#include <cfg/debug.h>
+#include <cfg/test.h>
+
+
+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);
index fde41fc190d474357c29592a1e1c7932b7032d2c..e925ebcbe3d6ddf94beb7a1c991dacfa565ed44b 100755 (executable)
@@ -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'