From 610ff3b76562e9f6e7ca7e21a4fe3b094d205901 Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Wed, 28 Sep 2011 20:28:48 +0200 Subject: [PATCH] unit-test.h is now generated to avoid config.h dependency --- .gitignore | 1 + configure.ac | 8 +++----- tests/unit-test.h | 62 -------------------------------------------------------------- tests/unit-test.h.in | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 67 deletions(-) delete mode 100644 tests/unit-test.h create mode 100644 tests/unit-test.h.in diff --git a/.gitignore b/.gitignore index ddd7705..2f38378 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ tests/bandwidth-server-one tests/random-test-client tests/random-test-server tests/unit-test-client +tests/unit-test.h tests/unit-test-server tests/version doc/*.html diff --git a/configure.ac b/configure.ac index 39d3160..0d9bc8c 100644 --- a/configure.ac +++ b/configure.ac @@ -16,17 +16,15 @@ m4_define([libmodbus_version_minor], [0]) m4_define([libmodbus_version_micro], [1]) m4_define([libmodbus_release_status], - [m4_if(m4_eval(libmodbus_version_minor % 2), [1], [snapshot], - [release])]) + [m4_if(m4_eval(libmodbus_version_minor % 2), [1], [snapshot], [release])]) m4_define([libmodbus_version], - [libmodbus_version_major.libmodbus_version_minor.libmodbus_version_micro]) + [libmodbus_version_major.libmodbus_version_minor.libmodbus_version_micro]) AC_PREREQ([2.63]) AC_INIT([libmodbus],[libmodbus_version], [https://github.com/stephane/libmodbus/issues]) -AC_CONFIG_SRCDIR([src/modbus.c]) -AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([config.h tests/unit-test.h]) AM_INIT_AUTOMAKE([foreign]) # enable nice build output on automake1.11 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) diff --git a/tests/unit-test.h b/tests/unit-test.h deleted file mode 100644 index 78575c1..0000000 --- a/tests/unit-test.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2008-2010 Stéphane Raimbault - * - * This program 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 3 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, see . - */ - -#ifndef _UNIT_TEST_H_ -#define _UNIT_TEST_H_ - -#include - -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_STDINT_H -# ifndef _MSC_VER -# include -# else -# include "stdint.h" -# endif -#endif - -#define SERVER_ID 17 -#define INVALID_SERVER_ID 18 - -const uint16_t UT_BITS_ADDRESS = 0x13; -const uint16_t UT_BITS_NB = 0x25; -const uint8_t UT_BITS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B }; - -const uint16_t UT_INPUT_BITS_ADDRESS = 0xC4; -const uint16_t UT_INPUT_BITS_NB = 0x16; -const uint8_t UT_INPUT_BITS_TAB[] = { 0xAC, 0xDB, 0x35 }; - -const uint16_t UT_REGISTERS_ADDRESS = 0x6B; -/* Raise a manual exception when this adress is used for the first byte */ -const uint16_t UT_REGISTERS_ADDRESS_SPECIAL = 0x6C; -const uint16_t UT_REGISTERS_NB = 0x3; -const uint16_t UT_REGISTERS_TAB[] = { 0x022B, 0x0001, 0x0064 }; -/* If the following value is used, a bad response is sent. - It's better to test with a lower value than - UT_REGISTERS_NB_POINTS to try to raise a segfault. */ -const uint16_t UT_REGISTERS_NB_SPECIAL = 0x2; - -const uint16_t UT_INPUT_REGISTERS_ADDRESS = 0x08; -const uint16_t UT_INPUT_REGISTERS_NB = 0x1; -const uint16_t UT_INPUT_REGISTERS_TAB[] = { 0x000A }; - -const float UT_REAL = 916.540649; -const uint32_t UT_IREAL = 0x4465229a; - -#endif /* _UNIT_TEST_H_ */ diff --git a/tests/unit-test.h.in b/tests/unit-test.h.in new file mode 100644 index 0000000..d2aa14c --- /dev/null +++ b/tests/unit-test.h.in @@ -0,0 +1,64 @@ +/* + * Copyright © 2008-2011 Stéphane Raimbault + * + * This program 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 3 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, see . + */ + +#ifndef _UNIT_TEST_H_ +#define _UNIT_TEST_H_ + +/* Constants defined by configure.ac */ +#define HAVE_INTTYPES_H @HAVE_INTTYPES_H@ +#define HAVE_STDINT_H @HAVE_STDINT_H@ + +#ifdef HAVE_INTTYPES_H +#include +#endif +#ifdef HAVE_STDINT_H +# ifndef _MSC_VER +# include +# else +# include "stdint.h" +# endif +#endif + +#define SERVER_ID 17 +#define INVALID_SERVER_ID 18 + +const uint16_t UT_BITS_ADDRESS = 0x13; +const uint16_t UT_BITS_NB = 0x25; +const uint8_t UT_BITS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B }; + +const uint16_t UT_INPUT_BITS_ADDRESS = 0xC4; +const uint16_t UT_INPUT_BITS_NB = 0x16; +const uint8_t UT_INPUT_BITS_TAB[] = { 0xAC, 0xDB, 0x35 }; + +const uint16_t UT_REGISTERS_ADDRESS = 0x6B; +/* Raise a manual exception when this adress is used for the first byte */ +const uint16_t UT_REGISTERS_ADDRESS_SPECIAL = 0x6C; +const uint16_t UT_REGISTERS_NB = 0x3; +const uint16_t UT_REGISTERS_TAB[] = { 0x022B, 0x0001, 0x0064 }; +/* If the following value is used, a bad response is sent. + It's better to test with a lower value than + UT_REGISTERS_NB_POINTS to try to raise a segfault. */ +const uint16_t UT_REGISTERS_NB_SPECIAL = 0x2; + +const uint16_t UT_INPUT_REGISTERS_ADDRESS = 0x08; +const uint16_t UT_INPUT_REGISTERS_NB = 0x1; +const uint16_t UT_INPUT_REGISTERS_TAB[] = { 0x000A }; + +const float UT_REAL = 916.540649; +const uint32_t UT_IREAL = 0x4465229a; + +#endif /* _UNIT_TEST_H_ */ -- libgit2 0.21.4