Tester: handle logger function correctly (in progress)

parent c180f46b
......@@ -66,7 +66,7 @@ int belle_sip_tester_ipv6_available(void){
return ipv6_available;
}
static void log_handler(belle_sip_log_level lev, const char *fmt, va_list args) {
static void log_handler(int lev, const char *fmt, va_list args) {
belle_sip_set_log_file(stderr);
belle_sip_log_handler(lev, fmt, args);
if (log_file){
......@@ -77,9 +77,9 @@ static void log_handler(belle_sip_log_level lev, const char *fmt, va_list args)
void belle_sip_tester_init() {
belle_sip_log_handler = belle_sip_get_log_handler();
belle_sip_set_log_handler(log_handler);
belle_sip_set_log_handler((belle_sip_log_function_t)log_handler);
tester_init();
tester_init(log_handler);
belle_sip_init_sockets();
belle_sip_object_enable_marshal_check(TRUE);
ipv6_available=_belle_sip_tester_ipv6_available();
......@@ -142,10 +142,10 @@ int main (int argc, char *argv[]) {
CHECK_ARG("--log-file", ++i, argc);
log_file=fopen(argv[i],"w");
if (!log_file) {
tester_fprintf(stderr, "Cannot open file [%s] for writing logs because [%s]",argv[i],strerror(errno));
belle_sip_error("Cannot open file [%s] for writing logs because [%s]",argv[i],strerror(errno));
return -2;
} else {
tester_fprintf(stdout,"Redirecting traces to file [%s]",argv[i]);
belle_sip_message("Redirecting traces to file [%s]",argv[i]);
}
} else if (strcmp(argv[i],"--domain")==0){
CHECK_ARG("--domain", ++i, argc);
......
/home/gpelloux/code/desktop/belle-sip/tester/../../linphone-debian/tester/tester_utils.c
\ No newline at end of file
This diff is collapsed.
/home/gpelloux/code/desktop/belle-sip/tester/../../linphone-debian/tester/tester_utils.h
\ No newline at end of file
/*
tester - liblinphone test suite
Copyright (C) 2013 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TESTER_UTILS_H
#define TESTER_UTILS_H
#include "CUnit/Basic.h"
extern const char *tester_file_prefix;
extern const char *tester_writable_dir_prefix;
typedef void (*test_function_t)(void);
typedef int (*test_suite_function_t)(const char *name);
typedef struct {
const char *name;
test_function_t func;
} test_t;
typedef struct {
const char *name;
CU_InitializeFunc init_func;
CU_CleanupFunc cleanup_func;
int nb_tests;
test_t *tests;
} test_suite_t;
#ifdef __cplusplus
extern "C" {
#endif
#define CHECK_ARG(argument, index, argc) \
if(index >= argc) { \
fprintf(stderr, "Missing argument for \"%s\"\n", argument); \
return -1; \
} \
void tester_init(void (*tester_printf)(int level, const char *fmt, va_list args));
void tester_helper(const char *name, const char* additionnal_helper);
int tester_parse_args(int argc, char** argv, int argid);
int tester_start();
int tester_test_suite_index(const char *suite_name);
void tester_list_suites();
void tester_list_suite_tests(const char *suite_name);
int tester_test_index(const char *suite_name, const char *test_name);
int tester_nb_test_suites(void);
int tester_nb_tests(const char *suite_name);
const char * tester_test_suite_name(int suite_index);
const char * tester_test_name(const char *suite_name, int test_index);
int tester_run_tests(const char *suite_name, const char *test_name);
void tester_add_suite(test_suite_t *suite);
int tester_run_suite(test_suite_t *suite);
void tester_uninit();
#ifdef __cplusplus
}
#endif
#endif
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