handle the new environment variable PEP_NOABORT, and define that when running the test suite: fix pEp.foundation/pEpEngine#121

gitea-121
positron 2 months ago
parent 8fc02b587c
commit a4c1226b7e

@ -23,6 +23,11 @@
well by adding a test case documenting the behaviour difference; the
unexpected ugly status code was only returned in 2.x, which required a
non-trivial fix.
* If the environment variable PEP_NOABORT is defined, to any value, never abort
on failure indepdendently from the fatality mode. This is meant for internal
use with the pEp Engine test suite, but users and developers of other pEp
components might also find this useful.
This solves https://gitea.pep.foundation/pEp.foundation/pEpEngine/issues/121 .
v3.2.0-RC20 2023-01-23
* make register_sync_callbacks really side-effect-free; this fixes

@ -4,9 +4,20 @@
* @license GNU General Public License 3.0 - see LICENSE.txt
*/
#define _EXPORT_PEP_ENGINE_DLL // FIXME: remove unless there is at least one exported *function*
#define _EXPORT_PEP_ENGINE_DLL
#include "pEp_debug.h"
#include <stdlib.h>
/* Nothing here. The functionality of this module is entirely implemented in
the header, with CPP macros. */
/* Internal functions.
* ***************************************************************** */
DYNAMIC_API void pEp_abort_unless_PEP_NOABORT(void)
{
if (getenv("PEP_NOABORT") == NULL)
abort();
/* Otherwise there is no need to print anything; calls to this function
always come after logging. */
}

@ -71,7 +71,12 @@ typedef enum {
/* These constant expressions evaluate to non-false when failed checks should
cause an abort.
These Boolean values express *fatality*. */
These Boolean values express *fatality*.
Notice that abort is never actually called when the environment variable
PEP_NOABORT is defined; see the comment for pEp_abort_unless_PEP_NOABORT.
PEP_NOABORT is intended for use by the Engine developers in the test
suite. */
#define PEP_ABORT_ON_VIOLATED_REQUIRE \
(PEP_SAFETY_MODE == PEP_SAFETY_MODE_MAINTAINER)
#define PEP_ABORT_ON_VIOLATED_WEAK_ASSERT \
@ -133,7 +138,7 @@ typedef enum {
what_as_string " precondition", \
"session != NULL"); \
if (abort_on_failure) \
abort(); \
pEp_abort_unless_PEP_NOABORT(); \
do { \
else_statement; \
} while (false); \
@ -143,7 +148,7 @@ typedef enum {
what_as_string, \
expression_as_string); \
if (abort_on_failure) \
abort(); \
pEp_abort_unless_PEP_NOABORT(); \
do { \
else_statement; \
} while (false); \
@ -473,6 +478,23 @@ typedef enum {
#define PEP_SET_STATUS_ORELSE_RETURN(expression, else_result, ...) \
_PEP_SET_STATUS_ORELSE(expression, {return (else_result);}, __VA_ARGS__)
/* Internal functions.
* ***************************************************************** */
/**
* <!-- pEp_abort_unless_PEP_NOABORT() -->
*
* @brief Call abort(3), unless the environment variable PEP_NOABORT is
* currently defined, to any value -- in which case do nothing.
* This function is useful to override the current fatality mode
* when running the test suite: when called from test cases pEp
* functions should always return failure codes, and never abort.
*
*/
DYNAMIC_API void pEp_abort_unless_PEP_NOABORT(void);
#ifdef __cplusplus
} /* extern "C" */

@ -134,7 +134,9 @@ $(TARGET): $(OBJS)
test: all
$(RM) -rf ./pEp_test_home/*
$(TEST_CMD_PFX) $(TEST_DEBUGGER) GTEST_COLOR=no python3 $(GTEST_PL) \
$(TEST_CMD_PFX) $(TEST_DEBUGGER) \
PEP_NOABORT=noabort GTEST_COLOR=no \
python3 $(GTEST_PL) \
--gtest_color=no ./$(TARGET)
clean:

Loading…
Cancel
Save