From 0c59f6e50017db2ccd2d3103b35e6dfc1179242f Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Thu, 6 Nov 2014 20:23:40 -0500 Subject: [PATCH] add CODE_COVERAGE macro for ./configure --enable-profile-coverage --- configure.ac | 1 + server/tcp_server.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 087de0fa..3a024b8b 100644 --- a/configure.ac +++ b/configure.ac @@ -133,6 +133,7 @@ if test "x$want_profile_coverage" = "xyes"; then FKO_CHECK_COMPILER_ARG([-fprofile-arcs -ftest-coverage -fno-inline]) FKO_CHECK_COMPILER_ARG([-g]) FKO_CHECK_COMPILER_ARG_LDFLAGS_ONLY([-lgcov]) + AC_DEFINE([CODE_COVERAGE], [1], [Define for code coverage support]) fi dnl Decide whether or not to build binaries with fault injection support diff --git a/server/tcp_server.c b/server/tcp_server.c index 6cf3f4d1..0d521de1 100644 --- a/server/tcp_server.c +++ b/server/tcp_server.c @@ -54,7 +54,7 @@ int run_tcp_server(fko_srv_options_t *opts) { -#if !FUZZING_INTERFACES +#if !CODE_COVERAGE pid_t pid, ppid; #endif int s_sock, c_sock, sfd_flags, clen, selval; @@ -75,7 +75,7 @@ run_tcp_server(fko_srv_options_t *opts) } log_msg(LOG_INFO, "Kicking off TCP server to listen on port %i.", port); -#if !FUZZING_INTERFACES +#if !CODE_COVERAGE /* Fork off a child process to run the command and provide its outputs. */ pid = fork(); @@ -131,7 +131,7 @@ run_tcp_server(fko_srv_options_t *opts) return -1; } -#if !FUZZING_INTERFACES +#if !CODE_COVERAGE sfd_flags |= O_NONBLOCK; if(fcntl(s_sock, F_SETFL, sfd_flags) < 0) @@ -199,7 +199,7 @@ run_tcp_server(fko_srv_options_t *opts) break; } -#if !FUZZING_INTERFACES +#if !CODE_COVERAGE if(selval == 0) { /* Timeout - So we check to make sure our parent is still there by simply @@ -244,7 +244,7 @@ run_tcp_server(fko_srv_options_t *opts) shutdown(c_sock, SHUT_RDWR); close(c_sock); -#if FUZZING_INTERFACES +#if CODE_COVERAGE break; #endif } /* infinite while loop */