Skip to content

Commit

Permalink
bullseye coverage macros incl. B() whitch works
Browse files Browse the repository at this point in the history
  • Loading branch information
sorgom committed Oct 17, 2024
1 parent fbd88d8 commit 77853f1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
28 changes: 28 additions & 0 deletions application/components/BAS/coverage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// coverage instrumentation exception handling
// > works with compilers
// that support _Pragma(string-literal) directive
// - documented for:
// - gcc : https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html
// - msvc: https://learn.microsoft.com/en-us/cpp/preprocessor/pragma-directives-and-the-pragma-keyword

// created by Manfred Sorgo
#pragma once
#ifndef COVERAGE_H
#define COVERAGE_H

// bullseye coverage
#if _BullseyeCoverage
// pause coverage instrumentation
#define COVERAGE_PAUSE _Pragma("BullseyeCoverage off")
// resume coverage instrumentation
#define COVERAGE_RESUME _Pragma("BullseyeCoverage on")
// force coverage of simple boolean expressions
// by converting them to ternary expressions
#define B(SIMPLE_EXPR) (SIMPLE_EXPR ? true : false)
#else
#define COVERAGE_PAUSE
#define COVERAGE_RESUME
#define B(SIMPLE_EXPR) SIMPLE_EXPR
#endif

#endif // _H
4 changes: 4 additions & 0 deletions application/components/COM/src/TCP.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <COM/TCP.h>
#include <BAS/coverage.h>

#ifdef _WIN32
#include <winsock2.h>
Expand Down Expand Up @@ -56,8 +57,11 @@ bool TCP::listen(const INT32 socket) const
INT32 TCP::select(const INT32 socket) const
{
fd_set readfds;
// interns of fd_set macros must not be coverage instrumented
COVERAGE_PAUSE
FD_ZERO(&readfds);
FD_SET(socket, &readfds);
COVERAGE_RESUME
timeval timeout;
timeout.tv_sec = mSec;
timeout.tv_usec = mMicro;
Expand Down
2 changes: 1 addition & 1 deletion application/components/COM/src/TCP_Com.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <COM/TCP_Com.h>
#include <SYS/IL.h>
#include <BAS/coverage.h>

using std::endl;

Expand Down Expand Up @@ -78,7 +79,6 @@ I_TCP_Con& TCP_Listener_Ctrl::getCon() const
}
INSTANCE_DEF(TCP_Listener_Ctrl)


// ============================================================
// TCP connections
// ============================================================
Expand Down

0 comments on commit 77853f1

Please sign in to comment.