Tester: always use the same logging system

This commit is contained in:
Gautier Pelloux-Prayer 2015-07-01 12:18:30 +02:00
parent 699cbfb6b0
commit 3a3c9636a5
8 changed files with 26 additions and 47 deletions

View file

@ -20,6 +20,7 @@
#import "Utils.h"
#include "linphone/linphonecore.h"
#import <CommonCrypto/CommonDigest.h>
@implementation LinphoneLogger
@ -262,8 +263,6 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) {
@implementation NSString(md5)
#import <CommonCrypto/CommonDigest.h>
- (NSString *)md5 {
const char *ptr = [self UTF8String];
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];

View file

@ -102,7 +102,7 @@ static bool invalidAccount = true;
[tester waitForTimeInterval:0.5];
}
NSLog(@"Switching to a valid account");
LOGI(@"Switching to a valid account");
[tester tapViewWithAccessibilityLabel:@"Start"];
[tester tapViewWithAccessibilityLabel:@"Sign in linphone.org account"];

View file

@ -10,6 +10,7 @@
#include "linphone/linphonecore.h"
#include "linphone/liblinphone_tester.h"
#import "NSObject+DTRuntime.h"
#import "Utils.h"
@interface LinphoneTester_Tests : XCTestCase
@property (retain, nonatomic) NSString* bundlePath;
@ -17,19 +18,6 @@
@end
@implementation LinphoneTester_Tests
static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list args) {
NSString* log = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:fmt] arguments:args];
NSLog(@"%@",log);
}
void LSLog(NSString* fmt, ...){
va_list args;
va_start(args, fmt);
linphone_log_function(ORTP_MESSAGE, [fmt UTF8String], args);
va_end(args);
}
+ (NSArray*)skippedSuites {
NSArray* skipped_suites = @[@"Flexisip"];
@ -48,7 +36,7 @@ void LSLog(NSString* fmt, ...){
static char * bundle = NULL;
static char * documents = NULL;
bc_tester_init((void (*)(int, const char *fm, va_list))linphone_log_function, ORTP_MESSAGE, ORTP_ERROR);
bc_tester_init((void (*)(int, const char *fm, va_list))linphone_iphone_log_handler, ORTP_MESSAGE, ORTP_ERROR);
liblinphone_tester_add_suites();
NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
@ -57,14 +45,13 @@ void LSLog(NSString* fmt, ...){
bundle = ms_strdup([bundlePath UTF8String]);
documents = ms_strdup([documentPath UTF8String]);
LSLog(@"Bundle path: %@", bundlePath);
LSLog(@"Document path: %@", documentPath);
LOGI(@"Bundle path: %@", bundlePath);
LOGI(@"Document path: %@", documentPath);
bc_tester_read_dir_prefix = ms_strdup(bundle);
bc_tester_writable_dir_prefix = ms_strdup(documents);
liblinphone_tester_keep_accounts(TRUE);
int count = bc_tester_nb_suites();
for (int i=0; i<count; i++) {
@ -101,7 +88,7 @@ void LSLog(NSString* fmt, ...){
- (void)testForSuite:(NSString*)suite andTest:(NSString*)test
{
LSLog(@"Launching test %@ from suite %@", test, suite);
LOGI(@"Launching test %@ from suite %@", test, suite);
XCTAssertFalse(bc_tester_run_tests([suite UTF8String], [test UTF8String]), @"Suite '%@' / Test '%@' failed", suite, test);
}

View file

@ -10,6 +10,7 @@
#import "MasterViewController.h"
#import "LogsViewController.h"
#include "linphone/liblinphone_tester.h"
#import "Utils.h"
static NSString* const kAllTestsName = @"Run All tests";
@ -165,7 +166,7 @@ static NSString* const kAllTestsName = @"Run All tests";
- (void)launchTests:(NSIndexPath *)index {
if (in_progress) {
LSLog(@"Test already in progress");
LOGE(@"Test already in progress");
return;
}
in_progress = TRUE;
@ -178,7 +179,7 @@ static NSString* const kAllTestsName = @"Run All tests";
dispatch_async(queue, ^{
TestItem *test = _tests[index.row];
LSLog(@"Should launch test %@", test);
LOGI(@"Should launch test %@", test);
NSString *testSuite = test.suite;
if ([test.suite isEqualToString:@"All"]) {
testSuite = nil;
@ -189,10 +190,10 @@ static NSString* const kAllTestsName = @"Run All tests";
}
BOOL fail = bc_tester_run_tests([testSuite UTF8String], [testName UTF8String]);
if (fail) {
LSLog(@"Test Failed!");
LOGW(@"Test Failed!");
test.state = TestStateFailed;
} else {
LSLog(@"Test Passed!");
LOGI(@"Test Passed!");
test.state = TestStatePassed;
}

View file

@ -8,8 +8,6 @@
#import <UIKit/UIKit.h>
void LSLog(NSString* fmt, ...);
NSMutableArray* lastLogs;
NSString* const kLogsUpdateNotification;

View file

@ -12,6 +12,7 @@
#include "linphone/liblinphone_tester.h"
#include "mediastreamer2/msutils.h"
#import "Utils.h"
@interface MasterViewController () {
NSMutableArray *_objects;
@ -37,23 +38,12 @@ static int const kLastLogsCapacity = 5000;
static int const kLogsBufferCapacity = 10;
NSString* const kLogsUpdateNotification = @"kLogsUpdateNotification";
void LSLog(NSString* fmt, ...){
va_list args;
va_start(args, fmt);
linphone_log_function(ORTP_MESSAGE, [fmt UTF8String], args);
va_end(args);
}
static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list args) {
NSString* log = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:fmt] arguments:args];
NSLog(@"%@",log);
}
- (void)setupLogging {
lastLogs = [[NSMutableArray alloc] initWithCapacity:kLastLogsCapacity];
logsBuffer = [NSMutableArray arrayWithCapacity:kLogsBufferCapacity];
linphone_core_set_log_handler(linphone_log_function);
// linphone_core_set_log_level(ORTP_MESSAGE);
linphone_core_set_log_handler((OrtpLogFunc)linphone_iphone_log_handler);
}
@ -69,16 +59,16 @@ static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list arg
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentPath = [paths objectAtIndex:0];
bc_tester_init((void (*)(int, const char *fm, va_list))linphone_log_function, ORTP_MESSAGE, ORTP_ERROR);
bc_tester_init((void (*)(int, const char *fm, va_list))linphone_iphone_log_handler, ORTP_MESSAGE, ORTP_ERROR);
liblinphone_tester_add_suites();
bc_tester_read_dir_prefix = ms_strdup([bundlePath UTF8String]);
bc_tester_writable_dir_prefix = ms_strdup([documentPath UTF8String]);
LSLog(@"Bundle path: %@", bundlePath);
LSLog(@"Document path: %@", documentPath);
LOGI(@"Bundle path: %@", bundlePath);
LOGI(@"Document path: %@", documentPath);
int count = bc_tester_nb_suites();
int count = bc_tester_nb_suites();
_objects = [[NSMutableArray alloc] initWithCapacity:count + 1];
[_objects addObject:@"All"];
for (int i = 0; i < count; i++) {
@ -88,8 +78,8 @@ static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list arg
}
- (void)displayLogs {
LSLog(@"Should display logs");
[self.navigationController performSegueWithIdentifier:@"viewLogs" sender:self];
LOGI(@"Should display logs");
[self.navigationController performSegueWithIdentifier:@"viewLogs" sender:self];
}
- (void)didReceiveMemoryWarning

View file

@ -111,6 +111,8 @@
630CF5571AF7CE1500539F7A /* UITextField+DoneButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 630CF5561AF7CE1500539F7A /* UITextField+DoneButton.m */; };
631C4FB119D2A8F2004BFE77 /* UIDigitButtonLongPlus.m in Sources */ = {isa = PBXBuildFile; fileRef = 631C4FB019D2A8F2004BFE77 /* UIDigitButtonLongPlus.m */; };
631C4FB719D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m in Sources */ = {isa = PBXBuildFile; fileRef = 631C4FB619D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m */; };
632DA24D1B43EE9400EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; };
632DA24E1B43EEEF00EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; };
636316D11A1DEBCB0009B839 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D31A1DEBCB0009B839 /* AboutViewController.xib */; };
636316D41A1DEC650009B839 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D61A1DEC650009B839 /* SettingsViewController.xib */; };
636316D91A1DECC90009B839 /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D71A1DECC90009B839 /* PhoneMainView.xib */; };
@ -4049,6 +4051,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
632DA24E1B43EEEF00EB356A /* Utils.m in Sources */,
F08F119D19C0A65B007D70C2 /* NSObject+DTRuntime.m in Sources */,
F08F118F19C09C6B007D70C2 /* LinphoneTester_Tests.m in Sources */,
F08F11A019C0A6CB007D70C2 /* DTObjectBlockExecutor.m in Sources */,
@ -4059,6 +4062,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
632DA24D1B43EE9400EB356A /* Utils.m in Sources */,
F0BB8BE41936208100974404 /* AppDelegate.m in Sources */,
F84015C7193B4E34006ABAB5 /* LogsViewController.m in Sources */,
F0BB8BED1936208200974404 /* MasterViewController.m in Sources */,

@ -1 +1 @@
Subproject commit 58bf466a676881ff5c4f086bb2ef77a472cc0a00
Subproject commit 369d675171bc38601fe4d38834fc66df8e52ec9f