mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
ovs_assert, tests: Support NDEBUG.
./configure accepts --enable-ndebug option. Make ovs_assert() honor it, and make sure all test programs disable it. The order of include files in test programs is also made uniform: 1. #include <config.h> 2. #undef NDEBUG 3. Include file of the test subject (to make sure it itself has sufficient include directives). 4. System includes in alphapetical order. 5. OVS includes in aplhapetical order. Suggested-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
parent
5445f508df
commit
3f636c7e22
11
lib/util.h
11
lib/util.h
@ -65,15 +65,16 @@
|
||||
#define BUILD_ASSERT_DECL_GCCONLY(EXPR) ((void) 0)
|
||||
#endif
|
||||
|
||||
/* Like the standard assert macro, except:
|
||||
*
|
||||
* - Writes the failure message to the log.
|
||||
*
|
||||
* - Not affected by NDEBUG. */
|
||||
/* Like the standard assert macro, except writes the failure message to the
|
||||
* log. */
|
||||
#ifndef NDEBUG
|
||||
#define ovs_assert(CONDITION) \
|
||||
if (!OVS_LIKELY(CONDITION)) { \
|
||||
ovs_assert_failure(SOURCE_LOCATOR, __func__, #CONDITION); \
|
||||
}
|
||||
#else
|
||||
#define ovs_assert(CONDITION) ((void) (CONDITION))
|
||||
#endif
|
||||
NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
|
||||
|
||||
/* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes
|
||||
|
@ -17,12 +17,13 @@
|
||||
/* The mother of all test programs that links with libopevswitch.la */
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include "command-line.h"
|
||||
#include "ovstest.h"
|
||||
#include "dynamic-string.h"
|
||||
#include "ovstest.h"
|
||||
#include "util.h"
|
||||
|
||||
static struct command *commands = NULL;
|
||||
|
@ -15,10 +15,11 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <ctype.h>
|
||||
#undef NDEBUG
|
||||
#include "aes128.h"
|
||||
#include "util.h"
|
||||
#include <ctype.h>
|
||||
#include "ovstest.h"
|
||||
#include "util.h"
|
||||
|
||||
static void
|
||||
hex_to_uint8(const char *input, uint8_t *output, size_t n)
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "ovs-atomic.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
|
@ -15,13 +15,12 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "bitmap.h"
|
||||
#include <assert.h>
|
||||
#include "command-line.h"
|
||||
#include "ovstest.h"
|
||||
#include "timeval.h"
|
||||
#include "command-line.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
enum { MAX_BITS = 20 * BITMAP_ULONG_BITS };
|
||||
|
||||
|
@ -14,18 +14,15 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "bundle.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "flow.h"
|
||||
#include "ofp-actions.h"
|
||||
#include "ofpbuf.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
#include "util.h"
|
||||
|
||||
#define N_FLOWS 50000
|
||||
#define MAX_SLAVES 8 /* Maximum supported by this test framework. */
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "byte-order.h"
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -27,20 +27,20 @@
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "classifier.h"
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include "byte-order.h"
|
||||
#include "classifier.h"
|
||||
#include "classifier-private.h"
|
||||
#include "command-line.h"
|
||||
#include "flow.h"
|
||||
#include "ofp-util.h"
|
||||
#include "ovstest.h"
|
||||
#include "packets.h"
|
||||
#include "random.h"
|
||||
#include "unaligned.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
/* Fields in a rule. */
|
||||
#define CLS_FIELDS \
|
||||
|
@ -18,10 +18,12 @@
|
||||
* cmap.h. */
|
||||
|
||||
#include <config.h>
|
||||
#include "bitmap.h"
|
||||
#undef NDEBUG
|
||||
#include "cmap.h"
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include "bitmap.h"
|
||||
#include "command-line.h"
|
||||
#include "fat-rwlock.h"
|
||||
#include "hash.h"
|
||||
@ -32,9 +34,6 @@
|
||||
#include "timeval.h"
|
||||
#include "util.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
/* Sample cmap element. */
|
||||
struct element {
|
||||
int value;
|
||||
|
@ -15,20 +15,19 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "csum.h"
|
||||
#include "crc32c.h"
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "crc32c.h"
|
||||
#include "ovstest.h"
|
||||
#include "random.h"
|
||||
#include "unaligned.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
struct test_case {
|
||||
char *data;
|
||||
|
@ -15,23 +15,22 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "flow.h"
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "classifier.h"
|
||||
#include "openflow/openflow.h"
|
||||
#include "timeval.h"
|
||||
#include "ofpbuf.h"
|
||||
#include "ofp-print.h"
|
||||
#include "ofp-util.h"
|
||||
#include "openflow/openflow.h"
|
||||
#include "ovstest.h"
|
||||
#include "pcap-file.h"
|
||||
#include "timeval.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
static void
|
||||
test_flows_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
|
||||
|
@ -15,17 +15,16 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "hash.h"
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "hash.h"
|
||||
#include "jhash.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
static void
|
||||
set_bit(uint32_t array[3], int bit)
|
||||
{
|
||||
|
@ -17,17 +17,16 @@
|
||||
/* A test for for functions and macros declared in heap.h. */
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "heap.h"
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include "command-line.h"
|
||||
#include "ovstest.h"
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
/* Sample heap element. */
|
||||
struct element {
|
||||
|
@ -18,15 +18,14 @@
|
||||
* hindex.h. */
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "hindex.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "hash.h"
|
||||
#include "ovstest.h"
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
/* Sample hindex element. */
|
||||
struct element {
|
||||
|
@ -18,15 +18,14 @@
|
||||
* hmap.h. */
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "hmap.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "hash.h"
|
||||
#include "ovstest.h"
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
/* Sample hmap element. */
|
||||
struct element {
|
||||
|
@ -15,16 +15,15 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "json.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
#include "util.h"
|
||||
|
||||
/* --pretty: If set, the JSON output is pretty-printed, instead of printed as
|
||||
* compactly as possible. */
|
||||
static int pretty = 0;
|
||||
|
@ -15,25 +15,23 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "jsonrpc.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "command-line.h"
|
||||
#include "daemon.h"
|
||||
#include "json.h"
|
||||
#include "ovstest.h"
|
||||
#include "poll-loop.h"
|
||||
#include "stream-ssl.h"
|
||||
#include "stream.h"
|
||||
#include "timeval.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
NO_RETURN static void usage(void);
|
||||
static void parse_options(int argc, char *argv[]);
|
||||
|
@ -18,13 +18,12 @@
|
||||
* list.h. */
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "list.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
/* Sample list element. */
|
||||
struct element {
|
||||
int value;
|
||||
|
@ -15,20 +15,18 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "lockfile.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ovstest.h"
|
||||
#include "process.h"
|
||||
#include "timeval.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
struct test {
|
||||
const char *name;
|
||||
|
@ -15,19 +15,17 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "multipath.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "flow.h"
|
||||
#include "ofp-actions.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
#include "util.h"
|
||||
|
||||
static void
|
||||
test_multipath_main(int argc, char *argv[])
|
||||
|
@ -15,25 +15,24 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "netflow.h"
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "command-line.h"
|
||||
#include "daemon.h"
|
||||
#include "dynamic-string.h"
|
||||
#include "netflow.h"
|
||||
#include "ofpbuf.h"
|
||||
#include "ovstest.h"
|
||||
#include "packets.h"
|
||||
#include "poll-loop.h"
|
||||
#include "socket-util.h"
|
||||
#include "unixctl.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
NO_RETURN static void usage(void);
|
||||
static void parse_options(int argc, char *argv[]);
|
||||
|
@ -15,18 +15,17 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "odp-util.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dynamic-string.h"
|
||||
#include "flow.h"
|
||||
#include "match.h"
|
||||
#include "odp-util.h"
|
||||
#include "ofp-parse.h"
|
||||
#include "ofpbuf.h"
|
||||
#include "ovstest.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
static int
|
||||
parse_keys(bool wc_keys)
|
||||
|
@ -15,16 +15,14 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "packets.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
static void
|
||||
test_ipv4_cidr(void)
|
||||
{
|
||||
|
@ -15,11 +15,11 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "random.h"
|
||||
#include "ovstest.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ovstest.h"
|
||||
|
||||
static void
|
||||
test_random_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
|
||||
|
@ -15,20 +15,18 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "reconnect.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "command-line.h"
|
||||
#include "compiler.h"
|
||||
#include "ovstest.h"
|
||||
#include "svec.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
static struct reconnect *reconnect;
|
||||
static int now;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "rstp-common.h"
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
@ -16,7 +16,8 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "netflow.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
@ -24,19 +25,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "command-line.h"
|
||||
#include "daemon.h"
|
||||
#include "dynamic-string.h"
|
||||
#include "netflow.h"
|
||||
#include "ofpbuf.h"
|
||||
#include "ovstest.h"
|
||||
#include "packets.h"
|
||||
#include "poll-loop.h"
|
||||
#include "socket-util.h"
|
||||
#include "unixctl.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
NO_RETURN static void usage(void);
|
||||
static void parse_options(int argc, char *argv[]);
|
||||
|
@ -15,17 +15,16 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "sha1.h"
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ovstest.h"
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
struct test_vector {
|
||||
char *data;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "stp.h"
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
@ -24,9 +24,9 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include "ofpbuf.h"
|
||||
#include "ovstest.h"
|
||||
#include "packets.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
struct bpdu {
|
||||
int port_no;
|
||||
|
@ -15,14 +15,13 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "socket-util.h"
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "socket-util.h"
|
||||
#include "ovstest.h"
|
||||
#include "util.h"
|
||||
|
||||
static void
|
||||
test_unix_socket_main(int argc, char *argv[])
|
||||
|
@ -15,22 +15,19 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include "util.h"
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "byte-order.h"
|
||||
#include "command-line.h"
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
#include "random.h"
|
||||
#include "vlog.h"
|
||||
|
||||
static void
|
||||
check_log_2_floor(uint32_t x, int n)
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "uuid.h"
|
||||
#include <stdio.h>
|
||||
#include "ovstest.h"
|
||||
|
@ -15,7 +15,9 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#undef NDEBUG
|
||||
#include "vconn.h"
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
@ -27,6 +29,7 @@
|
||||
#include "ofp-util.h"
|
||||
#include "ofpbuf.h"
|
||||
#include "openflow/openflow.h"
|
||||
#include "ovstest.h"
|
||||
#include "poll-loop.h"
|
||||
#include "socket-util.h"
|
||||
#include "stream.h"
|
||||
@ -34,10 +37,6 @@
|
||||
#include "timeval.h"
|
||||
#include "util.h"
|
||||
#include "vlog.h"
|
||||
#include "ovstest.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
struct fake_pvconn {
|
||||
const char *type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user