diff --git a/test/BUILD.gn b/test/BUILD.gn index bfbdd513..32dc298f 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -43,29 +43,6 @@ static_library("test") { "test_paths.h", ] - if (crashpad_is_ios) { - sources -= [ - "errors.cc", - "errors.h", - "file.cc", - "file.h", - "filesystem.cc", - "filesystem.h", - "multiprocess.h", - "multiprocess_exec.cc", - "multiprocess_exec.h", - "process_type.cc", - "process_type.h", - "scoped_guarded_page.h", - "scoped_module_handle.cc", - "scoped_module_handle.h", - "scoped_temp_dir.cc", - "scoped_temp_dir.h", - "test_paths.cc", - "test_paths.h", - ] - } - if (crashpad_is_posix || crashpad_is_fuchsia) { sources += [ "scoped_guarded_page_posix.cc", @@ -93,6 +70,14 @@ static_library("test") { ] } + if (crashpad_is_ios) { + sources -= [ + "multiprocess.h", + "multiprocess_exec.cc", + "multiprocess_exec.h", + ] + } + if (crashpad_is_linux || crashpad_is_android) { set_sources_assignment_filter([]) sources += [ @@ -139,13 +124,6 @@ static_library("test") { "../util", ] - if (crashpad_is_ios) { - deps -= [ - "../compat", - "../util", - ] - } - if (crashpad_is_mac) { libs = [ "bsm" ] deps += [ @@ -154,6 +132,10 @@ static_library("test") { ] } + if (crashpad_is_ios) { + deps += [ ":test_bundle_data" ] + } + if (crashpad_is_win) { libs = [ "shell32.lib" ] } @@ -166,6 +148,17 @@ static_library("test") { } } +if (crashpad_is_ios) { + bundle_data("test_bundle_data") { + testonly = true + + sources = [ "test_paths_test_data_root.txt" ] + + outputs = [ "{{bundle_resources_dir}}/crashpad_test_data/" + + "{{source_root_relative_dir}}/{{source_file_part}}" ] + } +} + source_set("test_test") { testonly = true @@ -178,15 +171,6 @@ source_set("test_test") { "test_paths_test.cc", ] - if (crashpad_is_ios) { - sources -= [ - "multiprocess_exec_test.cc", - "scoped_guarded_page_test.cc", - "scoped_temp_dir_test.cc", - "test_paths_test.cc", - ] - } - # TODO(crbug.com/812974): Remove !crashpad_is_fuchsia when Fuchsia is no # longer treated as a posix platform. if (crashpad_is_posix && !crashpad_is_fuchsia && !crashpad_is_ios) { @@ -197,6 +181,13 @@ source_set("test_test") { sources += [ "mac/mach_multiprocess_test.cc" ] } + if (crashpad_is_ios) { + sources -= [ + "multiprocess_exec_test.cc", + "scoped_guarded_page_test.cc", + ] + } + if (crashpad_is_win) { sources += [ "win/win_child_process_test.cc", @@ -216,11 +207,6 @@ source_set("test_test") { data_deps = [ ":crashpad_test_test_multiprocess_exec_test_child" ] if (crashpad_is_ios) { - deps -= [ - "../compat", - "../util", - ] - data_deps -= [ ":crashpad_test_test_multiprocess_exec_test_child" ] } } diff --git a/test/test_paths.cc b/test/test_paths.cc index dfe6c96b..475e2b01 100644 --- a/test/test_paths.cc +++ b/test/test_paths.cc @@ -46,7 +46,7 @@ base::FilePath TestDataRootInternal() { #if defined(OS_FUCHSIA) base::FilePath asset_path("/pkg/data"); if (!IsTestDataRoot(asset_path)) { - LOG(WARNING) << "Test data root seems invalid, continuing anyway"; + LOG(WARNING) << "test data root seems invalid, continuing anyway"; } return asset_path; #else // defined(OS_FUCHSIA) @@ -65,19 +65,23 @@ base::FilePath TestDataRootInternal() { return base::FilePath(environment_value); } - // In a standalone build, the test executable is usually at - // out/{Debug,Release} relative to the Crashpad root. base::FilePath executable_path; if (Paths::Executable(&executable_path)) { -#if defined(OS_ANDROID) +#if defined(OS_IOS) || defined(OS_ANDROID) + // On Android and iOS, test data is in a crashpad_test_data directory + // adjacent to the main executable. On iOS, this refers to the main + // executable file inside the .app bundle, so crashpad_test_data is also + // inside the bundle. base::FilePath candidate = executable_path.DirName() .Append("crashpad_test_data"); -#else +#else // OS_IOS || OS_ANDRID + // In a standalone build, the test executable is usually at + // out/{Debug,Release} relative to the Crashpad root. base::FilePath candidate = base::FilePath(executable_path.DirName() .Append(base::FilePath::kParentDirectory) .Append(base::FilePath::kParentDirectory)); -#endif +#endif // OS_IOS || OS_ANDROID if (IsTestDataRoot(candidate)) { return candidate; } diff --git a/util/BUILD.gn b/util/BUILD.gn index 183a0a82..7fe02f2b 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -244,14 +244,13 @@ static_library("util") { } } - if (crashpad_is_ios) { + if (crashpad_is_mac || crashpad_is_ios) { sources += [ - "ios/exception_processor.h", - "ios/exception_processor.mm", - "ios/ios_system_data_collector.h", - "ios/ios_system_data_collector.mm", "mac/xattr.cc", "mac/xattr.h", + "misc/clock_mac.cc", + "misc/paths_mac.cc", + "synchronization/semaphore_mac.cc", ] } @@ -264,8 +263,6 @@ static_library("util") { "mac/mac_util.h", "mac/service_management.cc", "mac/service_management.h", - "mac/xattr.cc", - "mac/xattr.h", "mach/child_port_handshake.cc", "mach/child_port_handshake.h", "mach/child_port_server.cc", @@ -298,13 +295,19 @@ static_library("util") { "mach/task_for_pid.cc", "mach/task_for_pid.h", "misc/capture_context_mac.S", - "misc/clock_mac.cc", - "misc/paths_mac.cc", "net/http_transport_mac.mm", "posix/process_info_mac.cc", "process/process_memory_mac.cc", "process/process_memory_mac.h", - "synchronization/semaphore_mac.cc", + ] + } + + if (crashpad_is_ios) { + sources += [ + "ios/exception_processor.h", + "ios/exception_processor.mm", + "ios/ios_system_data_collector.h", + "ios/ios_system_data_collector.mm", ] } @@ -655,12 +658,15 @@ source_set("util_test") { sources += [ "posix/scoped_mmap_test.cc" ] } + if (crashpad_is_mac || crashpad_is_ios) { + sources += [ "mac/xattr_test.cc" ] + } + if (crashpad_is_mac) { sources += [ "mac/launchd_test.mm", "mac/mac_util_test.mm", "mac/service_management_test.mm", - "mac/xattr_test.cc", "mach/child_port_handshake_test.cc", "mach/child_port_server_test.cc", "mach/composite_mach_message_server_test.cc", @@ -684,20 +690,9 @@ source_set("util_test") { sources += [ "ios/exception_processor_test.mm" ] sources -= [ - "file/directory_reader_test.cc", - "file/file_io_test.cc", - "file/filesystem_test.cc", "misc/capture_context_test.cc", - "misc/clock_test.cc", - "misc/paths_test.cc", - "net/http_body_test.cc", - "net/http_multipart_builder_test.cc", "process/process_memory_range_test.cc", "process/process_memory_test.cc", - "stream/file_encoder_test.cc", - "synchronization/semaphore_test.cc", - "thread/thread_test.cc", - "thread/worker_thread_test.cc", ] } @@ -743,7 +738,12 @@ source_set("util_test") { } } - data = [ "net/testdata/" ] + data = [ + "net/testdata/ascii_http_body.txt", + "net/testdata/binary_http_body.dat", + "net/testdata/crashpad_util_test_cert.pem", + "net/testdata/crashpad_util_test_key.pem", + ] deps = [ ":util", @@ -756,10 +756,6 @@ source_set("util_test") { "../third_party/zlib", ] - if (crashpad_is_android || crashpad_is_linux) { - deps += [ "../third_party/lss" ] - } - if (!crashpad_is_android && !crashpad_is_ios) { data_deps = [ ":http_transport_test_server" ] @@ -772,6 +768,14 @@ source_set("util_test") { libs = [ "Foundation.framework" ] } + if (crashpad_is_ios) { + deps += [ ":util_test_bundle_data" ] + } + + if (crashpad_is_android || crashpad_is_linux) { + deps += [ "../third_party/lss" ] + } + if (crashpad_is_win) { libs = [ "rpcrt4.lib", @@ -785,6 +789,20 @@ source_set("util_test") { } } +if (crashpad_is_ios) { + bundle_data("util_test_bundle_data") { + testonly = true + + sources = [ + "net/testdata/ascii_http_body.txt", + "net/testdata/binary_http_body.dat", + ] + + outputs = [ "{{bundle_resources_dir}}/crashpad_test_data/" + + "{{source_root_relative_dir}}/{{source_file_part}}" ] + } +} + if (crashpad_is_win) { crashpad_executable("crashpad_util_test_process_info_test_child") { testonly = true