Feature/zephyr ztest (#118)

* Leverage (older) embedded unit tests into external unit tests build upon copy of Zephyr's ztest library and CMake.

* Expand top-level CMake build to run external unit tests.

* Expand Zephyr module extension to run external unit tests via west or sanitycheck.

Co-authored-by: Gregory Shue <gregory.shue@legrand.us>
This commit is contained in:
Greg Shue
2020-09-16 05:33:34 -07:00
committed by GitHub
parent a7b2e94cb7
commit 19869dccdb
399 changed files with 21885 additions and 5 deletions
+81
View File
@@ -0,0 +1,81 @@
/**************************************************************************
*
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************/
#ifndef BITS_H
#define BITS_H
#include <sys/util.h> /* defines BIT(n) */
/********************************************************************
* Bit Masks
*********************************************************************/
#define BIT0 BIT( 0)
#define BIT1 BIT( 1)
#define BIT2 BIT( 2)
#define BIT3 BIT( 3)
#define BIT4 BIT( 4)
#define BIT5 BIT( 5)
#define BIT6 BIT( 6)
#define BIT7 BIT( 7)
#define BIT8 BIT( 8)
#define BIT9 BIT( 9)
#define BIT10 BIT(10)
#define BIT11 BIT(11)
#define BIT12 BIT(12)
#define BIT13 BIT(13)
#define BIT14 BIT(14)
#define BIT15 BIT(15)
#define BIT16 BIT(16)
#define BIT17 BIT(17)
#define BIT18 BIT(18)
#define BIT19 BIT(19)
#define BIT20 BIT(20)
#define BIT21 BIT(21)
#define BIT22 BIT(22)
#define BIT23 BIT(23)
#define BIT24 BIT(24)
#define BIT25 BIT(25)
#define BIT26 BIT(26)
#define BIT27 BIT(27)
#define BIT28 BIT(28)
#define BIT29 BIT(29)
#define BIT30 BIT(30)
#define BIT31 BIT(31)
/* a=register, b=bit number to act upon 0-n */
#define BIT_SET(a,b) ((a) |= (1<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
#define BIT_FLIP(a,b) ((a) ^= (1<<(b)))
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
/* x=target variable, y=mask */
#define BITMASK_SET(x,y) ((x) |= (y))
#define BITMASK_CLEAR(x,y) ((x) &= (~(y)))
#define BITMASK_FLIP(x,y) ((x) ^= (y))
#define BITMASK_CHECK(x,y) (((x) & (y)) == (y))
#ifndef _BV
#define _BV(x) (1<<(x))
#endif
#endif
+110
View File
@@ -0,0 +1,110 @@
/**************************************************************************
*
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************/
#ifndef ETHERNET_H
#define ETHERNET_H
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/npdu.h"
/* specific defines for Ethernet */
#define MAX_HEADER (6+6+2+1+1+1)
#define MAX_MPDU (MAX_HEADER+MAX_PDU)
/* Unless we explicitly need these remaps to be NOT exposed
* (e.g. implementation where we need both bacnet and Zephyr symbols),
* replace the BACnet Ethernet API symbols with non-conflicting ones.
*/
#if !defined(BACNET_ETHERNET_NO_REMAP_DEFINES)
#define ethernet_valid bacnet_ethernet_valid
#define ethernet_cleanup bacnet_ethernet_cleanup
#define ethernet_init bacnet_ethernet_init
#define ethernet_send_pdu bacnet_ethernet_send_pdu
#define ethernet_receive bacnet_ethernet_receive
#define ethernet_set_my_address bacnet_ethernet_set_my_address
#define ethernet_get_my_address bacnet_ethernet_get_my_address
#define ethernet_get_broadcast_address bacnet_ethernet_get_broadcast_address
#define ethernet_debug_address bacnet_ethernet_debug_address
#define ethernet_send bacnet_ethernet_send
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
bool bacnet_ethernet_valid(
void);
BACNET_STACK_EXPORT
void bacnet_ethernet_cleanup(
void);
BACNET_STACK_EXPORT
bool bacnet_ethernet_init(
char *interface_name);
/* function to send a packet out the 802.2 socket */
/* returns number of bytes sent on success, negative on failure */
BACNET_STACK_EXPORT
int bacnet_ethernet_send_pdu(
BACNET_ADDRESS * dest, /* destination address */
BACNET_NPDU_DATA * npdu_data, /* network information */
uint8_t * pdu, /* any data to be sent - may be null */
unsigned pdu_len); /* number of bytes of data */
/* receives an 802.2 framed packet */
/* returns the number of octets in the PDU, or zero on failure */
BACNET_STACK_EXPORT
uint16_t bacnet_ethernet_receive(
BACNET_ADDRESS * src, /* source address */
uint8_t * pdu, /* PDU data */
uint16_t max_pdu, /* amount of space available in the PDU */
unsigned timeout); /* milliseconds to wait for a packet */
BACNET_STACK_EXPORT
void bacnet_ethernet_set_my_address(
BACNET_ADDRESS * my_address);
BACNET_STACK_EXPORT
void bacnet_ethernet_get_my_address(
BACNET_ADDRESS * my_address);
BACNET_STACK_EXPORT
void bacnet_ethernet_get_broadcast_address(
BACNET_ADDRESS * dest); /* destination address */
/* some functions from Linux driver */
BACNET_STACK_EXPORT
void bacnet_ethernet_debug_address(
const char *info,
BACNET_ADDRESS * dest);
BACNET_STACK_EXPORT
int bacnet_ethernet_send(
uint8_t * mtu,
int mtu_len);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+41
View File
@@ -0,0 +1,41 @@
/**************************************************************************
*
* Copyright (c) 2020 Legrand North America, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
#ifndef NET_H
#define NET_H
#include <net/net_ip.h>
#include <net/socket.h>
static inline char *inet_ntoa(struct in_addr in) {
return "(inet_ntoa() to be implemented)";
}
/* Local helper functions for this port */
extern int bip_get_local_netmask(
struct in_addr *netmask);
#endif