Commit ed754efa authored by Simon Morlat's avatar Simon Morlat

Merge remote-tracking branch 'origin/master' into pr1813

parents ce9b6530 2a4e0e98
......@@ -44,7 +44,7 @@ macro(bc_init_compilation_flags CPP_FLAGS C_FLAGS CXX_FLAGS STRICT_COMPILATION)
if(ENABLE_STRICT)
list(APPEND ${CPP_FLAGS} "-Werror" "-Wextra" "-Wno-unused-parameter" "-Wno-error=unknown-pragmas" "-Wuninitialized" "-Wno-missing-field-initializers"
"-fno-strict-aliasing" "-Wno-error=deprecated" "-Wno-error=deprecated-declarations")
list(APPEND ${C_FLAGS} "-Werror" "-Wdeclaration-after-statement" "-Wstrict-prototypes")
list(APPEND ${C_FLAGS} "-Werror" "-Wstrict-prototypes")
endif()
endif()
endmacro()
......@@ -73,7 +73,7 @@ macro(bc_git_version PROJECT_NAME PROJECT_VERSION)
endmacro()
macro(bc_project_build_version PROJECT_VERSION PROJECT_BUILD_VERSION)
macro(bc_project_build_version PROJECT_VERSION PROJECT_BUILD_VERSION)
find_program (WC wc)
if(WC)
......@@ -102,7 +102,7 @@ macro(bc_project_build_version PROJECT_VERSION PROJECT_BUILD_VERSION)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
if (NOT PROJECT_VERSION_BUILD)
if (NOT PROJECT_VERSION_BUILD)
set(PROJECT_VERSION_BUILD 0)
endif()
endmacro()
......@@ -128,4 +128,3 @@ macro(bc_generate_rpm_specfile SOURCE DEST)
unset(_variableNames)
endif()
endmacro()
......@@ -107,8 +107,14 @@ BCTBX_PUBLIC void *bctbx_log_handler_get_user_data(const bctbx_log_handler_t* lo
BCTBX_PUBLIC void bctbx_add_log_handler(bctbx_log_handler_t* handler);
BCTBX_PUBLIC void bctbx_remove_log_handler(bctbx_log_handler_t* handler);
/*
* Set a callback function to render logs for the default handler.
*/
BCTBX_PUBLIC void bctbx_set_log_handler(BctbxLogFunc func);
/*same as bctbx_set_log_handler but only for a domain. NULL for all*/
/*
* Same as bctbx_set_log_handler but only for a domain. NULL for all.
* Be careful that if domain is specified, the default log handler will no longer output logs for other domains.
*/
BCTBX_PUBLIC void bctbx_set_log_handler_for_domain(BctbxLogFunc func, const char* domain);
/*Convenient function that creates a static log handler logging into supplied FILE argument.
Despite it is not recommended to use it in libraries, it can be useful for simple test programs.*/
......@@ -118,7 +124,11 @@ BCTBX_PUBLIC bctbx_list_t* bctbx_get_log_handlers(void);
BCTBX_PUBLIC void bctbx_logv_out(const char *domain, BctbxLogLevel level, const char *fmt, va_list args);
BCTBX_PUBLIC void bctbx_logv_file(void* user_info, const char *domain, BctbxLogLevel level, const char *fmt, va_list args);
#define bctbx_log_level_enabled(domain, level) (bctbx_get_log_level_mask(domain) & (level))
/*
* Returns 1 if the log level 'level' is enabled for the calling thread, otherwise 0.
* This gives the condition to decide to output a log.
*/
BCTBX_PUBLIC int bctbx_log_level_enabled(const char *domain, BctbxLogLevel level);
BCTBX_PUBLIC void bctbx_logv(const char *domain, BctbxLogLevel level, const char *fmt, va_list args);
......@@ -136,6 +146,19 @@ BCTBX_PUBLIC void bctbx_set_log_level(const char *domain, BctbxLogLevel level);
BCTBX_PUBLIC void bctbx_set_log_level_mask(const char *domain, int levelmask);
BCTBX_PUBLIC unsigned int bctbx_get_log_level_mask(const char *domain);
/**
* Set a specific log level for the calling thread for domain.
* When domain is NULL, the log level applies to all domains.
*/
BCTBX_PUBLIC void bctbx_set_thread_log_level(const char *domain, BctbxLogLevel level);
/**
* Clears the specific log level set for the calling thread by bctbx_set_thread_log_level().
* After calling this function, the global (not per thread) log level will apply to
* logs printed by this thread.
*/
BCTBX_PUBLIC void bctbx_clear_thread_log_level(const char *domain);
/**
* Tell oRTP the id of the thread used to output the logs.
* This is meant to output all the logs from the same thread to prevent deadlock problems at the application level.
......@@ -276,18 +299,22 @@ namespace bctoolbox {
class pumpstream : public std::ostringstream {
public:
pumpstream(const char *domain, BctbxLogLevel level) : mDomain(domain ? domain : ""), mLevel(level) {}
/*contructor used to disable logging*/
pumpstream():mDomain(""),mLevel(BCTBX_LOG_DEBUG),mTraceEnabled(false){}
pumpstream(const char *domain, BctbxLogLevel level) : mDomain(domain ? domain : ""), mLevel(level),mTraceEnabled(true) {}
~pumpstream() {
const char *domain = mDomain.empty() ? NULL : mDomain.c_str();
if (bctbx_log_level_enabled(domain, mLevel))
if (mTraceEnabled && bctbx_log_level_enabled(domain, mLevel))
bctbx_log(domain, mLevel, "%s", str().c_str());
}
private:
const std::string mDomain;
const BctbxLogLevel mLevel;
const bool mTraceEnabled;
};
#if (__GNUC__ == 4 && __GNUC_MINOR__ < 5 && __cplusplus > 199711L)
template <typename _Tp> inline pumpstream &operator<<(pumpstream &&__os, const _Tp &__x) {
(static_cast<std::ostringstream &>(__os)) << __x;
......@@ -297,7 +324,12 @@ template <typename _Tp> inline pumpstream &operator<<(pumpstream &&__os, const _
#define BCTBX_SLOG(domain, thelevel) pumpstream(domain, thelevel)
#ifndef BCTBX_DEBUG_MODE
#define BCTBX_SLOGD BCTBX_SLOG(BCTBX_LOG_DOMAIN, BCTBX_LOG_DEBUG)
#else
#define BCTBX_SLOGD pumpstream()
#endif
#define BCTBX_SLOGI BCTBX_SLOG(BCTBX_LOG_DOMAIN, BCTBX_LOG_MESSAGE)
#define BCTBX_SLOGW BCTBX_SLOG(BCTBX_LOG_DOMAIN, BCTBX_LOG_WARNING)
#define BCTBX_SLOGE BCTBX_SLOG(BCTBX_LOG_DOMAIN, BCTBX_LOG_ERROR)
......
......@@ -103,8 +103,7 @@ endif()
if(ENABLE_SHARED)
add_library(bctoolbox SHARED ${BCTOOLBOX_SOURCE_FILES} ${BCTOOLBOX_HEADER_FILES})
target_link_libraries(bctoolbox PRIVATE ${CMAKE_THREAD_LIBS_INIT})
#TODO: replace by if(APPLE) when we want to make apple framework on linphone-desktop too
if(IOS)
if(APPLE)
if(IOS)
set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET})
else()
......@@ -214,7 +213,7 @@ if(ENABLE_TESTS_COMPONENT)
if(ENABLE_SHARED)
target_include_directories(bctoolbox-tester PUBLIC ${BCUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester PRIVATE bctoolbox ${BCUNIT_LIBRARIES})
if(IOS)
if(APPLE)
set_target_properties(bctoolbox-tester PROPERTIES
FRAMEWORK TRUE
MACOSX_FRAMEWORK_IDENTIFIER com.belledonne-communications.bctoolbox-tester
......
This diff is collapsed.
......@@ -105,6 +105,7 @@ static size_t max_vm_kb = 0;
static int run_skipped_tests = 0;
//0 if deactivated, or > 0, representing the maximum number of subprocesses to launch
static int parallel_suites = 0;
static uint64_t globalTimeout = 0;
//To keep record of the process name who started and args
static char **origin_argv = NULL;
......@@ -221,7 +222,7 @@ int bc_tester_suite_index(const char *suite_name) {
int i;
for (i = 0; i < nb_test_suites; i++) {
if (strcmp(suite_name, test_suite[i]->name) == 0) {
if (strcasecmp(suite_name, test_suite[i]->name) == 0) {
return i;
}
}
......@@ -234,7 +235,7 @@ int bc_tester_test_index(test_suite_t *suite, const char *test_name) {
int i;
for (i = 0; i < suite->nb_tests; i++) {
if (strcmp(test_name, suite->tests[i].name) == 0) {
if (strcasecmp(test_name, suite->tests[i].name) == 0) {
return i;
}
}
......@@ -382,6 +383,14 @@ void merge_and_print_results_files(void) {
remove(file_name);
} else {
bc_tester_printf(bc_printf_verbosity_error, "Failed to open suite results file '%s'", file_name);
//Assume suite crash and report it.
if (results == NULL) {
results = bctbx_concat("Suite '", test_suite[i]->name, "' results: CRASH\n", NULL);
} else {
tmp = bctbx_concat(results, "\nSuite '", test_suite[i]->name, "' results: CRASH\n", NULL);
bctbx_free(results);
results = tmp;
}
}
bctbx_free(suite_name_wo_spaces);
bctbx_free(file_name);
......@@ -663,8 +672,8 @@ int start_sub_process(const char *suite_name) {
argv[argc++] = origin_argv[i++];
argv[argc++] = get_logfile_name(log_file_name, suite_name);
} else if (strcmp(origin_argv[i], "--xml-file") == 0) {
argv[argc++] = origin_argv[i++];
argv[argc++] = origin_argv[i];
argv[argc++] = origin_argv[i + 1];
} else if (strcmp(origin_argv[i], "--parallel") == 0) {
argv[argc++] = origin_argv[i];
} else {
......@@ -720,7 +729,15 @@ int bc_tester_run_parallel(void) {
int bc_tester_run_parallel(void) {
int suitesPids[nb_test_suites];
uint64_t time_start = bctbx_get_cur_time_ms(), elapsed = time_start, print_timer = time_start;
uint64_t timeout = time_start + (40 * 60 * 1000); //Assume there is a problem if a child is still running after 40mn. TODO make timeout a cli parameter ?
//Assume there is a problem if a suite is still running 60mn after the start of the tester. TODO make timeout a cli parameter ?
uint64_t timeout = 0;
if (globalTimeout <= 0) {
globalTimeout = 60;
}
timeout = time_start + (globalTimeout * 60 * 1000);
int maxProcess = bc_tester_get_max_parallel_processes();
int nextSuite = 0; //Next suite id to be exec'd
int runningSuites = 0; //Number of currently running suites
......@@ -783,6 +800,11 @@ int bc_tester_run_parallel(void) {
}
bc_tester_printf(bc_printf_verbosity_info, "All suites ended.");
all_complete_message_handler(NULL);
{
int seconds = (int)(elapsed - time_start)/1000;
bc_tester_printf(bc_printf_verbosity_info, "Full parallel run completed in %2i mn %2i s.\n", seconds/60, seconds % 60);
}
return ret;
}
......@@ -1093,6 +1115,7 @@ void bc_tester_helper(const char *name, const char* additionnal_helper) {
"\t\t\t--max-alloc <size in ko> (maximum amount of memory obtained via malloc allocator)\n"
"\t\t\t--max-alloc <size in ko> (maximum amount of memory obtained via malloc allocator)\n"
"\t\t\t--parallel (Execute tests concurrently and with JUnit report)\n"
"\t\t\t--timeout <timeout in minutes> (sets the global timeout when used alongside to the parallel option, the default value is 60)\n"
"And additionally:\n"
"%s",
name,
......@@ -1151,6 +1174,9 @@ int bc_tester_parse_args(int argc, char **argv, int argid)
//Defaults to JUnit report if parallel is enabled
xml_enabled = 1;
parallel_suites = 1;
} else if (strcmp(argv[i], "--timeout") == 0) {
CHECK_ARG("--timeout", ++i, argc);
globalTimeout = atoi(argv[i]);
} else if (strcmp(argv[i], "--max-alloc") == 0) {
CHECK_ARG("--max-alloc", ++i, argc);
max_vm_kb = atol(argv[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment