include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCXXSourceCompiles)
+include(CheckStructHasMember)
include(TestBigEndian)
set(PACKAGE ${APPLICATION_NAME})
check_include_file(time.h HAVE_TIME_H)
check_include_file(unistd.h HAVE_UNISTD_H)
+if (HAVE_TIME_H)
+ check_struct_has_member("struct timespec" tv_sec "time.h" HAVE_STRUCT_TIMESPEC)
+endif (HAVE_TIME_H)
# FUNCTIONS
check_function_exists(calloc HAVE_CALLOC)
}" HAVE_MSVC_THREAD_LOCAL_STORAGE)
endif(WIN32)
-if (HAVE_TIME_H AND HAVE_CLOCK_GETTIME)
+if (HAVE_TIME_H AND HAVE_STRUCT_TIMESPEC AND HAVE_CLOCK_GETTIME)
set(CMAKE_REQUIRED_LIBRARIES ${RT_LIBRARY})
message(STATUS "CMAKE_REQUIRED_INCLUDES=${CMAKE_REQUIRED_INCLUDES} CMAKE_REQUIRED_LIBRARIES=${CMAKE_REQUIRED_LIBRARIES}")
return 0;
}" HAVE_CLOCK_GETTIME_REALTIME)
set(CMAKE_REQUIRED_INCLUDES)
-endif (HAVE_TIME_H AND HAVE_CLOCK_GETTIME)
+endif ()
# ENDIAN
if (NOT WIN32)
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1
+/**************************** STRUCTS ****************************/
+
+#cmakedefine HAVE_STRUCT_TIMESPEC 1
+
/*************************** FUNCTIONS ***************************/
/* Define to 1 if you have the `calloc' function. */
* TIME CALCULATIONS
****************************************************************************/
+#ifdef HAVE_STRUCT_TIMESPEC
static struct timespec cm_tspecdiff(struct timespec time1,
struct timespec time0)
{
return ret;
}
+#endif /* HAVE_STRUCT_TIMESPEC */
/****************************************************************************
* CMOCKA TEST RUNNER
static int cmocka_run_one_tests(struct CMUnitTestState *test_state)
{
+#ifdef HAVE_STRUCT_TIMESPEC
struct timespec start = {
.tv_sec = 0,
.tv_nsec = 0,
.tv_sec = 0,
.tv_nsec = 0,
};
+#endif
int rc = 0;
/* Run setup */
}
/* Run test */
+#ifdef HAVE_STRUCT_TIMESPEC
CMOCKA_CLOCK_GETTIME(CLOCK_REALTIME, &start);
+#endif
if (rc == 0) {
rc = cmocka_run_one_test_or_fixture(test_state->test->name,
rc = 0;
}
+ test_state->runtime = 0.0;
+
+#ifdef HAVE_STRUCT_TIMESPEC
CMOCKA_CLOCK_GETTIME(CLOCK_REALTIME, &finish);
test_state->runtime = cm_secdiff(finish, start);
+#endif
/* Run teardown */
if (rc == 0 && test_state->test->teardown_func != NULL) {