mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Add support for computing iOS code coverage
Also disable failing PosixSignalDeliveryTest* tests for iOS Bug: chromium:844647 Change-Id: I64bb233bef2f06f6778f2d475b6d3ad685fb9143 Reviewed-on: https://webrtc-review.googlesource.com/c/105641 Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org> Reviewed-by: Artem Titarenko <artit@webrtc.org> Commit-Queue: Artem Titarenko <artit@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25524}
This commit is contained in:
parent
277b6ea850
commit
34fc346a0c
9 changed files with 131 additions and 6 deletions
|
@ -648,12 +648,13 @@ if (is_ios || (is_mac && target_cpu != "x86")) {
|
|||
rtc_ios_xctest_test("apprtcmobile_tests") {
|
||||
info_plist = "objc/AppRTCMobile/ios/Info.plist"
|
||||
sources = [
|
||||
"objc/AppRTCMobile/ios/main.m",
|
||||
"objc/AppRTCMobile/tests/main.mm",
|
||||
]
|
||||
deps = [
|
||||
":AppRTCMobile_lib",
|
||||
":apprtcmobile_test_sources",
|
||||
"../sdk:framework_objc",
|
||||
"//test:test_support",
|
||||
]
|
||||
ldflags = [ "-all_load" ]
|
||||
}
|
||||
|
|
21
examples/objc/AppRTCMobile/tests/main.mm
Normal file
21
examples/objc/AppRTCMobile/tests/main.mm
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2018 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include "test/ios/coverage_util_ios.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
rtc::test::ConfigureCoverageReportPath();
|
||||
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, nil);
|
||||
}
|
||||
}
|
|
@ -547,7 +547,13 @@ Thread* PosixSignalDeliveryTest::signaled_thread_ = nullptr;
|
|||
|
||||
// Test receiving a synchronous signal while not in Wait() and then entering
|
||||
// Wait() afterwards.
|
||||
TEST_F(PosixSignalDeliveryTest, RaiseThenWait) {
|
||||
// TODO(webrtc:7864): Fails on real iOS devices
|
||||
#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM_FAMILY)
|
||||
#define MAYBE_RaiseThenWait DISABLED_RaiseThenWait
|
||||
#else
|
||||
#define MAYBE_RaiseThenWait RaiseThenWait
|
||||
#endif
|
||||
TEST_F(PosixSignalDeliveryTest, MAYBE_RaiseThenWait) {
|
||||
ASSERT_TRUE(ss_->SetPosixSignalHandler(SIGTERM, &RecordSignal));
|
||||
raise(SIGTERM);
|
||||
EXPECT_TRUE(ss_->Wait(0, true));
|
||||
|
@ -557,7 +563,13 @@ TEST_F(PosixSignalDeliveryTest, RaiseThenWait) {
|
|||
|
||||
// Test that we can handle getting tons of repeated signals and that we see all
|
||||
// the different ones.
|
||||
TEST_F(PosixSignalDeliveryTest, InsanelyManySignals) {
|
||||
// TODO(webrtc:7864): Fails on real iOS devices
|
||||
#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM_FAMILY)
|
||||
#define MAYBE_InsanelyManySignals DISABLED_InsanelyManySignals
|
||||
#else
|
||||
#define MAYBE_InsanelyManySignals InsanelyManySignals
|
||||
#endif
|
||||
TEST_F(PosixSignalDeliveryTest, MAYBE_InsanelyManySignals) {
|
||||
ss_->SetPosixSignalHandler(SIGTERM, &RecordSignal);
|
||||
ss_->SetPosixSignalHandler(SIGINT, &RecordSignal);
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
|
@ -597,7 +609,13 @@ class RaiseSigTermRunnable : public Runnable {
|
|||
|
||||
// Test that it works no matter what thread the kernel chooses to give the
|
||||
// signal to (since it's not guaranteed to be the one that Wait() runs on).
|
||||
TEST_F(PosixSignalDeliveryTest, SignalOnDifferentThread) {
|
||||
// TODO(webrtc:7864): Fails on real iOS devices
|
||||
#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM_FAMILY)
|
||||
#define MAYBE_SignalOnDifferentThread DISABLED_SignalOnDifferentThread
|
||||
#else
|
||||
#define MAYBE_SignalOnDifferentThread SignalOnDifferentThread
|
||||
#endif
|
||||
TEST_F(PosixSignalDeliveryTest, DISABLED_SignalOnDifferentThread) {
|
||||
ss_->SetPosixSignalHandler(SIGTERM, &RecordSignal);
|
||||
// Mask out SIGTERM so that it can't be delivered to this thread.
|
||||
sigset_t mask;
|
||||
|
|
|
@ -1106,7 +1106,7 @@ if (is_ios || is_mac) {
|
|||
rtc_ios_xctest_test("sdk_unittests") {
|
||||
info_plist = "//test/ios/Info.plist"
|
||||
sources = [
|
||||
"objc/unittests/main.m",
|
||||
"objc/unittests/main.mm",
|
||||
]
|
||||
|
||||
_bundle_id_suffix = ios_generic_test_bundle_id_suffix
|
||||
|
@ -1115,6 +1115,7 @@ if (is_ios || is_mac) {
|
|||
":peerconnectionfactory_base_objc",
|
||||
":sdk_unittests_bundle_data",
|
||||
":sdk_unittests_sources",
|
||||
"//test:test_support",
|
||||
]
|
||||
ldflags = [ "-all_load" ]
|
||||
}
|
||||
|
@ -1124,7 +1125,7 @@ if (is_ios || is_mac) {
|
|||
info_plist = "//test/ios/Info.plist"
|
||||
sources = [
|
||||
"objc/unittests/RTCDoNotPutCPlusPlusInFrameworkHeaders_xctest.m",
|
||||
"objc/unittests/main.m",
|
||||
"objc/unittests/main.mm",
|
||||
]
|
||||
|
||||
_bundle_id_suffix = ios_generic_test_bundle_id_suffix
|
||||
|
@ -1132,6 +1133,7 @@ if (is_ios || is_mac) {
|
|||
deps = [
|
||||
":framework_objc+link",
|
||||
":ios_framework_bundle",
|
||||
"//test:test_support",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#include "test/ios/coverage_util_ios.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
rtc::test::ConfigureCoverageReportPath();
|
||||
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, nil);
|
||||
}
|
|
@ -137,6 +137,8 @@ if (is_ios) {
|
|||
testonly = true
|
||||
visibility = [ ":test_support" ]
|
||||
sources = [
|
||||
"ios/coverage_util_ios.h",
|
||||
"ios/coverage_util_ios.mm",
|
||||
"ios/test_support.h",
|
||||
"ios/test_support.mm",
|
||||
]
|
||||
|
@ -144,6 +146,15 @@ if (is_ios) {
|
|||
":perf_test",
|
||||
"../sdk:helpers_objc",
|
||||
]
|
||||
configs += [ ":test_support_objc_config" ]
|
||||
}
|
||||
|
||||
config("test_support_objc_config") {
|
||||
defines = []
|
||||
|
||||
if (use_clang_coverage) {
|
||||
defines += [ "WEBRTC_IOS_ENABLE_COVERAGE" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
24
test/ios/coverage_util_ios.h
Normal file
24
test/ios/coverage_util_ios.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright 2018 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef TEST_IOS_COVERAGE_UTIL_IOS_H_
|
||||
#define TEST_IOS_COVERAGE_UTIL_IOS_H_
|
||||
|
||||
namespace rtc {
|
||||
namespace test {
|
||||
|
||||
// In debug builds, if IOS_ENABLE_COVERAGE is defined, sets the filename of the
|
||||
// coverage file. Otherwise, it does nothing.
|
||||
void ConfigureCoverageReportPath();
|
||||
|
||||
} // namespace test
|
||||
} // namespace rtc
|
||||
|
||||
#endif // TEST_IOS_COVERAGE_UTIL_IOS_H_
|
42
test/ios/coverage_util_ios.mm
Normal file
42
test/ios/coverage_util_ios.mm
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2018 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifdef WEBRTC_IOS_ENABLE_COVERAGE
|
||||
extern "C" void __llvm_profile_set_filename(const char* name);
|
||||
#endif
|
||||
|
||||
namespace rtc {
|
||||
namespace test {
|
||||
|
||||
void ConfigureCoverageReportPath() {
|
||||
#ifdef WEBRTC_IOS_ENABLE_COVERAGE
|
||||
static dispatch_once_t once_token;
|
||||
dispatch_once(&once_token, ^{
|
||||
// Writes the profraw file to the Documents directory, where the app has
|
||||
// write rights.
|
||||
NSArray* paths =
|
||||
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString* documents_directory = [paths firstObject];
|
||||
NSString* file_name = [documents_directory stringByAppendingPathComponent:@"coverage.profraw"];
|
||||
|
||||
// For documentation, see:
|
||||
// http://clang.llvm.org/docs/SourceBasedCodeCoverage.html
|
||||
__llvm_profile_set_filename([file_name cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
|
||||
// Print the path for easier retrieval.
|
||||
NSLog(@"Coverage data at %@.", file_name);
|
||||
});
|
||||
#endif // ifdef WEBRTC_IOS_ENABLE_COVERAGE
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace rtc
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include "test/ios/coverage_util_ios.h"
|
||||
#include "test/ios/test_support.h"
|
||||
#include "test/testsupport/perf_test.h"
|
||||
|
||||
|
@ -70,6 +71,8 @@ static bool g_save_chartjson_result;
|
|||
}
|
||||
|
||||
- (void)runTests {
|
||||
rtc::test::ConfigureCoverageReportPath();
|
||||
|
||||
int exitStatus = g_test_suite();
|
||||
|
||||
if (g_save_chartjson_result) {
|
||||
|
|
Loading…
Reference in a new issue