Tester: update

parent 8bcdeed6
......@@ -18,7 +18,7 @@ mediastreamer2_tester_SOURCES= \
mediastreamer2_framework_tester.c \
mediastreamer2_player_tester.c \
mediastreamer2_neon_tester.c \
common/tester_utils.c common/tester_utils.h
common/bc_tester_utils.c common/bc_tester_utils.h
AM_CPPFLAGS=\
-DBC_CONFIG_FILE=\"mediastreamer-config.h\" \
......
......@@ -20,8 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* this must be provided at compile time*/
#include BC_CONFIG_FILE
#include "tester_utils.h"
#include "bc_tester_utils.h"
#include <stdarg.h>
#include <stdlib.h>
#include "CUnit/Automated.h"
......@@ -47,7 +48,6 @@ static int nb_test_suites = 0;
static unsigned char curses = 0;
#endif
int use_log_file = 0;
char* xml_file = NULL;
int xml_enabled = 0;
char * suite_name;
......@@ -109,7 +109,7 @@ static int tester_nb_tests(const char *suite_name) {
static void tester_list_suites() {
int j;
for(j=0;j<nb_test_suites;j++) {
tester_printf(verbosity_info, "%s", tester_test_suite_name(j));
fprintf(stdout, "%s\n", tester_test_suite_name(j));
}
}
......@@ -117,7 +117,7 @@ static void tester_list_suite_tests(const char *suite_name) {
int j;
for( j = 0; j < tester_nb_tests(suite_name); j++) {
const char *test_name = tester_test_name(suite_name, j);
tester_printf(verbosity_info, "%s", test_name);
fprintf(stdout, "%s\n", test_name);
}
}
......@@ -175,7 +175,7 @@ static void test_complete_message_handler(const CU_pTest pTest,
static int tester_run_tests(const char *suite_name, const char *test_name) {
int i;
int ret;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
......@@ -235,33 +235,22 @@ static int tester_run_tests(const char *suite_name, const char *test_name) {
else
#endif
{
/* Run all tests using the CUnit Basic interface */
/* Run all tests using the CUnit Basic interface */
CU_run_all_tests();
}
}
}
ret=CU_get_number_of_tests_failed()!=0;
/* Redisplay list of failed tests on end */
if (CU_get_number_of_failure_records()){
CU_basic_show_failures(CU_get_failure_list());
tester_printf(verbosity_info,"");
}
return CU_get_number_of_tests_failed()!=0;
CU_cleanup_registry();
return ret;
}
void bc_tester_helper(const char *name, const char* additionnal_helper) {
fprintf(stderr,"%s --help\n"
fprintf(stdout,"%s --help\n"
"\t\t\t--list-suites\n"
"\t\t\t--list-tests <suite>\n"
"\t\t\t--suite <suite name>\n"
"\t\t\t--test <test name>\n"
"\t\t\t--log-file <output log file path>\n"
#if HAVE_CU_CURSES
"\t\t\t--curses\n"
#endif
......@@ -293,41 +282,30 @@ int bc_tester_parse_args(int argc, char **argv, int argid)
suite_name=argv[i];
} else if (strcmp(argv[i],"--list-suites")==0){
tester_list_suites();
return -1;
return 0;
} else if (strcmp(argv[i],"--list-tests")==0){
CHECK_ARG("--list-tests", ++i, argc);
suite_name = argv[i];
tester_list_suite_tests(suite_name);
return -1;
return 0;
} else if (strcmp(argv[i], "--xml-file") == 0){
CHECK_ARG("--xml-file", ++i, argc);
xml_file = argv[i];
xml_enabled = 1;
} else if (strcmp(argv[i], "--xml") == 0){
xml_enabled = 1;
} else if (strcmp(argv[i],"--log-file")==0){
CHECK_ARG("--log-file", ++i, argc);
FILE *log_file=fopen(argv[i],"w");
if (!log_file) {
fprintf(stderr, "Cannot open file [%s] for writing logs because [%s]",argv[i],strerror(errno));
return -2;
} else {
use_log_file=1;
tester_printf(verbosity_info,"Redirecting traces to file [%s]",argv[i]);
// linphone_core_set_log_file(log_file);
}
}else {
fprintf(stderr, "Unknown option \"%s\"\n", argv[i]);
return -2;
return -1;
}
if( xml_enabled && (suite_name || test_name) ){
fprintf(stderr, "Cannot use both XML and specific test suite\n");
return -2;
return -1;
}
/* returns number of arguments read */
return i - argid;
/* returns number of arguments read + 1 */
return i - argid + 1;
}
int bc_tester_start() {
......@@ -355,6 +333,13 @@ void bc_tester_add_suite(test_suite_t *suite) {
}
void bc_tester_uninit() {
/* Redisplay list of failed tests on end */
if (CU_get_number_of_failure_records()){
CU_basic_show_failures(CU_get_failure_list());
tester_printf(verbosity_info,""); /*add missing final newline*/
}
CU_cleanup_registry();
if( xml_enabled ){
/*create real xml file only if tester did not crash*/
char * xml_tmp_file = malloc(sizeof(char) * (strlen(xml_file) + strlen(".tmp") + 1));
......
......@@ -459,7 +459,7 @@ static void tmmbr_feedback_for_audio_stream(void) {
RtpProfile *profile = rtp_profile_new("default profile");
RtpSession *marielle_session;
RtpSession *margaux_session;
char* hello_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_file_root(), HELLO_8K_1S_FILE);
char* hello_file = ms_strdup_printf("%s/%s", bc_tester_read_dir_prefix, HELLO_8K_1S_FILE);
int dummy=0;
reset_stats(&marielle_stats);
......
......@@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester.h"
#include "mediastreamer2_tester_private.h"
#include "common/tester_utils.h"
#include <mediastreamer2/mediastream.h>
#if HAVE_CONFIG_H
#include <mediastreamer-config.h>
......@@ -75,9 +73,7 @@ void mediastreamer2_tester_uninit(void) {
}
static const char* mediastreamer2_helper =
#ifndef _WIN32
"\t\t\t--verbose\n"
#endif
"\t\t\t--silent\n"
"\t\t\t--log-file <output log file path>\n";
......@@ -115,12 +111,13 @@ int main (int argc, char *argv[]) {
}
} else {
int ret = bc_tester_parse_args(argc, argv, i);
if (ret>0) {
i += ret;
} else {
if (ret>1) {
i += ret - 1;
continue;
} else if (ret<0) {
bc_tester_helper(argv[0], mediastreamer2_helper);
return ret;
}
return ret;
}
}
......
......@@ -20,8 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _MEDIASTREAMER2_TESTER_H
#define _MEDIASTREAMER2_TESTER_H
#include "common/tester_utils.h"
#include "common/bc_tester_utils.h"
#ifdef __cplusplus
extern "C" {
......
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