Tools/ChangeLog

 12017-02-09 Jonathan Bedard <jbedard@apple.com>
 2
 3 Removing LayoutTestRelay
 4 https://bugs.webkit.org/show_bug.cgi?id=165927
 5
 6 Reviewed by NOBODY (OOPS!).
 7 Part 2
 8
 9 LayoutTestRelay uses SPI, since recent versions of the iOS SDK allow for installing apps on simulators through simctl, use this functionality instead.
 10
 11 * BuildSlaveSupport/built-product-archive:
 12 (archiveBuiltProduct): No more special case for iOS Simulator products.
 13 * BuildSlaveSupport/kill-old-processes:
 14 (main): Remove LayoutTestRelay from list of processes.
 15 * LayoutTestRelay: Removed LayoutTestRelay.
 16 * Makefile:
 17 * Scripts/build-layouttestrelay: Removed.
 18 * Scripts/build-webkit: Removed LayoutTestRelay references.
 19
1202017-02-09 Youenn Fablet <youenn@apple.com>
221
322 Improve W3C importer command line options
211961

Tools/LayoutTestRelay/Configurations/Base.xcconfig

1 // Copyright (C) 2014 Apple Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions
5 // are met:
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 //
12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 #include "../../../../Internal/Configurations/HaveInternalSDK.xcconfig"
25 
26 USE_INTERNAL_SDK = $(USE_INTERNAL_SDK_$(CONFIGURATION));
27 USE_INTERNAL_SDK_Production = YES;
28 USE_INTERNAL_SDK_Debug = $(HAVE_INTERNAL_SDK);
29 USE_INTERNAL_SDK_Release = $(HAVE_INTERNAL_SDK);
30 
31 CLANG_CXX_LANGUAGE_STANDARD = gnu++0x;
32 CLANG_ENABLE_OBJC_ARC = YES;
33 CLANG_WARN_CXX0X_EXTENSIONS = NO;
34 HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(SRCROOT)/../../Source/JavaScriptCore/icu $(NEXT_ROOT)/usr/local/include/WebCoreTestSupport;
35 GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) ENABLE_DASHBOARD_SUPPORT;
36 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym;
37 PREBINDING = NO
38 GCC_C_LANGUAGE_STANDARD = gnu99
39 GCC_ENABLE_CPP_EXCEPTIONS = NO;
40 GCC_ENABLE_CPP_RTTI = NO;
41 GCC_PRECOMPILE_PREFIX_HEADER = YES
42 GCC_TREAT_WARNINGS_AS_ERRORS = YES
43 GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
44 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO
45 GCC_WARN_UNUSED_FUNCTION = YES
46 GCC_WARN_UNUSED_VARIABLE = YES
47 GCC_WARN_64_TO_32_BIT_CONVERSION[arch=x86_64] = NO;
48 WARNING_CFLAGS = -Wall -W -Wno-unused-parameter -Wundef
49 
50 DEBUG_DEFINES_debug = ;
51 DEBUG_DEFINES_normal = NDEBUG;
52 DEBUG_DEFINES = $(DEBUG_DEFINES_$(CURRENT_VARIANT));
53 
54 TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
55 TARGET_MAC_OS_X_VERSION_MAJOR_10 = 101000;
56 TARGET_MAC_OS_X_VERSION_MAJOR_11 = 101100;
57 TARGET_MAC_OS_X_VERSION_MAJOR_12 = 101200;
58 TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;
59 
60 SDKROOT = macosx.internal;
61 
62 SUPPORTED_PLATFORMS = macosx;
63 
64 TOOLCHAINS = default;
65 
66 OTHER_CFLAGS = $(ASAN_OTHER_CFLAGS);
67 OTHER_CPLUSPLUSFLAGS = $(ASAN_OTHER_CPLUSPLUSFLAGS);
68 OTHER_LDFLAGS = $(ASAN_OTHER_LDFLAGS);
211961

Tools/LayoutTestRelay/Configurations/DebugRelease.xcconfig

1 // Copyright (C) 2014 Apple Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions
5 // are met:
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 //
12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 #include "Base.xcconfig"
25 
26 ARCHS = $(ARCHS_STANDARD_64_BIT);
27 
28 TARGET_MAC_OS_X_VERSION_MAJOR = $(MAC_OS_X_VERSION_MAJOR);
29 
30 MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_$(TARGET_MAC_OS_X_VERSION_MAJOR))
31 MACOSX_DEPLOYMENT_TARGET_101000 = 10.10;
32 MACOSX_DEPLOYMENT_TARGET_101100 = 10.11;
33 MACOSX_DEPLOYMENT_TARGET_101200 = 10.12;
34 MACOSX_DEPLOYMENT_TARGET_101300 = 10.13;
35 
36 FRAMEWORK_SEARCH_PATHS = $(DEVELOPER_DIR)/Library/PrivateFrameworks;
37 LD_RUNPATH_SEARCH_PATHS = $(DEVELOPER_DIR)/Library/PrivateFrameworks;
38 OTHER_LDFLAGS = -framework CoreSimulator -framework AppKit;
39 
40 SDKROOT = $(SDKROOT_macosx_$(USE_INTERNAL_SDK));
41 SDKROOT_macosx_ = macosx;
42 SDKROOT_macosx_YES = macosx.internal;
211961

Tools/LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h

1 /*
2  * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #if __has_include(<CoreSimulator/CoreSimulator.h>)
27 
28 /* FIXME: Remove the below #define once we require Xcode 7.3 with iOS 9.3 SDK or newer. */
29 #define __coresim_unavailable_msg(msg)
30 #import <CoreSimulator/CoreSimulator.h>
31 
32 /* FIXME: Always use SimServiceContext once we require Xcode 7.3 with iOS 9.3 SDK or newer. */
33 #define USE_SIM_SERVICE_CONTEXT defined(CORESIM_API_MAX_ALLOWED)
34 
35 #else
36 
37 #import <Foundation/Foundation.h>
38 
39 #define USE_SIM_SERVICE_CONTEXT 1
40 
41 #define kSimDeviceLaunchApplicationArguments @"arguments"
42 #define kSimDeviceLaunchApplicationEnvironment @"environment"
43 
44 @interface SimDevice : NSObject
45 - (BOOL)installApplication:(NSURL *)installURL withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error;
46 - (pid_t)launchApplicationWithID:(NSString *)bundleID options:(NSDictionary *)options error:(NSError * __autoreleasing *)error;
47 @end
48 
49 @interface SimDeviceSet : NSObject
50 @property (readonly, copy) NSDictionary *devicesByUDID;
51 @end
52 
53 @interface SimServiceContext : NSObject
54 +(SimServiceContext *)sharedServiceContextForDeveloperDir:(NSString *)developerDir error:(NSError * __autoreleasing *)error;
55 -(SimDeviceSet *)defaultDeviceSetWithError:(NSError * __autoreleasing *)error;
56 @end
57 
58 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTPipeRelay.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef LTPipeRelay_h
27 #define LTPipeRelay_h
28 
29 #import "LTRelay.h"
30 
31 @interface LTPipeRelay : NSObject <LTRelay>
32 @property (weak) id<LTRelayDelegate> relayDelegate;
33 - (id)initWithPrefix:(NSString *)prefix;
34 @end
35 
36 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTPipeRelay.m

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "LTPipeRelay.h"
27 
28 #import <Foundation/Foundation.h>
29 #include <sys/stat.h>
30 #include <sys/types.h>
31 
32 @interface LTPipeRelay ()
33 @property (readonly, strong) NSString *fifoPrefix;
34 @property (strong) NSOutputStream *standardInputPipe;
35 @property (strong) NSInputStream *standardOutputPipe;
36 @property (strong) NSInputStream *standardErrorPipe;
37 
38 - (void)createFIFOs;
39 - (void)destroyFIFOs;
40 @end
41 
42 @implementation LTPipeRelay
43 
44 - (NSString *)inPipePath
45 {
46  return [_fifoPrefix stringByAppendingString:@"_IN"];
47 }
48 
49 - (NSString *)outPipePath
50 {
51  return [_fifoPrefix stringByAppendingString:@"_OUT"];
52 }
53 
54 - (NSString *)errorPipePath
55 {
56  return [_fifoPrefix stringByAppendingString:@"_ERROR"];
57 }
58 
59 - (NSOutputStream *) outputStream
60 {
61  return _standardInputPipe;
62 }
63 
64 - (id)initWithPrefix:(NSString *)prefix
65 {
66  if ((self = [super init])) {
67  _fifoPrefix = prefix;
68  [self destroyFIFOs];
69  }
70  return self;
71 }
72 
73 - (void)setup
74 {
75  [self destroyFIFOs];
76  [self createFIFOs];
77 }
78 
79 - (void)tearDown
80 {
81  [self destroyFIFOs];
82 }
83 
84 -(void) connect
85 {
86  _standardInputPipe = [NSOutputStream outputStreamToFileAtPath:[self inPipePath] append:YES];
87  _standardOutputPipe = [NSInputStream inputStreamWithFileAtPath:[self outPipePath]];
88  _standardErrorPipe = [NSInputStream inputStreamWithFileAtPath:[self errorPipePath]];
89 
90  [[self standardInputPipe] setDelegate:self];
91  [[self standardOutputPipe] setDelegate:self];
92  [[self standardErrorPipe] setDelegate:self];
93 
94  [[self standardOutputPipe] scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
95  [[self standardErrorPipe] scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
96 
97  [[self standardInputPipe] open];
98  [[self standardOutputPipe] open];
99  [[self standardErrorPipe] open];
100 
101  [[self relayDelegate] didConnect];
102 }
103 
104 - (void)disconnect
105 {
106  [[self standardOutputPipe] close];
107  [[self standardErrorPipe] close];
108  [[self standardInputPipe] close];
109  [[self relayDelegate] didDisconnect];
110 }
111 
112 - (void)createFIFOs
113 {
114  mkfifo([[self inPipePath] UTF8String], 0666);
115  mkfifo([[self outPipePath] UTF8String], 0666);
116  mkfifo([[self errorPipePath] UTF8String], 0666);
117 }
118 
119 - (void)destroyFIFOs
120 {
121  unlink([[self inPipePath] UTF8String]);
122  unlink([[self outPipePath] UTF8String]);
123  unlink([[self errorPipePath] UTF8String]);
124 }
125 
126 - (void) relayStream:(NSInputStream *)stream
127 {
128  uint8_t bytes[1024];
129  NSInteger bytesRead = [stream read:bytes maxLength:1024];
130  NSData *data = [NSData dataWithBytes:bytes length:bytesRead];
131 
132  if (stream == [self standardOutputPipe])
133  [[self relayDelegate] didReceiveStdoutData:data];
134  else
135  [[self relayDelegate] didReceiveStderrData:data];
136 }
137 
138 - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
139 {
140  switch (eventCode) {
141  case NSStreamEventNone:
142  break;
143  case NSStreamEventHasBytesAvailable:
144  [self relayStream:(NSInputStream *)aStream];
145  case NSStreamEventHasSpaceAvailable:
146  break;
147  case NSStreamEventOpenCompleted:
148  break;
149  case NSStreamEventEndEncountered:
150  [[self relayDelegate] didCrashWithMessage:nil];
151  break;
152  case NSStreamEventErrorOccurred:
153  [[self relayDelegate] didCrashWithMessage:[[aStream streamError] description]];
154  break;
155  }
156 }
157 
158 @end
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelay.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef LTRelay_h
27 #define LTRelay_h
28 
29 #import <Foundation/Foundation.h>
30 
31 @protocol LTRelayDelegate <NSObject>
32 - (void)didConnect;
33 - (void)didDisconnect;
34 - (void)didCrashWithMessage:(NSString *)message;
35 - (void)didReceiveStdoutData:(NSData *)data;
36 - (void)didReceiveStderrData:(NSData *)data;
37 @end
38 
39 @protocol LTRelay <NSObject, NSStreamDelegate>
40 - (void)setup;
41 - (void)tearDown;
42 - (void)connect;
43 - (void)disconnect;
44 @property (weak) id<LTRelayDelegate> relayDelegate;
45 @property (readonly, strong) NSOutputStream *outputStream;
46 @end
47 
48 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef LTRelayController_h
26 #define LTRelayController_h
27 
28 #import "LTRelay.h"
29 
30 #import <Foundation/Foundation.h>
31 
32 @class SimDevice;
33 
34 @interface LTRelayController : NSObject <LTRelayDelegate>
35 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments;
36 - (void)start;
37 - (void)finish;
38 @end
39 
40 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "LTRelayController.h"
27 
28 #import "CoreSimulatorSPI.h"
29 #import "LTPipeRelay.h"
30 #import <AppKit/AppKit.h>
31 #import <crt_externs.h>
32 
33 @interface LTRelayController ()
34 @property (readonly, strong) dispatch_source_t standardInputDispatchSource;
35 @property (readonly, strong) NSFileHandle *standardOutput;
36 @property (readonly, strong) NSFileHandle *standardError;
37 @property (readonly, strong) NSString *ipcIdentifier;
38 @property (readonly, strong) NSString *appBundleIdentifier;
39 @property (readonly, strong) NSString *appPath;
40 @property (readonly, strong) NSUUID *deviceUDID;
41 @property (readonly, strong) NSArray *dumpToolArguments;
42 @property (readonly, strong) NSString *productDir;
43 @property (strong) SimDevice *device;
44 @property (strong) id<LTRelay> relay;
45 @property pid_t pid;
46 @property (strong) dispatch_source_t appDispatchSource;
47 @end
48 
49 @implementation LTRelayController
50 
51 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments
52 {
53  if ((self = [super init])) {
54  _device = device;
55  _productDir = productDir;
56  _appPath = appPath;
57  _appBundleIdentifier = [[NSBundle bundleWithPath:appPath] bundleIdentifier];
58  _deviceUDID = udid;
59  _dumpToolArguments = arguments;
60  _standardInputDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, STDIN_FILENO, 0, dispatch_get_main_queue());
61  _standardOutput = [NSFileHandle fileHandleWithStandardOutput];
62  _standardError = [NSFileHandle fileHandleWithStandardError];
63 
64  dispatch_source_set_event_handler(_standardInputDispatchSource, ^{
65  uint8_t buffer[1024];
66  ssize_t len = read(STDIN_FILENO, buffer, sizeof(buffer));
67  if (len > 0) {
68  @try {
69  [[[self relay] outputStream] write:buffer maxLength:len];
70  } @catch (NSException *e) {
71  // Broken pipe - the dump tool crashed. Time to die.
72  [self didCrashWithMessage:nil];
73  }
74  } else {
75  // EOF Received on the relay's standard input.
76  [self finish];
77  }
78  });
79 
80  _relay = [[LTPipeRelay alloc] initWithPrefix:[@"/tmp" stringByAppendingPathComponent:self.ipcIdentifier]];
81  [_relay setRelayDelegate:self];
82  }
83  return self;
84 }
85 
86 - (NSString *)ipcIdentifier
87 {
88  return [NSString stringWithFormat:@"%@-%@", self.appBundleIdentifier, self.deviceUDID.UUIDString];
89 }
90 
91 - (NSString *)processName
92 {
93  return [self.appBundleIdentifier componentsSeparatedByString:@"."].lastObject;
94 }
95 
96 - (void)didReceiveStdoutData:(NSData *)data
97 {
98  @try {
99  [[self standardOutput] writeData:data];
100  } @catch (NSException *exception) {
101  // NSFileHandleOperationException
102  // Broken pipe - the test harness stopped listening to us,
103  // probably because we timed out or a run was canceled.
104  exit(EXIT_FAILURE);
105  }
106 }
107 
108 - (void)didReceiveStderrData:(NSData *)data
109 {
110  @try {
111  [[self standardError] writeData:data];
112  } @catch (NSException *exception) {
113  // NSFileHandleOperationException
114  // Broken pipe - the test harness stopped listening to us,
115  // probably because we timed out or a run was canceled.
116  exit(EXIT_FAILURE);
117  }
118 }
119 
120 - (void)didDisconnect
121 {
122  dispatch_suspend([self standardInputDispatchSource]);
123 }
124 
125 - (void)didConnect
126 {
127  dispatch_resume([self standardInputDispatchSource]);
128 }
129 
130 - (void)didCrashWithMessage:(NSString *)message
131 {
132  [[self relay] disconnect];
133  NSString *crashMessage = [NSString stringWithFormat:@"\n#CRASHED - %@ (pid %d)\n", [self processName], [self pid]];
134 
135  if (message)
136  crashMessage = [crashMessage stringByAppendingFormat:@"%@\n", message];
137 
138  [[self standardError] writeData:[crashMessage dataUsingEncoding:NSUTF8StringEncoding]];
139  [[self standardError] closeFile];
140  [[self standardOutput] closeFile];
141  exit(EXIT_FAILURE);
142 }
143 
144 - (void)installApp
145 {
146  NSDictionary *installOptions = @{
147  (NSString *)kCFBundleIdentifierKey: self.appBundleIdentifier,
148  };
149 
150  NSError *error = nil;
151  BOOL installed = [self.device installApplication:[NSURL fileURLWithPath:self.appPath] withOptions:installOptions error:&error];
152  if (!installed) {
153  NSLog(@"Couldn't install %@: %@", self.appPath, error.description);
154  exit(EXIT_FAILURE);
155  }
156 }
157 
158 - (void)killApp
159 {
160  dispatch_source_t dispatch = [self appDispatchSource];
161 
162  if (dispatch)
163  dispatch_source_cancel(dispatch);
164 
165  if ([self pid] > 1) {
166  kill(self.pid, SIGKILL);
167  [self setPid:-1];
168  }
169  [self setAppDispatchSource:nil];
170 }
171 
172 - (NSDictionary *)_environmentVariables
173 {
174  static NSDictionary *environmentVariables;
175  static dispatch_once_t once;
176 
177  dispatch_once(&once, ^{
178  NSString *productDirectory = [self productDir];
179 
180  NSMutableDictionary *dictionary = [@{
181  @"IPC_IDENTIFIER": self.ipcIdentifier,
182  @"DYLD_FRAMEWORK_PATH": productDirectory,
183  @"__XPC_DYLD_FRAMEWORK_PATH": productDirectory,
184  @"DYLD_LIBRARY_PATH": productDirectory,
185  @"__XPC_DYLD_LIBRARY_PATH": productDirectory,
186  } mutableCopy];
187 
188  for (NSString *keyName in @[@"DYLD_INSERT_LIBRARIES", @"MallocStackLogging", @"LOCAL_RESOURCE_ROOT", @"DUMPRENDERTREE_TEMP"]) {
189  const char* value = getenv([keyName UTF8String]);
190  if (value && strlen(value)) {
191  NSString *nsValue = [NSString stringWithUTF8String:value];
192  [dictionary setObject:nsValue forKey:keyName];
193  [dictionary setObject:nsValue forKey:[@"__XPC_" stringByAppendingString:keyName]];
194  }
195  }
196 
197  for (char** envp = *_NSGetEnviron(); *envp; envp++) {
198  const char* env = *envp;
199  if (!strncmp("JSC_", env, 4) || !strncmp("__XPC_JSC_", env, 10)) {
200  const char* equal = strchr(env, '=');
201  if (!equal) {
202  NSLog(@"Missing '=' in env var '%s'", env);
203  continue;
204  }
205 
206  static const size_t maxKeyLength = 256;
207  size_t keyLength = equal - env;
208  if (keyLength >= maxKeyLength) {
209  NSLog(@"Env var '%s' is too long", env);
210  continue;
211  }
212 
213  char key[maxKeyLength];
214  strncpy(key, env, keyLength);
215  key[keyLength] = '\0';
216  const char* value = equal + 1;
217 
218  NSString *nsKey = [NSString stringWithUTF8String:key];
219  NSString *nsValue = [NSString stringWithUTF8String:value];
220  [dictionary setObject:nsValue forKey:nsKey];
221  }
222  }
223 
224  environmentVariables = [dictionary copy];
225  });
226 
227  return environmentVariables;
228 }
229 
230 - (void)launchApp
231 {
232  NSDictionary *launchOptions = @{
233  kSimDeviceLaunchApplicationEnvironment: [self _environmentVariables],
234  kSimDeviceLaunchApplicationArguments: [self dumpToolArguments],
235  };
236 
237  NSError *error;
238  pid_t pid = [self.device launchApplicationWithID:self.appBundleIdentifier options:launchOptions error:&error];
239 
240  if (pid < 0) {
241  NSLog(@"Couldn't launch %@: %@", self.appBundleIdentifier, error.description);
242  exit(EXIT_FAILURE);
243  }
244 
245  [self setPid:pid];
246 
247  dispatch_queue_t queue = dispatch_get_main_queue();
248  dispatch_source_t simulatorAppExitDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, [self pid], DISPATCH_PROC_EXIT, queue);
249  [self setAppDispatchSource:simulatorAppExitDispatchSource];
250  dispatch_source_set_event_handler(simulatorAppExitDispatchSource, ^{
251  dispatch_source_cancel(simulatorAppExitDispatchSource);
252  [self didCrashWithMessage:nil];
253  });
254  dispatch_resume(simulatorAppExitDispatchSource);
255 }
256 
257 - (void)start
258 {
259  [self installApp];
260  [[self relay] setup];
261  [self launchApp];
262  [[self relay] connect];
263 }
264 
265 - (void)finish
266 {
267  [[self relay] disconnect];
268  [self killApp];
269  exit(EXIT_SUCCESS);
270 }
271 
272 @end
211961

Tools/LayoutTestRelay/LayoutTestRelay/main.m

1 /*
2  * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "CoreSimulatorSPI.h"
27 #import "LTRelayController.h"
28 #import <Foundation/Foundation.h>
29 
30 static LTRelayController *relayController;
31 
32 void usage()
33 {
34  NSString *helpText = @"LayoutTestRelay: run a dump tool in the simulator. Not for direct consumption.\n"
35  "Usage: LayoutTestRelay [-h] [options] -- [dump tool arguments]\n"
36  "Required options:\n"
37  " -udid <identifier> Simulator device identifier\n"
38  " -app <app_path> Path to the built iOS .app bundle directory.\n"
39  " -productDir <dir> /path/to/WebKitBuild/{configuration}-{short platform}.\n";
40 
41  fprintf(stderr, "%s\n", [helpText UTF8String]);
42 }
43 
44 NSString *getRequiredStringArgument(NSString *parameter)
45 {
46  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
47  NSString *argument = [defaults stringForKey:parameter];
48 
49  if (!argument) {
50  NSLog(@"-%@ is required.", parameter);
51  usage();
52  exit(EXIT_FAILURE);
53  }
54  return argument;
55 }
56 
57 NSArray *getDumpToolArguments()
58 {
59  NSMutableArray *dumpToolArguments = [[NSMutableArray alloc] init];
60  NSArray *processArgs = [[NSProcessInfo processInfo] arguments];
61  BOOL appending = NO;
62  for (NSString *arg in processArgs) {
63  if ([arg isEqualToString:@"--"]) {
64  appending = YES;
65  continue;
66  }
67  if (appending)
68  [dumpToolArguments addObject:arg];
69  }
70  return dumpToolArguments;
71 }
72 
73 void finish()
74 {
75  [relayController finish];
76 }
77 
78 void receivedSignal(int signal)
79 {
80  exit(EXIT_SUCCESS);
81 }
82 
83 int main(int argc, const char * argv[])
84 {
85  @autoreleasepool {
86  NSArray *helpArguments = @[@"-h", @"--help"];
87  for (NSString *helpArgument in helpArguments) {
88  if ([[[NSProcessInfo processInfo] arguments] indexOfObject:helpArgument] != NSNotFound) {
89  usage();
90  exit(EXIT_FAILURE);
91  }
92  }
93 
94 #if USE_SIM_SERVICE_CONTEXT
95  NSString *developerDirectory = getRequiredStringArgument(@"developerDir");
96 #endif
97  NSUUID *udid = [[NSUUID alloc] initWithUUIDString:getRequiredStringArgument(@"udid")];
98  NSString *appPath = getRequiredStringArgument(@"app");
99  NSString *productDirectory = getRequiredStringArgument(@"productDir");
100  NSArray *dumpToolArguments = getDumpToolArguments();
101 
102 #if USE_SIM_SERVICE_CONTEXT
103  NSError *error;
104  SimServiceContext *serviceContext = [SimServiceContext sharedServiceContextForDeveloperDir:developerDirectory error:&error];
105  if (!serviceContext) {
106  NSLog(@"Device context couldn't be found: %@", error);
107  exit(EXIT_FAILURE);
108  }
109  SimDeviceSet *deviceSet = [serviceContext defaultDeviceSetWithError:nil];
110  if (!deviceSet) {
111  NSLog(@"Default device set couldn't be found: %@", error);
112  exit(EXIT_FAILURE);
113  }
114  SimDevice *device = [deviceSet.devicesByUDID objectForKey:udid];
115 #else
116  SimDevice *device = [SimDeviceSet.defaultSet.devicesByUDID objectForKey:udid];
117 #endif
118  if (!device) {
119  NSLog(@"Device %@ couldn't be found", udid);
120  exit(EXIT_FAILURE);
121  }
122 
123  relayController = [[LTRelayController alloc] initWithDevice:device productDir:productDirectory appPath:appPath deviceUDID:udid dumpToolArguments:dumpToolArguments];
124  [relayController start];
125 
126  atexit(finish);
127  signal(SIGINT, receivedSignal);
128  signal(SIGTERM, receivedSignal);
129 
130  [[NSRunLoop mainRunLoop] run];
131  }
132  return 0;
133 }
211961

Tools/LayoutTestRelay/LayoutTestRelay.xcodeproj/project.pbxproj

1 // !$*UTF8*$!
2 {
3  archiveVersion = 1;
4  classes = {
5  };
6  objectVersion = 46;
7  objects = {
8 
9 /* Begin PBXBuildFile section */
10  2E8D3EF819881D43004F6CC2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3EF719881D43004F6CC2 /* main.m */; };
11  2E8D3F0219881FD0004F6CC2 /* LTPipeRelay.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */; };
12  2E8D3F0619882406004F6CC2 /* LTRelayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3F0519882406004F6CC2 /* LTRelayController.m */; };
13 /* End PBXBuildFile section */
14 
15 /* Begin PBXCopyFilesBuildPhase section */
16  2E8D3EF219881D43004F6CC2 /* CopyFiles */ = {
17  isa = PBXCopyFilesBuildPhase;
18  buildActionMask = 2147483647;
19  dstPath = /usr/share/man/man1/;
20  dstSubfolderSpec = 0;
21  files = (
22  );
23  runOnlyForDeploymentPostprocessing = 1;
24  };
25 /* End PBXCopyFilesBuildPhase section */
26 
27 /* Begin PBXFileReference section */
28  2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LayoutTestRelay; sourceTree = BUILT_PRODUCTS_DIR; };
29  2E8D3EF719881D43004F6CC2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
30  2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = DebugRelease.xcconfig; path = Configurations/DebugRelease.xcconfig; sourceTree = "<group>"; };
31  2E8D3EFF19881E25004F6CC2 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Base.xcconfig; path = Configurations/Base.xcconfig; sourceTree = "<group>"; };
32  2E8D3F0019881F29004F6CC2 /* LTRelay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTRelay.h; sourceTree = "<group>"; };
33  2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTPipeRelay.m; sourceTree = "<group>"; };
34  2E8D3F0319881FE2004F6CC2 /* LTPipeRelay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTPipeRelay.h; sourceTree = "<group>"; };
35  2E8D3F0419882406004F6CC2 /* LTRelayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LTRelayController.h; sourceTree = "<group>"; };
36  2E8D3F0519882406004F6CC2 /* LTRelayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTRelayController.m; sourceTree = "<group>"; };
37  CE1FBC151B290E79000136F5 /* CoreSimulatorSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreSimulatorSPI.h; sourceTree = "<group>"; };
38 /* End PBXFileReference section */
39 
40 /* Begin PBXFrameworksBuildPhase section */
41  2E8D3EF119881D43004F6CC2 /* Frameworks */ = {
42  isa = PBXFrameworksBuildPhase;
43  buildActionMask = 2147483647;
44  files = (
45  );
46  runOnlyForDeploymentPostprocessing = 0;
47  };
48 /* End PBXFrameworksBuildPhase section */
49 
50 /* Begin PBXGroup section */
51  2E8D3EEB19881D43004F6CC2 = {
52  isa = PBXGroup;
53  children = (
54  2E8D3EFF19881E25004F6CC2 /* Base.xcconfig */,
55  2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */,
56  2E8D3EF619881D43004F6CC2 /* LayoutTestRelay */,
57  2E8D3EF519881D43004F6CC2 /* Products */,
58  );
59  sourceTree = "<group>";
60  };
61  2E8D3EF519881D43004F6CC2 /* Products */ = {
62  isa = PBXGroup;
63  children = (
64  2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */,
65  );
66  name = Products;
67  sourceTree = "<group>";
68  };
69  2E8D3EF619881D43004F6CC2 /* LayoutTestRelay */ = {
70  isa = PBXGroup;
71  children = (
72  2E8D3EF719881D43004F6CC2 /* main.m */,
73  CE1FBC151B290E79000136F5 /* CoreSimulatorSPI.h */,
74  2E8D3F0019881F29004F6CC2 /* LTRelay.h */,
75  2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */,
76  2E8D3F0319881FE2004F6CC2 /* LTPipeRelay.h */,
77  2E8D3F0419882406004F6CC2 /* LTRelayController.h */,
78  2E8D3F0519882406004F6CC2 /* LTRelayController.m */,
79  );
80  path = LayoutTestRelay;
81  sourceTree = "<group>";
82  };
83 /* End PBXGroup section */
84 
85 /* Begin PBXNativeTarget section */
86  2E8D3EF319881D43004F6CC2 /* LayoutTestRelay */ = {
87  isa = PBXNativeTarget;
88  buildConfigurationList = 2E8D3EFB19881D43004F6CC2 /* Build configuration list for PBXNativeTarget "LayoutTestRelay" */;
89  buildPhases = (
90  2E8D3EF019881D43004F6CC2 /* Sources */,
91  2E8D3EF119881D43004F6CC2 /* Frameworks */,
92  2E8D3EF219881D43004F6CC2 /* CopyFiles */,
93  );
94  buildRules = (
95  );
96  dependencies = (
97  );
98  name = LayoutTestRelay;
99  productName = LayoutTestRelay;
100  productReference = 2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */;
101  productType = "com.apple.product-type.tool";
102  };
103 /* End PBXNativeTarget section */
104 
105 /* Begin PBXProject section */
106  2E8D3EEC19881D43004F6CC2 /* Project object */ = {
107  isa = PBXProject;
108  attributes = {
109  LastUpgradeCheck = 0600;
110  ORGANIZATIONNAME = "Apple, Inc.";
111  TargetAttributes = {
112  2E8D3EF319881D43004F6CC2 = {
113  CreatedOnToolsVersion = 6.0;
114  };
115  };
116  };
117  buildConfigurationList = 2E8D3EEF19881D43004F6CC2 /* Build configuration list for PBXProject "LayoutTestRelay" */;
118  compatibilityVersion = "Xcode 3.2";
119  developmentRegion = English;
120  hasScannedForEncodings = 0;
121  knownRegions = (
122  en,
123  );
124  mainGroup = 2E8D3EEB19881D43004F6CC2;
125  productRefGroup = 2E8D3EF519881D43004F6CC2 /* Products */;
126  projectDirPath = "";
127  projectRoot = "";
128  targets = (
129  2E8D3EF319881D43004F6CC2 /* LayoutTestRelay */,
130  );
131  };
132 /* End PBXProject section */
133 
134 /* Begin PBXSourcesBuildPhase section */
135  2E8D3EF019881D43004F6CC2 /* Sources */ = {
136  isa = PBXSourcesBuildPhase;
137  buildActionMask = 2147483647;
138  files = (
139  2E8D3F0619882406004F6CC2 /* LTRelayController.m in Sources */,
140  2E8D3EF819881D43004F6CC2 /* main.m in Sources */,
141  2E8D3F0219881FD0004F6CC2 /* LTPipeRelay.m in Sources */,
142  );
143  runOnlyForDeploymentPostprocessing = 0;
144  };
145 /* End PBXSourcesBuildPhase section */
146 
147 /* Begin XCBuildConfiguration section */
148  2E8D3EF919881D43004F6CC2 /* Debug */ = {
149  isa = XCBuildConfiguration;
150  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
151  buildSettings = {
152  };
153  name = Debug;
154  };
155  2E8D3EFA19881D43004F6CC2 /* Release */ = {
156  isa = XCBuildConfiguration;
157  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
158  buildSettings = {
159  };
160  name = Release;
161  };
162  2E8D3EFC19881D43004F6CC2 /* Debug */ = {
163  isa = XCBuildConfiguration;
164  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
165  buildSettings = {
166  PRODUCT_NAME = "$(TARGET_NAME)";
167  };
168  name = Debug;
169  };
170  2E8D3EFD19881D43004F6CC2 /* Release */ = {
171  isa = XCBuildConfiguration;
172  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
173  buildSettings = {
174  PRODUCT_NAME = "$(TARGET_NAME)";
175  };
176  name = Release;
177  };
178 /* End XCBuildConfiguration section */
179 
180 /* Begin XCConfigurationList section */
181  2E8D3EEF19881D43004F6CC2 /* Build configuration list for PBXProject "LayoutTestRelay" */ = {
182  isa = XCConfigurationList;
183  buildConfigurations = (
184  2E8D3EF919881D43004F6CC2 /* Debug */,
185  2E8D3EFA19881D43004F6CC2 /* Release */,
186  );
187  defaultConfigurationIsVisible = 0;
188  defaultConfigurationName = Release;
189  };
190  2E8D3EFB19881D43004F6CC2 /* Build configuration list for PBXNativeTarget "LayoutTestRelay" */ = {
191  isa = XCConfigurationList;
192  buildConfigurations = (
193  2E8D3EFC19881D43004F6CC2 /* Debug */,
194  2E8D3EFD19881D43004F6CC2 /* Release */,
195  );
196  defaultConfigurationIsVisible = 0;
197  defaultConfigurationName = Release;
198  };
199 /* End XCConfigurationList section */
200  };
201  rootObject = 2E8D3EEC19881D43004F6CC2 /* Project object */;
202 }
211961

Tools/LayoutTestRelay/LayoutTestRelay.xcodeproj

Deleted: svn:ignore
## -1,2 +0,0 ##
project.xcworkspace
xcuserdata
211961

Tools/LayoutTestRelay/Makefile

1 SCRIPTS_PATH = ../Scripts
2 
3 OVERRIDE_ARCHS = default
4 OVERRIDE_SDKROOT = default
5 
6 include ../../Makefile.shared
211961

Tools/Makefile

@@ifneq (,$(SDKROOT))
77 ifneq (,$(findstring iphone,$(SDKROOT)))
88 MODULES += MobileMiniBrowser
99 endif
10  ifeq (,$(DO_NOT_BUILD_LAYOUT_TEST_RELAY))
11  MODULES += LayoutTestRelay
12  endif
1310endif
1411
1512all:
211961

Tools/BuildSlaveSupport/built-product-archive

@@def dirContainsdwo(directory):
165165def archiveBuiltProduct(configuration, platform, fullPlatform):
166166 assert platform in ('mac', 'win', 'gtk', 'efl', 'ios')
167167
168  if fullPlatform.startswith('ios-simulator'):
169  # We need to include in the archive the Mac tool, LayoutTestRelay, to run layout tests in the iOS simulator.
170  combinedDirectory = os.path.join(_topLevelBuildDirectory, 'combined-mac-and-ios')
171  removeDirectoryIfExists(combinedDirectory)
172  os.makedirs(combinedDirectory)
173 
174  if subprocess.call(['/bin/cp', '-pR', _configurationBuildDirectory, combinedDirectory]):
175  return 1
176 
177  macBuildDirectory = webkitBuildDirectoryForConfigurationAndPlatform(configuration, 'mac')
178  destinationDirectory = os.path.join(combinedDirectory, os.path.relpath(macBuildDirectory, _topLevelBuildDirectory))
179  os.makedirs(destinationDirectory)
180  for filename in ['LayoutTestRelay', 'LayoutTestRelay.dSYM']:
181  sourceFile = os.path.join(macBuildDirectory, filename)
182  if not os.path.exists(sourceFile):
183  continue
184  if subprocess.call(['/bin/cp', '-pR', sourceFile, destinationDirectory]):
185  return 1
186 
187  if createZip(combinedDirectory, configuration):
188  return 1
189  shutil.rmtree(combinedDirectory)
190  elif platform in ('mac', 'ios'):
 168 # FIXME: ImageDiff should be built with the host SDK <rdar://problem/30266038>
 169 if platform in ('mac', 'ios'):
191170 return createZip(_configurationBuildDirectory, configuration, embedParentDirectoryNameOnDarwin=True)
192171 elif platform == 'win':
193172 # FIXME: We shouldn't hardcode the assumption of a 32-bit build. See <https://bugs.webkit.org/show_bug.cgi?id=149715>.
211961

Tools/BuildSlaveSupport/kill-old-processes

@@def main():
8989 "WebProcess",
9090 "xcodebuild",
9191 # FIXME: Consider moving iOS-specific tasks to their own list.
92  "Simulator",
93  "LayoutTestRelay"
 92 "Simulator"
9493 ]
9594
9695 taskToKillUnix = [
211961

Tools/LayoutTestRelay/Configurations/Base.xcconfig

1 // Copyright (C) 2014 Apple Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions
5 // are met:
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 //
12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 #include "../../../../Internal/Configurations/HaveInternalSDK.xcconfig"
25 
26 USE_INTERNAL_SDK = $(USE_INTERNAL_SDK_$(CONFIGURATION));
27 USE_INTERNAL_SDK_Production = YES;
28 USE_INTERNAL_SDK_Debug = $(HAVE_INTERNAL_SDK);
29 USE_INTERNAL_SDK_Release = $(HAVE_INTERNAL_SDK);
30 
31 CLANG_CXX_LANGUAGE_STANDARD = gnu++0x;
32 CLANG_ENABLE_OBJC_ARC = YES;
33 CLANG_WARN_CXX0X_EXTENSIONS = NO;
34 HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(SRCROOT)/../../Source/JavaScriptCore/icu $(NEXT_ROOT)/usr/local/include/WebCoreTestSupport;
35 GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) ENABLE_DASHBOARD_SUPPORT;
36 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym;
37 PREBINDING = NO
38 GCC_C_LANGUAGE_STANDARD = gnu99
39 GCC_ENABLE_CPP_EXCEPTIONS = NO;
40 GCC_ENABLE_CPP_RTTI = NO;
41 GCC_PRECOMPILE_PREFIX_HEADER = YES
42 GCC_TREAT_WARNINGS_AS_ERRORS = YES
43 GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
44 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO
45 GCC_WARN_UNUSED_FUNCTION = YES
46 GCC_WARN_UNUSED_VARIABLE = YES
47 GCC_WARN_64_TO_32_BIT_CONVERSION[arch=x86_64] = NO;
48 WARNING_CFLAGS = -Wall -W -Wno-unused-parameter -Wundef
49 
50 DEBUG_DEFINES_debug = ;
51 DEBUG_DEFINES_normal = NDEBUG;
52 DEBUG_DEFINES = $(DEBUG_DEFINES_$(CURRENT_VARIANT));
53 
54 TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
55 TARGET_MAC_OS_X_VERSION_MAJOR_10 = 101000;
56 TARGET_MAC_OS_X_VERSION_MAJOR_11 = 101100;
57 TARGET_MAC_OS_X_VERSION_MAJOR_12 = 101200;
58 TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;
59 
60 SDKROOT = macosx.internal;
61 
62 SUPPORTED_PLATFORMS = macosx;
63 
64 TOOLCHAINS = default;
65 
66 OTHER_CFLAGS = $(ASAN_OTHER_CFLAGS);
67 OTHER_CPLUSPLUSFLAGS = $(ASAN_OTHER_CPLUSPLUSFLAGS);
68 OTHER_LDFLAGS = $(ASAN_OTHER_LDFLAGS);
211961

Tools/LayoutTestRelay/Configurations/DebugRelease.xcconfig

1 // Copyright (C) 2014 Apple Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions
5 // are met:
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 //
12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 #include "Base.xcconfig"
25 
26 ARCHS = $(ARCHS_STANDARD_64_BIT);
27 
28 TARGET_MAC_OS_X_VERSION_MAJOR = $(MAC_OS_X_VERSION_MAJOR);
29 
30 MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_$(TARGET_MAC_OS_X_VERSION_MAJOR))
31 MACOSX_DEPLOYMENT_TARGET_101000 = 10.10;
32 MACOSX_DEPLOYMENT_TARGET_101100 = 10.11;
33 MACOSX_DEPLOYMENT_TARGET_101200 = 10.12;
34 MACOSX_DEPLOYMENT_TARGET_101300 = 10.13;
35 
36 FRAMEWORK_SEARCH_PATHS = $(DEVELOPER_DIR)/Library/PrivateFrameworks;
37 LD_RUNPATH_SEARCH_PATHS = $(DEVELOPER_DIR)/Library/PrivateFrameworks;
38 OTHER_LDFLAGS = -framework CoreSimulator -framework AppKit;
39 
40 SDKROOT = $(SDKROOT_macosx_$(USE_INTERNAL_SDK));
41 SDKROOT_macosx_ = macosx;
42 SDKROOT_macosx_YES = macosx.internal;
211961

Tools/LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h

1 /*
2  * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #if __has_include(<CoreSimulator/CoreSimulator.h>)
27 
28 /* FIXME: Remove the below #define once we require Xcode 7.3 with iOS 9.3 SDK or newer. */
29 #define __coresim_unavailable_msg(msg)
30 #import <CoreSimulator/CoreSimulator.h>
31 
32 /* FIXME: Always use SimServiceContext once we require Xcode 7.3 with iOS 9.3 SDK or newer. */
33 #define USE_SIM_SERVICE_CONTEXT defined(CORESIM_API_MAX_ALLOWED)
34 
35 #else
36 
37 #import <Foundation/Foundation.h>
38 
39 #define USE_SIM_SERVICE_CONTEXT 1
40 
41 #define kSimDeviceLaunchApplicationArguments @"arguments"
42 #define kSimDeviceLaunchApplicationEnvironment @"environment"
43 
44 @interface SimDevice : NSObject
45 - (BOOL)installApplication:(NSURL *)installURL withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error;
46 - (pid_t)launchApplicationWithID:(NSString *)bundleID options:(NSDictionary *)options error:(NSError * __autoreleasing *)error;
47 @end
48 
49 @interface SimDeviceSet : NSObject
50 @property (readonly, copy) NSDictionary *devicesByUDID;
51 @end
52 
53 @interface SimServiceContext : NSObject
54 +(SimServiceContext *)sharedServiceContextForDeveloperDir:(NSString *)developerDir error:(NSError * __autoreleasing *)error;
55 -(SimDeviceSet *)defaultDeviceSetWithError:(NSError * __autoreleasing *)error;
56 @end
57 
58 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTPipeRelay.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef LTPipeRelay_h
27 #define LTPipeRelay_h
28 
29 #import "LTRelay.h"
30 
31 @interface LTPipeRelay : NSObject <LTRelay>
32 @property (weak) id<LTRelayDelegate> relayDelegate;
33 - (id)initWithPrefix:(NSString *)prefix;
34 @end
35 
36 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTPipeRelay.m

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "LTPipeRelay.h"
27 
28 #import <Foundation/Foundation.h>
29 #include <sys/stat.h>
30 #include <sys/types.h>
31 
32 @interface LTPipeRelay ()
33 @property (readonly, strong) NSString *fifoPrefix;
34 @property (strong) NSOutputStream *standardInputPipe;
35 @property (strong) NSInputStream *standardOutputPipe;
36 @property (strong) NSInputStream *standardErrorPipe;
37 
38 - (void)createFIFOs;
39 - (void)destroyFIFOs;
40 @end
41 
42 @implementation LTPipeRelay
43 
44 - (NSString *)inPipePath
45 {
46  return [_fifoPrefix stringByAppendingString:@"_IN"];
47 }
48 
49 - (NSString *)outPipePath
50 {
51  return [_fifoPrefix stringByAppendingString:@"_OUT"];
52 }
53 
54 - (NSString *)errorPipePath
55 {
56  return [_fifoPrefix stringByAppendingString:@"_ERROR"];
57 }
58 
59 - (NSOutputStream *) outputStream
60 {
61  return _standardInputPipe;
62 }
63 
64 - (id)initWithPrefix:(NSString *)prefix
65 {
66  if ((self = [super init])) {
67  _fifoPrefix = prefix;
68  [self destroyFIFOs];
69  }
70  return self;
71 }
72 
73 - (void)setup
74 {
75  [self destroyFIFOs];
76  [self createFIFOs];
77 }
78 
79 - (void)tearDown
80 {
81  [self destroyFIFOs];
82 }
83 
84 -(void) connect
85 {
86  _standardInputPipe = [NSOutputStream outputStreamToFileAtPath:[self inPipePath] append:YES];
87  _standardOutputPipe = [NSInputStream inputStreamWithFileAtPath:[self outPipePath]];
88  _standardErrorPipe = [NSInputStream inputStreamWithFileAtPath:[self errorPipePath]];
89 
90  [[self standardInputPipe] setDelegate:self];
91  [[self standardOutputPipe] setDelegate:self];
92  [[self standardErrorPipe] setDelegate:self];
93 
94  [[self standardOutputPipe] scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
95  [[self standardErrorPipe] scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
96 
97  [[self standardInputPipe] open];
98  [[self standardOutputPipe] open];
99  [[self standardErrorPipe] open];
100 
101  [[self relayDelegate] didConnect];
102 }
103 
104 - (void)disconnect
105 {
106  [[self standardOutputPipe] close];
107  [[self standardErrorPipe] close];
108  [[self standardInputPipe] close];
109  [[self relayDelegate] didDisconnect];
110 }
111 
112 - (void)createFIFOs
113 {
114  mkfifo([[self inPipePath] UTF8String], 0666);
115  mkfifo([[self outPipePath] UTF8String], 0666);
116  mkfifo([[self errorPipePath] UTF8String], 0666);
117 }
118 
119 - (void)destroyFIFOs
120 {
121  unlink([[self inPipePath] UTF8String]);
122  unlink([[self outPipePath] UTF8String]);
123  unlink([[self errorPipePath] UTF8String]);
124 }
125 
126 - (void) relayStream:(NSInputStream *)stream
127 {
128  uint8_t bytes[1024];
129  NSInteger bytesRead = [stream read:bytes maxLength:1024];
130  NSData *data = [NSData dataWithBytes:bytes length:bytesRead];
131 
132  if (stream == [self standardOutputPipe])
133  [[self relayDelegate] didReceiveStdoutData:data];
134  else
135  [[self relayDelegate] didReceiveStderrData:data];
136 }
137 
138 - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
139 {
140  switch (eventCode) {
141  case NSStreamEventNone:
142  break;
143  case NSStreamEventHasBytesAvailable:
144  [self relayStream:(NSInputStream *)aStream];
145  case NSStreamEventHasSpaceAvailable:
146  break;
147  case NSStreamEventOpenCompleted:
148  break;
149  case NSStreamEventEndEncountered:
150  [[self relayDelegate] didCrashWithMessage:nil];
151  break;
152  case NSStreamEventErrorOccurred:
153  [[self relayDelegate] didCrashWithMessage:[[aStream streamError] description]];
154  break;
155  }
156 }
157 
158 @end
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelay.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef LTRelay_h
27 #define LTRelay_h
28 
29 #import <Foundation/Foundation.h>
30 
31 @protocol LTRelayDelegate <NSObject>
32 - (void)didConnect;
33 - (void)didDisconnect;
34 - (void)didCrashWithMessage:(NSString *)message;
35 - (void)didReceiveStdoutData:(NSData *)data;
36 - (void)didReceiveStderrData:(NSData *)data;
37 @end
38 
39 @protocol LTRelay <NSObject, NSStreamDelegate>
40 - (void)setup;
41 - (void)tearDown;
42 - (void)connect;
43 - (void)disconnect;
44 @property (weak) id<LTRelayDelegate> relayDelegate;
45 @property (readonly, strong) NSOutputStream *outputStream;
46 @end
47 
48 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef LTRelayController_h
26 #define LTRelayController_h
27 
28 #import "LTRelay.h"
29 
30 #import <Foundation/Foundation.h>
31 
32 @class SimDevice;
33 
34 @interface LTRelayController : NSObject <LTRelayDelegate>
35 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments;
36 - (void)start;
37 - (void)finish;
38 @end
39 
40 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "LTRelayController.h"
27 
28 #import "CoreSimulatorSPI.h"
29 #import "LTPipeRelay.h"
30 #import <AppKit/AppKit.h>
31 #import <crt_externs.h>
32 
33 @interface LTRelayController ()
34 @property (readonly, strong) dispatch_source_t standardInputDispatchSource;
35 @property (readonly, strong) NSFileHandle *standardOutput;
36 @property (readonly, strong) NSFileHandle *standardError;
37 @property (readonly, strong) NSString *ipcIdentifier;
38 @property (readonly, strong) NSString *appBundleIdentifier;
39 @property (readonly, strong) NSString *appPath;
40 @property (readonly, strong) NSUUID *deviceUDID;
41 @property (readonly, strong) NSArray *dumpToolArguments;
42 @property (readonly, strong) NSString *productDir;
43 @property (strong) SimDevice *device;
44 @property (strong) id<LTRelay> relay;
45 @property pid_t pid;
46 @property (strong) dispatch_source_t appDispatchSource;
47 @end
48 
49 @implementation LTRelayController
50 
51 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments
52 {
53  if ((self = [super init])) {
54  _device = device;
55  _productDir = productDir;
56  _appPath = appPath;
57  _appBundleIdentifier = [[NSBundle bundleWithPath:appPath] bundleIdentifier];
58  _deviceUDID = udid;
59  _dumpToolArguments = arguments;
60  _standardInputDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, STDIN_FILENO, 0, dispatch_get_main_queue());
61  _standardOutput = [NSFileHandle fileHandleWithStandardOutput];
62  _standardError = [NSFileHandle fileHandleWithStandardError];
63 
64  dispatch_source_set_event_handler(_standardInputDispatchSource, ^{
65  uint8_t buffer[1024];
66  ssize_t len = read(STDIN_FILENO, buffer, sizeof(buffer));
67  if (len > 0) {
68  @try {
69  [[[self relay] outputStream] write:buffer maxLength:len];
70  } @catch (NSException *e) {
71  // Broken pipe - the dump tool crashed. Time to die.
72  [self didCrashWithMessage:nil];
73  }
74  } else {
75  // EOF Received on the relay's standard input.
76  [self finish];
77  }
78  });
79 
80  _relay = [[LTPipeRelay alloc] initWithPrefix:[@"/tmp" stringByAppendingPathComponent:self.ipcIdentifier]];
81  [_relay setRelayDelegate:self];
82  }
83  return self;
84 }
85 
86 - (NSString *)ipcIdentifier
87 {
88  return [NSString stringWithFormat:@"%@-%@", self.appBundleIdentifier, self.deviceUDID.UUIDString];
89 }
90 
91 - (NSString *)processName
92 {
93  return [self.appBundleIdentifier componentsSeparatedByString:@"."].lastObject;
94 }
95 
96 - (void)didReceiveStdoutData:(NSData *)data
97 {
98  @try {
99  [[self standardOutput] writeData:data];
100  } @catch (NSException *exception) {
101  // NSFileHandleOperationException
102  // Broken pipe - the test harness stopped listening to us,
103  // probably because we timed out or a run was canceled.
104  exit(EXIT_FAILURE);
105  }
106 }
107 
108 - (void)didReceiveStderrData:(NSData *)data
109 {
110  @try {
111  [[self standardError] writeData:data];
112  } @catch (NSException *exception) {
113  // NSFileHandleOperationException
114  // Broken pipe - the test harness stopped listening to us,
115  // probably because we timed out or a run was canceled.
116  exit(EXIT_FAILURE);
117  }
118 }
119 
120 - (void)didDisconnect
121 {
122  dispatch_suspend([self standardInputDispatchSource]);
123 }
124 
125 - (void)didConnect
126 {
127  dispatch_resume([self standardInputDispatchSource]);
128 }
129 
130 - (void)didCrashWithMessage:(NSString *)message
131 {
132  [[self relay] disconnect];
133  NSString *crashMessage = [NSString stringWithFormat:@"\n#CRASHED - %@ (pid %d)\n", [self processName], [self pid]];
134 
135  if (message)
136  crashMessage = [crashMessage stringByAppendingFormat:@"%@\n", message];
137 
138  [[self standardError] writeData:[crashMessage dataUsingEncoding:NSUTF8StringEncoding]];
139  [[self standardError] closeFile];
140  [[self standardOutput] closeFile];
141  exit(EXIT_FAILURE);
142 }
143 
144 - (void)installApp
145 {
146  NSDictionary *installOptions = @{
147  (NSString *)kCFBundleIdentifierKey: self.appBundleIdentifier,
148  };
149 
150  NSError *error = nil;
151  BOOL installed = [self.device installApplication:[NSURL fileURLWithPath:self.appPath] withOptions:installOptions error:&error];
152  if (!installed) {
153  NSLog(@"Couldn't install %@: %@", self.appPath, error.description);
154  exit(EXIT_FAILURE);
155  }
156 }
157 
158 - (void)killApp
159 {
160  dispatch_source_t dispatch = [self appDispatchSource];
161 
162  if (dispatch)
163  dispatch_source_cancel(dispatch);
164 
165  if ([self pid] > 1) {
166  kill(self.pid, SIGKILL);
167  [self setPid:-1];
168  }
169  [self setAppDispatchSource:nil];
170 }
171 
172 - (NSDictionary *)_environmentVariables
173 {
174  static NSDictionary *environmentVariables;
175  static dispatch_once_t once;
176 
177  dispatch_once(&once, ^{
178  NSString *productDirectory = [self productDir];
179 
180  NSMutableDictionary *dictionary = [@{
181  @"IPC_IDENTIFIER": self.ipcIdentifier,
182  @"DYLD_FRAMEWORK_PATH": productDirectory,
183  @"__XPC_DYLD_FRAMEWORK_PATH": productDirectory,
184  @"DYLD_LIBRARY_PATH": productDirectory,
185  @"__XPC_DYLD_LIBRARY_PATH": productDirectory,
186  } mutableCopy];
187 
188  for (NSString *keyName in @[@"DYLD_INSERT_LIBRARIES", @"MallocStackLogging", @"LOCAL_RESOURCE_ROOT", @"DUMPRENDERTREE_TEMP"]) {
189  const char* value = getenv([keyName UTF8String]);
190  if (value && strlen(value)) {
191  NSString *nsValue = [NSString stringWithUTF8String:value];
192  [dictionary setObject:nsValue forKey:keyName];
193  [dictionary setObject:nsValue forKey:[@"__XPC_" stringByAppendingString:keyName]];
194  }
195  }
196 
197  for (char** envp = *_NSGetEnviron(); *envp; envp++) {
198  const char* env = *envp;
199  if (!strncmp("JSC_", env, 4) || !strncmp("__XPC_JSC_", env, 10)) {
200  const char* equal = strchr(env, '=');
201  if (!equal) {
202  NSLog(@"Missing '=' in env var '%s'", env);
203  continue;
204  }
205 
206  static const size_t maxKeyLength = 256;
207  size_t keyLength = equal - env;
208  if (keyLength >= maxKeyLength) {
209  NSLog(@"Env var '%s' is too long", env);
210  continue;
211  }
212 
213  char key[maxKeyLength];
214  strncpy(key, env, keyLength);
215  key[keyLength] = '\0';
216  const char* value = equal + 1;
217 
218  NSString *nsKey = [NSString stringWithUTF8String:key];
219  NSString *nsValue = [NSString stringWithUTF8String:value];
220  [dictionary setObject:nsValue forKey:nsKey];
221  }
222  }
223 
224  environmentVariables = [dictionary copy];
225  });
226 
227  return environmentVariables;
228 }
229 
230 - (void)launchApp
231 {
232  NSDictionary *launchOptions = @{
233  kSimDeviceLaunchApplicationEnvironment: [self _environmentVariables],
234  kSimDeviceLaunchApplicationArguments: [self dumpToolArguments],
235  };
236 
237  NSError *error;
238  pid_t pid = [self.device launchApplicationWithID:self.appBundleIdentifier options:launchOptions error:&error];
239 
240  if (pid < 0) {
241  NSLog(@"Couldn't launch %@: %@", self.appBundleIdentifier, error.description);
242  exit(EXIT_FAILURE);
243  }
244 
245  [self setPid:pid];
246 
247  dispatch_queue_t queue = dispatch_get_main_queue();
248  dispatch_source_t simulatorAppExitDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, [self pid], DISPATCH_PROC_EXIT, queue);
249  [self setAppDispatchSource:simulatorAppExitDispatchSource];
250  dispatch_source_set_event_handler(simulatorAppExitDispatchSource, ^{
251  dispatch_source_cancel(simulatorAppExitDispatchSource);
252  [self didCrashWithMessage:nil];
253  });
254  dispatch_resume(simulatorAppExitDispatchSource);
255 }
256 
257 - (void)start
258 {
259  [self installApp];
260  [[self relay] setup];
261  [self launchApp];
262  [[self relay] connect];
263 }
264 
265 - (void)finish
266 {
267  [[self relay] disconnect];
268  [self killApp];
269  exit(EXIT_SUCCESS);
270 }
271 
272 @end
211961

Tools/LayoutTestRelay/LayoutTestRelay/main.m

1 /*
2  * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "CoreSimulatorSPI.h"
27 #import "LTRelayController.h"
28 #import <Foundation/Foundation.h>
29 
30 static LTRelayController *relayController;
31 
32 void usage()
33 {
34  NSString *helpText = @"LayoutTestRelay: run a dump tool in the simulator. Not for direct consumption.\n"
35  "Usage: LayoutTestRelay [-h] [options] -- [dump tool arguments]\n"
36  "Required options:\n"
37  " -udid <identifier> Simulator device identifier\n"
38  " -app <app_path> Path to the built iOS .app bundle directory.\n"
39  " -productDir <dir> /path/to/WebKitBuild/{configuration}-{short platform}.\n";
40 
41  fprintf(stderr, "%s\n", [helpText UTF8String]);
42 }
43 
44 NSString *getRequiredStringArgument(NSString *parameter)
45 {
46  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
47  NSString *argument = [defaults stringForKey:parameter];
48 
49  if (!argument) {
50  NSLog(@"-%@ is required.", parameter);
51  usage();
52  exit(EXIT_FAILURE);
53  }
54  return argument;
55 }
56 
57 NSArray *getDumpToolArguments()
58 {
59  NSMutableArray *dumpToolArguments = [[NSMutableArray alloc] init];
60  NSArray *processArgs = [[NSProcessInfo processInfo] arguments];
61  BOOL appending = NO;
62  for (NSString *arg in processArgs) {
63  if ([arg isEqualToString:@"--"]) {
64  appending = YES;
65  continue;
66  }
67  if (appending)
68  [dumpToolArguments addObject:arg];
69  }
70  return dumpToolArguments;
71 }
72 
73 void finish()
74 {
75  [relayController finish];
76 }
77 
78 void receivedSignal(int signal)
79 {
80  exit(EXIT_SUCCESS);
81 }
82 
83 int main(int argc, const char * argv[])
84 {
85  @autoreleasepool {
86  NSArray *helpArguments = @[@"-h", @"--help"];
87  for (NSString *helpArgument in helpArguments) {
88  if ([[[NSProcessInfo processInfo] arguments] indexOfObject:helpArgument] != NSNotFound) {
89  usage();
90  exit(EXIT_FAILURE);
91  }
92  }
93 
94 #if USE_SIM_SERVICE_CONTEXT
95  NSString *developerDirectory = getRequiredStringArgument(@"developerDir");
96 #endif
97  NSUUID *udid = [[NSUUID alloc] initWithUUIDString:getRequiredStringArgument(@"udid")];
98  NSString *appPath = getRequiredStringArgument(@"app");
99  NSString *productDirectory = getRequiredStringArgument(@"productDir");
100  NSArray *dumpToolArguments = getDumpToolArguments();
101 
102 #if USE_SIM_SERVICE_CONTEXT
103  NSError *error;
104  SimServiceContext *serviceContext = [SimServiceContext sharedServiceContextForDeveloperDir:developerDirectory error:&error];
105  if (!serviceContext) {
106  NSLog(@"Device context couldn't be found: %@", error);
107  exit(EXIT_FAILURE);
108  }
109  SimDeviceSet *deviceSet = [serviceContext defaultDeviceSetWithError:nil];
110  if (!deviceSet) {
111  NSLog(@"Default device set couldn't be found: %@", error);
112  exit(EXIT_FAILURE);
113  }
114  SimDevice *device = [deviceSet.devicesByUDID objectForKey:udid];
115 #else
116  SimDevice *device = [SimDeviceSet.defaultSet.devicesByUDID objectForKey:udid];
117 #endif
118  if (!device) {
119  NSLog(@"Device %@ couldn't be found", udid);
120  exit(EXIT_FAILURE);
121  }
122 
123  relayController = [[LTRelayController alloc] initWithDevice:device productDir:productDirectory appPath:appPath deviceUDID:udid dumpToolArguments:dumpToolArguments];
124  [relayController start];
125 
126  atexit(finish);
127  signal(SIGINT, receivedSignal);
128  signal(SIGTERM, receivedSignal);
129 
130  [[NSRunLoop mainRunLoop] run];
131  }
132  return 0;
133 }
211961

Tools/LayoutTestRelay/LayoutTestRelay.xcodeproj/project.pbxproj

1 // !$*UTF8*$!
2 {
3  archiveVersion = 1;
4  classes = {
5  };
6  objectVersion = 46;
7  objects = {
8 
9 /* Begin PBXBuildFile section */
10  2E8D3EF819881D43004F6CC2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3EF719881D43004F6CC2 /* main.m */; };
11  2E8D3F0219881FD0004F6CC2 /* LTPipeRelay.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */; };
12  2E8D3F0619882406004F6CC2 /* LTRelayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3F0519882406004F6CC2 /* LTRelayController.m */; };
13 /* End PBXBuildFile section */
14 
15 /* Begin PBXCopyFilesBuildPhase section */
16  2E8D3EF219881D43004F6CC2 /* CopyFiles */ = {
17  isa = PBXCopyFilesBuildPhase;
18  buildActionMask = 2147483647;
19  dstPath = /usr/share/man/man1/;
20  dstSubfolderSpec = 0;
21  files = (
22  );
23  runOnlyForDeploymentPostprocessing = 1;
24  };
25 /* End PBXCopyFilesBuildPhase section */
26 
27 /* Begin PBXFileReference section */
28  2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LayoutTestRelay; sourceTree = BUILT_PRODUCTS_DIR; };
29  2E8D3EF719881D43004F6CC2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
30  2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = DebugRelease.xcconfig; path = Configurations/DebugRelease.xcconfig; sourceTree = "<group>"; };
31  2E8D3EFF19881E25004F6CC2 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Base.xcconfig; path = Configurations/Base.xcconfig; sourceTree = "<group>"; };
32  2E8D3F0019881F29004F6CC2 /* LTRelay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTRelay.h; sourceTree = "<group>"; };
33  2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTPipeRelay.m; sourceTree = "<group>"; };
34  2E8D3F0319881FE2004F6CC2 /* LTPipeRelay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTPipeRelay.h; sourceTree = "<group>"; };
35  2E8D3F0419882406004F6CC2 /* LTRelayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LTRelayController.h; sourceTree = "<group>"; };
36  2E8D3F0519882406004F6CC2 /* LTRelayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTRelayController.m; sourceTree = "<group>"; };
37  CE1FBC151B290E79000136F5 /* CoreSimulatorSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreSimulatorSPI.h; sourceTree = "<group>"; };
38 /* End PBXFileReference section */
39 
40 /* Begin PBXFrameworksBuildPhase section */
41  2E8D3EF119881D43004F6CC2 /* Frameworks */ = {
42  isa = PBXFrameworksBuildPhase;
43  buildActionMask = 2147483647;
44  files = (
45  );
46  runOnlyForDeploymentPostprocessing = 0;
47  };
48 /* End PBXFrameworksBuildPhase section */
49 
50 /* Begin PBXGroup section */
51  2E8D3EEB19881D43004F6CC2 = {
52  isa = PBXGroup;
53  children = (
54  2E8D3EFF19881E25004F6CC2 /* Base.xcconfig */,
55  2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */,
56  2E8D3EF619881D43004F6CC2 /* LayoutTestRelay */,
57  2E8D3EF519881D43004F6CC2 /* Products */,
58  );
59  sourceTree = "<group>";
60  };
61  2E8D3EF519881D43004F6CC2 /* Products */ = {
62  isa = PBXGroup;
63  children = (
64  2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */,
65  );
66  name = Products;
67  sourceTree = "<group>";
68  };
69  2E8D3EF619881D43004F6CC2 /* LayoutTestRelay */ = {
70  isa = PBXGroup;
71  children = (
72  2E8D3EF719881D43004F6CC2 /* main.m */,
73  CE1FBC151B290E79000136F5 /* CoreSimulatorSPI.h */,
74  2E8D3F0019881F29004F6CC2 /* LTRelay.h */,
75  2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */,
76  2E8D3F0319881FE2004F6CC2 /* LTPipeRelay.h */,
77  2E8D3F0419882406004F6CC2 /* LTRelayController.h */,
78  2E8D3F0519882406004F6CC2 /* LTRelayController.m */,
79  );
80  path = LayoutTestRelay;
81  sourceTree = "<group>";
82  };
83 /* End PBXGroup section */
84 
85 /* Begin PBXNativeTarget section */
86  2E8D3EF319881D43004F6CC2 /* LayoutTestRelay */ = {
87  isa = PBXNativeTarget;
88  buildConfigurationList = 2E8D3EFB19881D43004F6CC2 /* Build configuration list for PBXNativeTarget "LayoutTestRelay" */;
89  buildPhases = (
90  2E8D3EF019881D43004F6CC2 /* Sources */,
91  2E8D3EF119881D43004F6CC2 /* Frameworks */,
92  2E8D3EF219881D43004F6CC2 /* CopyFiles */,
93  );
94  buildRules = (
95  );
96  dependencies = (
97  );
98  name = LayoutTestRelay;
99  productName = LayoutTestRelay;
100  productReference = 2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */;
101  productType = "com.apple.product-type.tool";
102  };
103 /* End PBXNativeTarget section */
104 
105 /* Begin PBXProject section */
106  2E8D3EEC19881D43004F6CC2 /* Project object */ = {
107  isa = PBXProject;
108  attributes = {
109  LastUpgradeCheck = 0600;
110  ORGANIZATIONNAME = "Apple, Inc.";
111  TargetAttributes = {
112  2E8D3EF319881D43004F6CC2 = {
113  CreatedOnToolsVersion = 6.0;
114  };
115  };
116  };
117  buildConfigurationList = 2E8D3EEF19881D43004F6CC2 /* Build configuration list for PBXProject "LayoutTestRelay" */;
118  compatibilityVersion = "Xcode 3.2";
119  developmentRegion = English;
120  hasScannedForEncodings = 0;
121  knownRegions = (
122  en,
123  );
124  mainGroup = 2E8D3EEB19881D43004F6CC2;
125  productRefGroup = 2E8D3EF519881D43004F6CC2 /* Products */;
126  projectDirPath = "";
127  projectRoot = "";
128  targets = (
129  2E8D3EF319881D43004F6CC2 /* LayoutTestRelay */,
130  );
131  };
132 /* End PBXProject section */
133 
134 /* Begin PBXSourcesBuildPhase section */
135  2E8D3EF019881D43004F6CC2 /* Sources */ = {
136  isa = PBXSourcesBuildPhase;
137  buildActionMask = 2147483647;
138  files = (
139  2E8D3F0619882406004F6CC2 /* LTRelayController.m in Sources */,
140  2E8D3EF819881D43004F6CC2 /* main.m in Sources */,
141  2E8D3F0219881FD0004F6CC2 /* LTPipeRelay.m in Sources */,
142  );
143  runOnlyForDeploymentPostprocessing = 0;
144  };
145 /* End PBXSourcesBuildPhase section */
146 
147 /* Begin XCBuildConfiguration section */
148  2E8D3EF919881D43004F6CC2 /* Debug */ = {
149  isa = XCBuildConfiguration;
150  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
151  buildSettings = {
152  };
153  name = Debug;
154  };
155  2E8D3EFA19881D43004F6CC2 /* Release */ = {
156  isa = XCBuildConfiguration;
157  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
158  buildSettings = {
159  };
160  name = Release;
161  };
162  2E8D3EFC19881D43004F6CC2 /* Debug */ = {
163  isa = XCBuildConfiguration;
164  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
165  buildSettings = {
166  PRODUCT_NAME = "$(TARGET_NAME)";
167  };
168  name = Debug;
169  };
170  2E8D3EFD19881D43004F6CC2 /* Release */ = {
171  isa = XCBuildConfiguration;
172  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
173  buildSettings = {
174  PRODUCT_NAME = "$(TARGET_NAME)";
175  };
176  name = Release;
177  };
178 /* End XCBuildConfiguration section */
179 
180 /* Begin XCConfigurationList section */
181  2E8D3EEF19881D43004F6CC2 /* Build configuration list for PBXProject "LayoutTestRelay" */ = {
182  isa = XCConfigurationList;
183  buildConfigurations = (
184  2E8D3EF919881D43004F6CC2 /* Debug */,
185  2E8D3EFA19881D43004F6CC2 /* Release */,
186  );
187  defaultConfigurationIsVisible = 0;
188  defaultConfigurationName = Release;
189  };
190  2E8D3EFB19881D43004F6CC2 /* Build configuration list for PBXNativeTarget "LayoutTestRelay" */ = {
191  isa = XCConfigurationList;
192  buildConfigurations = (
193  2E8D3EFC19881D43004F6CC2 /* Debug */,
194  2E8D3EFD19881D43004F6CC2 /* Release */,
195  );
196  defaultConfigurationIsVisible = 0;
197  defaultConfigurationName = Release;
198  };
199 /* End XCConfigurationList section */
200  };
201  rootObject = 2E8D3EEC19881D43004F6CC2 /* Project object */;
202 }
211961

Tools/LayoutTestRelay/LayoutTestRelay.xcodeproj

Deleted: svn:ignore
## -1,2 +0,0 ##
project.xcworkspace
xcuserdata
211961

Tools/LayoutTestRelay/Makefile

1 SCRIPTS_PATH = ../Scripts
2 
3 OVERRIDE_ARCHS = default
4 OVERRIDE_SDKROOT = default
5 
6 include ../../Makefile.shared
211961

Tools/LayoutTestRelay/Configurations/Base.xcconfig

1 // Copyright (C) 2014 Apple Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions
5 // are met:
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 //
12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 #include "../../../../Internal/Configurations/HaveInternalSDK.xcconfig"
25 
26 USE_INTERNAL_SDK = $(USE_INTERNAL_SDK_$(CONFIGURATION));
27 USE_INTERNAL_SDK_Production = YES;
28 USE_INTERNAL_SDK_Debug = $(HAVE_INTERNAL_SDK);
29 USE_INTERNAL_SDK_Release = $(HAVE_INTERNAL_SDK);
30 
31 CLANG_CXX_LANGUAGE_STANDARD = gnu++0x;
32 CLANG_ENABLE_OBJC_ARC = YES;
33 CLANG_WARN_CXX0X_EXTENSIONS = NO;
34 HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(SRCROOT)/../../Source/JavaScriptCore/icu $(NEXT_ROOT)/usr/local/include/WebCoreTestSupport;
35 GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) ENABLE_DASHBOARD_SUPPORT;
36 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym;
37 PREBINDING = NO
38 GCC_C_LANGUAGE_STANDARD = gnu99
39 GCC_ENABLE_CPP_EXCEPTIONS = NO;
40 GCC_ENABLE_CPP_RTTI = NO;
41 GCC_PRECOMPILE_PREFIX_HEADER = YES
42 GCC_TREAT_WARNINGS_AS_ERRORS = YES
43 GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
44 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO
45 GCC_WARN_UNUSED_FUNCTION = YES
46 GCC_WARN_UNUSED_VARIABLE = YES
47 GCC_WARN_64_TO_32_BIT_CONVERSION[arch=x86_64] = NO;
48 WARNING_CFLAGS = -Wall -W -Wno-unused-parameter -Wundef
49 
50 DEBUG_DEFINES_debug = ;
51 DEBUG_DEFINES_normal = NDEBUG;
52 DEBUG_DEFINES = $(DEBUG_DEFINES_$(CURRENT_VARIANT));
53 
54 TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
55 TARGET_MAC_OS_X_VERSION_MAJOR_10 = 101000;
56 TARGET_MAC_OS_X_VERSION_MAJOR_11 = 101100;
57 TARGET_MAC_OS_X_VERSION_MAJOR_12 = 101200;
58 TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;
59 
60 SDKROOT = macosx.internal;
61 
62 SUPPORTED_PLATFORMS = macosx;
63 
64 TOOLCHAINS = default;
65 
66 OTHER_CFLAGS = $(ASAN_OTHER_CFLAGS);
67 OTHER_CPLUSPLUSFLAGS = $(ASAN_OTHER_CPLUSPLUSFLAGS);
68 OTHER_LDFLAGS = $(ASAN_OTHER_LDFLAGS);
211961

Tools/LayoutTestRelay/Configurations/DebugRelease.xcconfig

1 // Copyright (C) 2014 Apple Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions
5 // are met:
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 //
12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 #include "Base.xcconfig"
25 
26 ARCHS = $(ARCHS_STANDARD_64_BIT);
27 
28 TARGET_MAC_OS_X_VERSION_MAJOR = $(MAC_OS_X_VERSION_MAJOR);
29 
30 MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_$(TARGET_MAC_OS_X_VERSION_MAJOR))
31 MACOSX_DEPLOYMENT_TARGET_101000 = 10.10;
32 MACOSX_DEPLOYMENT_TARGET_101100 = 10.11;
33 MACOSX_DEPLOYMENT_TARGET_101200 = 10.12;
34 MACOSX_DEPLOYMENT_TARGET_101300 = 10.13;
35 
36 FRAMEWORK_SEARCH_PATHS = $(DEVELOPER_DIR)/Library/PrivateFrameworks;
37 LD_RUNPATH_SEARCH_PATHS = $(DEVELOPER_DIR)/Library/PrivateFrameworks;
38 OTHER_LDFLAGS = -framework CoreSimulator -framework AppKit;
39 
40 SDKROOT = $(SDKROOT_macosx_$(USE_INTERNAL_SDK));
41 SDKROOT_macosx_ = macosx;
42 SDKROOT_macosx_YES = macosx.internal;
211961

Tools/LayoutTestRelay/LayoutTestRelay.xcodeproj/project.pbxproj

1 // !$*UTF8*$!
2 {
3  archiveVersion = 1;
4  classes = {
5  };
6  objectVersion = 46;
7  objects = {
8 
9 /* Begin PBXBuildFile section */
10  2E8D3EF819881D43004F6CC2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3EF719881D43004F6CC2 /* main.m */; };
11  2E8D3F0219881FD0004F6CC2 /* LTPipeRelay.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */; };
12  2E8D3F0619882406004F6CC2 /* LTRelayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8D3F0519882406004F6CC2 /* LTRelayController.m */; };
13 /* End PBXBuildFile section */
14 
15 /* Begin PBXCopyFilesBuildPhase section */
16  2E8D3EF219881D43004F6CC2 /* CopyFiles */ = {
17  isa = PBXCopyFilesBuildPhase;
18  buildActionMask = 2147483647;
19  dstPath = /usr/share/man/man1/;
20  dstSubfolderSpec = 0;
21  files = (
22  );
23  runOnlyForDeploymentPostprocessing = 1;
24  };
25 /* End PBXCopyFilesBuildPhase section */
26 
27 /* Begin PBXFileReference section */
28  2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LayoutTestRelay; sourceTree = BUILT_PRODUCTS_DIR; };
29  2E8D3EF719881D43004F6CC2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
30  2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = DebugRelease.xcconfig; path = Configurations/DebugRelease.xcconfig; sourceTree = "<group>"; };
31  2E8D3EFF19881E25004F6CC2 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Base.xcconfig; path = Configurations/Base.xcconfig; sourceTree = "<group>"; };
32  2E8D3F0019881F29004F6CC2 /* LTRelay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTRelay.h; sourceTree = "<group>"; };
33  2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTPipeRelay.m; sourceTree = "<group>"; };
34  2E8D3F0319881FE2004F6CC2 /* LTPipeRelay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTPipeRelay.h; sourceTree = "<group>"; };
35  2E8D3F0419882406004F6CC2 /* LTRelayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LTRelayController.h; sourceTree = "<group>"; };
36  2E8D3F0519882406004F6CC2 /* LTRelayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTRelayController.m; sourceTree = "<group>"; };
37  CE1FBC151B290E79000136F5 /* CoreSimulatorSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreSimulatorSPI.h; sourceTree = "<group>"; };
38 /* End PBXFileReference section */
39 
40 /* Begin PBXFrameworksBuildPhase section */
41  2E8D3EF119881D43004F6CC2 /* Frameworks */ = {
42  isa = PBXFrameworksBuildPhase;
43  buildActionMask = 2147483647;
44  files = (
45  );
46  runOnlyForDeploymentPostprocessing = 0;
47  };
48 /* End PBXFrameworksBuildPhase section */
49 
50 /* Begin PBXGroup section */
51  2E8D3EEB19881D43004F6CC2 = {
52  isa = PBXGroup;
53  children = (
54  2E8D3EFF19881E25004F6CC2 /* Base.xcconfig */,
55  2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */,
56  2E8D3EF619881D43004F6CC2 /* LayoutTestRelay */,
57  2E8D3EF519881D43004F6CC2 /* Products */,
58  );
59  sourceTree = "<group>";
60  };
61  2E8D3EF519881D43004F6CC2 /* Products */ = {
62  isa = PBXGroup;
63  children = (
64  2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */,
65  );
66  name = Products;
67  sourceTree = "<group>";
68  };
69  2E8D3EF619881D43004F6CC2 /* LayoutTestRelay */ = {
70  isa = PBXGroup;
71  children = (
72  2E8D3EF719881D43004F6CC2 /* main.m */,
73  CE1FBC151B290E79000136F5 /* CoreSimulatorSPI.h */,
74  2E8D3F0019881F29004F6CC2 /* LTRelay.h */,
75  2E8D3F0119881FD0004F6CC2 /* LTPipeRelay.m */,
76  2E8D3F0319881FE2004F6CC2 /* LTPipeRelay.h */,
77  2E8D3F0419882406004F6CC2 /* LTRelayController.h */,
78  2E8D3F0519882406004F6CC2 /* LTRelayController.m */,
79  );
80  path = LayoutTestRelay;
81  sourceTree = "<group>";
82  };
83 /* End PBXGroup section */
84 
85 /* Begin PBXNativeTarget section */
86  2E8D3EF319881D43004F6CC2 /* LayoutTestRelay */ = {
87  isa = PBXNativeTarget;
88  buildConfigurationList = 2E8D3EFB19881D43004F6CC2 /* Build configuration list for PBXNativeTarget "LayoutTestRelay" */;
89  buildPhases = (
90  2E8D3EF019881D43004F6CC2 /* Sources */,
91  2E8D3EF119881D43004F6CC2 /* Frameworks */,
92  2E8D3EF219881D43004F6CC2 /* CopyFiles */,
93  );
94  buildRules = (
95  );
96  dependencies = (
97  );
98  name = LayoutTestRelay;
99  productName = LayoutTestRelay;
100  productReference = 2E8D3EF419881D43004F6CC2 /* LayoutTestRelay */;
101  productType = "com.apple.product-type.tool";
102  };
103 /* End PBXNativeTarget section */
104 
105 /* Begin PBXProject section */
106  2E8D3EEC19881D43004F6CC2 /* Project object */ = {
107  isa = PBXProject;
108  attributes = {
109  LastUpgradeCheck = 0600;
110  ORGANIZATIONNAME = "Apple, Inc.";
111  TargetAttributes = {
112  2E8D3EF319881D43004F6CC2 = {
113  CreatedOnToolsVersion = 6.0;
114  };
115  };
116  };
117  buildConfigurationList = 2E8D3EEF19881D43004F6CC2 /* Build configuration list for PBXProject "LayoutTestRelay" */;
118  compatibilityVersion = "Xcode 3.2";
119  developmentRegion = English;
120  hasScannedForEncodings = 0;
121  knownRegions = (
122  en,
123  );
124  mainGroup = 2E8D3EEB19881D43004F6CC2;
125  productRefGroup = 2E8D3EF519881D43004F6CC2 /* Products */;
126  projectDirPath = "";
127  projectRoot = "";
128  targets = (
129  2E8D3EF319881D43004F6CC2 /* LayoutTestRelay */,
130  );
131  };
132 /* End PBXProject section */
133 
134 /* Begin PBXSourcesBuildPhase section */
135  2E8D3EF019881D43004F6CC2 /* Sources */ = {
136  isa = PBXSourcesBuildPhase;
137  buildActionMask = 2147483647;
138  files = (
139  2E8D3F0619882406004F6CC2 /* LTRelayController.m in Sources */,
140  2E8D3EF819881D43004F6CC2 /* main.m in Sources */,
141  2E8D3F0219881FD0004F6CC2 /* LTPipeRelay.m in Sources */,
142  );
143  runOnlyForDeploymentPostprocessing = 0;
144  };
145 /* End PBXSourcesBuildPhase section */
146 
147 /* Begin XCBuildConfiguration section */
148  2E8D3EF919881D43004F6CC2 /* Debug */ = {
149  isa = XCBuildConfiguration;
150  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
151  buildSettings = {
152  };
153  name = Debug;
154  };
155  2E8D3EFA19881D43004F6CC2 /* Release */ = {
156  isa = XCBuildConfiguration;
157  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
158  buildSettings = {
159  };
160  name = Release;
161  };
162  2E8D3EFC19881D43004F6CC2 /* Debug */ = {
163  isa = XCBuildConfiguration;
164  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
165  buildSettings = {
166  PRODUCT_NAME = "$(TARGET_NAME)";
167  };
168  name = Debug;
169  };
170  2E8D3EFD19881D43004F6CC2 /* Release */ = {
171  isa = XCBuildConfiguration;
172  baseConfigurationReference = 2E8D3EFE19881E13004F6CC2 /* DebugRelease.xcconfig */;
173  buildSettings = {
174  PRODUCT_NAME = "$(TARGET_NAME)";
175  };
176  name = Release;
177  };
178 /* End XCBuildConfiguration section */
179 
180 /* Begin XCConfigurationList section */
181  2E8D3EEF19881D43004F6CC2 /* Build configuration list for PBXProject "LayoutTestRelay" */ = {
182  isa = XCConfigurationList;
183  buildConfigurations = (
184  2E8D3EF919881D43004F6CC2 /* Debug */,
185  2E8D3EFA19881D43004F6CC2 /* Release */,
186  );
187  defaultConfigurationIsVisible = 0;
188  defaultConfigurationName = Release;
189  };
190  2E8D3EFB19881D43004F6CC2 /* Build configuration list for PBXNativeTarget "LayoutTestRelay" */ = {
191  isa = XCConfigurationList;
192  buildConfigurations = (
193  2E8D3EFC19881D43004F6CC2 /* Debug */,
194  2E8D3EFD19881D43004F6CC2 /* Release */,
195  );
196  defaultConfigurationIsVisible = 0;
197  defaultConfigurationName = Release;
198  };
199 /* End XCConfigurationList section */
200  };
201  rootObject = 2E8D3EEC19881D43004F6CC2 /* Project object */;
202 }
211961

Tools/LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h

1 /*
2  * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #if __has_include(<CoreSimulator/CoreSimulator.h>)
27 
28 /* FIXME: Remove the below #define once we require Xcode 7.3 with iOS 9.3 SDK or newer. */
29 #define __coresim_unavailable_msg(msg)
30 #import <CoreSimulator/CoreSimulator.h>
31 
32 /* FIXME: Always use SimServiceContext once we require Xcode 7.3 with iOS 9.3 SDK or newer. */
33 #define USE_SIM_SERVICE_CONTEXT defined(CORESIM_API_MAX_ALLOWED)
34 
35 #else
36 
37 #import <Foundation/Foundation.h>
38 
39 #define USE_SIM_SERVICE_CONTEXT 1
40 
41 #define kSimDeviceLaunchApplicationArguments @"arguments"
42 #define kSimDeviceLaunchApplicationEnvironment @"environment"
43 
44 @interface SimDevice : NSObject
45 - (BOOL)installApplication:(NSURL *)installURL withOptions:(NSDictionary *)options error:(NSError * __autoreleasing *)error;
46 - (pid_t)launchApplicationWithID:(NSString *)bundleID options:(NSDictionary *)options error:(NSError * __autoreleasing *)error;
47 @end
48 
49 @interface SimDeviceSet : NSObject
50 @property (readonly, copy) NSDictionary *devicesByUDID;
51 @end
52 
53 @interface SimServiceContext : NSObject
54 +(SimServiceContext *)sharedServiceContextForDeveloperDir:(NSString *)developerDir error:(NSError * __autoreleasing *)error;
55 -(SimDeviceSet *)defaultDeviceSetWithError:(NSError * __autoreleasing *)error;
56 @end
57 
58 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTPipeRelay.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef LTPipeRelay_h
27 #define LTPipeRelay_h
28 
29 #import "LTRelay.h"
30 
31 @interface LTPipeRelay : NSObject <LTRelay>
32 @property (weak) id<LTRelayDelegate> relayDelegate;
33 - (id)initWithPrefix:(NSString *)prefix;
34 @end
35 
36 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTPipeRelay.m

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "LTPipeRelay.h"
27 
28 #import <Foundation/Foundation.h>
29 #include <sys/stat.h>
30 #include <sys/types.h>
31 
32 @interface LTPipeRelay ()
33 @property (readonly, strong) NSString *fifoPrefix;
34 @property (strong) NSOutputStream *standardInputPipe;
35 @property (strong) NSInputStream *standardOutputPipe;
36 @property (strong) NSInputStream *standardErrorPipe;
37 
38 - (void)createFIFOs;
39 - (void)destroyFIFOs;
40 @end
41 
42 @implementation LTPipeRelay
43 
44 - (NSString *)inPipePath
45 {
46  return [_fifoPrefix stringByAppendingString:@"_IN"];
47 }
48 
49 - (NSString *)outPipePath
50 {
51  return [_fifoPrefix stringByAppendingString:@"_OUT"];
52 }
53 
54 - (NSString *)errorPipePath
55 {
56  return [_fifoPrefix stringByAppendingString:@"_ERROR"];
57 }
58 
59 - (NSOutputStream *) outputStream
60 {
61  return _standardInputPipe;
62 }
63 
64 - (id)initWithPrefix:(NSString *)prefix
65 {
66  if ((self = [super init])) {
67  _fifoPrefix = prefix;
68  [self destroyFIFOs];
69  }
70  return self;
71 }
72 
73 - (void)setup
74 {
75  [self destroyFIFOs];
76  [self createFIFOs];
77 }
78 
79 - (void)tearDown
80 {
81  [self destroyFIFOs];
82 }
83 
84 -(void) connect
85 {
86  _standardInputPipe = [NSOutputStream outputStreamToFileAtPath:[self inPipePath] append:YES];
87  _standardOutputPipe = [NSInputStream inputStreamWithFileAtPath:[self outPipePath]];
88  _standardErrorPipe = [NSInputStream inputStreamWithFileAtPath:[self errorPipePath]];
89 
90  [[self standardInputPipe] setDelegate:self];
91  [[self standardOutputPipe] setDelegate:self];
92  [[self standardErrorPipe] setDelegate:self];
93 
94  [[self standardOutputPipe] scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
95  [[self standardErrorPipe] scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
96 
97  [[self standardInputPipe] open];
98  [[self standardOutputPipe] open];
99  [[self standardErrorPipe] open];
100 
101  [[self relayDelegate] didConnect];
102 }
103 
104 - (void)disconnect
105 {
106  [[self standardOutputPipe] close];
107  [[self standardErrorPipe] close];
108  [[self standardInputPipe] close];
109  [[self relayDelegate] didDisconnect];
110 }
111 
112 - (void)createFIFOs
113 {
114  mkfifo([[self inPipePath] UTF8String], 0666);
115  mkfifo([[self outPipePath] UTF8String], 0666);
116  mkfifo([[self errorPipePath] UTF8String], 0666);
117 }
118 
119 - (void)destroyFIFOs
120 {
121  unlink([[self inPipePath] UTF8String]);
122  unlink([[self outPipePath] UTF8String]);
123  unlink([[self errorPipePath] UTF8String]);
124 }
125 
126 - (void) relayStream:(NSInputStream *)stream
127 {
128  uint8_t bytes[1024];
129  NSInteger bytesRead = [stream read:bytes maxLength:1024];
130  NSData *data = [NSData dataWithBytes:bytes length:bytesRead];
131 
132  if (stream == [self standardOutputPipe])
133  [[self relayDelegate] didReceiveStdoutData:data];
134  else
135  [[self relayDelegate] didReceiveStderrData:data];
136 }
137 
138 - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
139 {
140  switch (eventCode) {
141  case NSStreamEventNone:
142  break;
143  case NSStreamEventHasBytesAvailable:
144  [self relayStream:(NSInputStream *)aStream];
145  case NSStreamEventHasSpaceAvailable:
146  break;
147  case NSStreamEventOpenCompleted:
148  break;
149  case NSStreamEventEndEncountered:
150  [[self relayDelegate] didCrashWithMessage:nil];
151  break;
152  case NSStreamEventErrorOccurred:
153  [[self relayDelegate] didCrashWithMessage:[[aStream streamError] description]];
154  break;
155  }
156 }
157 
158 @end
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelay.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef LTRelay_h
27 #define LTRelay_h
28 
29 #import <Foundation/Foundation.h>
30 
31 @protocol LTRelayDelegate <NSObject>
32 - (void)didConnect;
33 - (void)didDisconnect;
34 - (void)didCrashWithMessage:(NSString *)message;
35 - (void)didReceiveStdoutData:(NSData *)data;
36 - (void)didReceiveStderrData:(NSData *)data;
37 @end
38 
39 @protocol LTRelay <NSObject, NSStreamDelegate>
40 - (void)setup;
41 - (void)tearDown;
42 - (void)connect;
43 - (void)disconnect;
44 @property (weak) id<LTRelayDelegate> relayDelegate;
45 @property (readonly, strong) NSOutputStream *outputStream;
46 @end
47 
48 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef LTRelayController_h
26 #define LTRelayController_h
27 
28 #import "LTRelay.h"
29 
30 #import <Foundation/Foundation.h>
31 
32 @class SimDevice;
33 
34 @interface LTRelayController : NSObject <LTRelayDelegate>
35 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments;
36 - (void)start;
37 - (void)finish;
38 @end
39 
40 #endif
211961

Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "LTRelayController.h"
27 
28 #import "CoreSimulatorSPI.h"
29 #import "LTPipeRelay.h"
30 #import <AppKit/AppKit.h>
31 #import <crt_externs.h>
32 
33 @interface LTRelayController ()
34 @property (readonly, strong) dispatch_source_t standardInputDispatchSource;
35 @property (readonly, strong) NSFileHandle *standardOutput;
36 @property (readonly, strong) NSFileHandle *standardError;
37 @property (readonly, strong) NSString *ipcIdentifier;
38 @property (readonly, strong) NSString *appBundleIdentifier;
39 @property (readonly, strong) NSString *appPath;
40 @property (readonly, strong) NSUUID *deviceUDID;
41 @property (readonly, strong) NSArray *dumpToolArguments;
42 @property (readonly, strong) NSString *productDir;
43 @property (strong) SimDevice *device;
44 @property (strong) id<LTRelay> relay;
45 @property pid_t pid;
46 @property (strong) dispatch_source_t appDispatchSource;
47 @end
48 
49 @implementation LTRelayController
50 
51 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments
52 {
53  if ((self = [super init])) {
54  _device = device;
55  _productDir = productDir;
56  _appPath = appPath;
57  _appBundleIdentifier = [[NSBundle bundleWithPath:appPath] bundleIdentifier];
58  _deviceUDID = udid;
59  _dumpToolArguments = arguments;
60  _standardInputDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, STDIN_FILENO, 0, dispatch_get_main_queue());
61  _standardOutput = [NSFileHandle fileHandleWithStandardOutput];
62  _standardError = [NSFileHandle fileHandleWithStandardError];
63 
64  dispatch_source_set_event_handler(_standardInputDispatchSource, ^{
65  uint8_t buffer[1024];
66  ssize_t len = read(STDIN_FILENO, buffer, sizeof(buffer));
67  if (len > 0) {
68  @try {
69  [[[self relay] outputStream] write:buffer maxLength:len];
70  } @catch (NSException *e) {
71  // Broken pipe - the dump tool crashed. Time to die.
72  [self didCrashWithMessage:nil];
73  }
74  } else {
75  // EOF Received on the relay's standard input.
76  [self finish];
77  }
78  });
79 
80  _relay = [[LTPipeRelay alloc] initWithPrefix:[@"/tmp" stringByAppendingPathComponent:self.ipcIdentifier]];
81  [_relay setRelayDelegate:self];
82  }
83  return self;
84 }
85 
86 - (NSString *)ipcIdentifier
87 {
88  return [NSString stringWithFormat:@"%@-%@", self.appBundleIdentifier, self.deviceUDID.UUIDString];
89 }
90 
91 - (NSString *)processName
92 {
93  return [self.appBundleIdentifier componentsSeparatedByString:@"."].lastObject;
94 }
95 
96 - (void)didReceiveStdoutData:(NSData *)data
97 {
98  @try {
99  [[self standardOutput] writeData:data];
100  } @catch (NSException *exception) {
101  // NSFileHandleOperationException
102  // Broken pipe - the test harness stopped listening to us,
103  // probably because we timed out or a run was canceled.
104  exit(EXIT_FAILURE);
105  }
106 }
107 
108 - (void)didReceiveStderrData:(NSData *)data
109 {
110  @try {
111  [[self standardError] writeData:data];
112  } @catch (NSException *exception) {
113  // NSFileHandleOperationException
114  // Broken pipe - the test harness stopped listening to us,
115  // probably because we timed out or a run was canceled.
116  exit(EXIT_FAILURE);
117  }
118 }
119 
120 - (void)didDisconnect
121 {
122  dispatch_suspend([self standardInputDispatchSource]);
123 }
124 
125 - (void)didConnect
126 {
127  dispatch_resume([self standardInputDispatchSource]);
128 }
129 
130 - (void)didCrashWithMessage:(NSString *)message
131 {
132  [[self relay] disconnect];
133  NSString *crashMessage = [NSString stringWithFormat:@"\n#CRASHED - %@ (pid %d)\n", [self processName], [self pid]];
134 
135  if (message)
136  crashMessage = [crashMessage stringByAppendingFormat:@"%@\n", message];
137 
138  [[self standardError] writeData:[crashMessage dataUsingEncoding:NSUTF8StringEncoding]];
139  [[self standardError] closeFile];
140  [[self standardOutput] closeFile];
141  exit(EXIT_FAILURE);
142 }
143 
144 - (void)installApp
145 {
146  NSDictionary *installOptions = @{
147  (NSString *)kCFBundleIdentifierKey: self.appBundleIdentifier,
148  };
149 
150  NSError *error = nil;
151  BOOL installed = [self.device installApplication:[NSURL fileURLWithPath:self.appPath] withOptions:installOptions error:&error];
152  if (!installed) {
153  NSLog(@"Couldn't install %@: %@", self.appPath, error.description);
154  exit(EXIT_FAILURE);
155  }
156 }
157 
158 - (void)killApp
159 {
160  dispatch_source_t dispatch = [self appDispatchSource];
161 
162  if (dispatch)
163  dispatch_source_cancel(dispatch);
164 
165  if ([self pid] > 1) {
166  kill(self.pid, SIGKILL);
167  [self setPid:-1];
168  }
169  [self setAppDispatchSource:nil];
170 }
171 
172 - (NSDictionary *)_environmentVariables
173 {
174  static NSDictionary *environmentVariables;
175  static dispatch_once_t once;
176 
177  dispatch_once(&once, ^{
178  NSString *productDirectory = [self productDir];
179 
180  NSMutableDictionary *dictionary = [@{
181  @"IPC_IDENTIFIER": self.ipcIdentifier,
182  @"DYLD_FRAMEWORK_PATH": productDirectory,
183  @"__XPC_DYLD_FRAMEWORK_PATH": productDirectory,
184  @"DYLD_LIBRARY_PATH": productDirectory,
185  @"__XPC_DYLD_LIBRARY_PATH": productDirectory,
186  } mutableCopy];
187 
188  for (NSString *keyName in @[@"DYLD_INSERT_LIBRARIES", @"MallocStackLogging", @"LOCAL_RESOURCE_ROOT", @"DUMPRENDERTREE_TEMP"]) {
189  const char* value = getenv([keyName UTF8String]);
190  if (value && strlen(value)) {
191  NSString *nsValue = [NSString stringWithUTF8String:value];
192  [dictionary setObject:nsValue forKey:keyName];
193  [dictionary setObject:nsValue forKey:[@"__XPC_" stringByAppendingString:keyName]];
194  }
195  }
196 
197  for (char** envp = *_NSGetEnviron(); *envp; envp++) {
198  const char* env = *envp;
199  if (!strncmp("JSC_", env, 4) || !strncmp("__XPC_JSC_", env, 10)) {
200  const char* equal = strchr(env, '=');
201  if (!equal) {
202  NSLog(@"Missing '=' in env var '%s'", env);
203  continue;
204  }
205 
206  static const size_t maxKeyLength = 256;
207  size_t keyLength = equal - env;
208  if (keyLength >= maxKeyLength) {
209  NSLog(@"Env var '%s' is too long", env);
210  continue;
211  }
212 
213  char key[maxKeyLength];
214  strncpy(key, env, keyLength);
215  key[keyLength] = '\0';
216  const char* value = equal + 1;
217 
218  NSString *nsKey = [NSString stringWithUTF8String:key];
219  NSString *nsValue = [NSString stringWithUTF8String:value];
220  [dictionary setObject:nsValue forKey:nsKey];
221  }
222  }
223 
224  environmentVariables = [dictionary copy];
225  });
226 
227  return environmentVariables;
228 }
229 
230 - (void)launchApp
231 {
232  NSDictionary *launchOptions = @{
233  kSimDeviceLaunchApplicationEnvironment: [self _environmentVariables],
234  kSimDeviceLaunchApplicationArguments: [self dumpToolArguments],
235  };
236 
237  NSError *error;
238  pid_t pid = [self.device launchApplicationWithID:self.appBundleIdentifier options:launchOptions error:&error];
239 
240  if (pid < 0) {
241  NSLog(@"Couldn't launch %@: %@", self.appBundleIdentifier, error.description);
242  exit(EXIT_FAILURE);
243  }
244 
245  [self setPid:pid];
246 
247  dispatch_queue_t queue = dispatch_get_main_queue();
248  dispatch_source_t simulatorAppExitDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, [self pid], DISPATCH_PROC_EXIT, queue);
249  [self setAppDispatchSource:simulatorAppExitDispatchSource];
250  dispatch_source_set_event_handler(simulatorAppExitDispatchSource, ^{
251  dispatch_source_cancel(simulatorAppExitDispatchSource);
252  [self didCrashWithMessage:nil];
253  });
254  dispatch_resume(simulatorAppExitDispatchSource);
255 }
256 
257 - (void)start
258 {
259  [self installApp];
260  [[self relay] setup];
261  [self launchApp];
262  [[self relay] connect];
263 }
264 
265 - (void)finish
266 {
267  [[self relay] disconnect];
268  [self killApp];
269  exit(EXIT_SUCCESS);
270 }
271 
272 @end
211961

Tools/LayoutTestRelay/LayoutTestRelay/main.m

1 /*
2  * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "CoreSimulatorSPI.h"
27 #import "LTRelayController.h"
28 #import <Foundation/Foundation.h>
29 
30 static LTRelayController *relayController;
31 
32 void usage()
33 {
34  NSString *helpText = @"LayoutTestRelay: run a dump tool in the simulator. Not for direct consumption.\n"
35  "Usage: LayoutTestRelay [-h] [options] -- [dump tool arguments]\n"
36  "Required options:\n"
37  " -udid <identifier> Simulator device identifier\n"
38  " -app <app_path> Path to the built iOS .app bundle directory.\n"
39  " -productDir <dir> /path/to/WebKitBuild/{configuration}-{short platform}.\n";
40 
41  fprintf(stderr, "%s\n", [helpText UTF8String]);
42 }
43 
44 NSString *getRequiredStringArgument(NSString *parameter)
45 {
46  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
47  NSString *argument = [defaults stringForKey:parameter];
48 
49  if (!argument) {
50  NSLog(@"-%@ is required.", parameter);
51  usage();
52  exit(EXIT_FAILURE);
53  }
54  return argument;
55 }
56 
57 NSArray *getDumpToolArguments()
58 {
59  NSMutableArray *dumpToolArguments = [[NSMutableArray alloc] init];
60  NSArray *processArgs = [[NSProcessInfo processInfo] arguments];
61  BOOL appending = NO;
62  for (NSString *arg in processArgs) {
63  if ([arg isEqualToString:@"--"]) {
64  appending = YES;
65  continue;
66  }
67  if (appending)
68  [dumpToolArguments addObject:arg];
69  }
70  return dumpToolArguments;
71 }
72 
73 void finish()
74 {
75  [relayController finish];
76 }
77 
78 void receivedSignal(int signal)
79 {
80  exit(EXIT_SUCCESS);
81 }
82 
83 int main(int argc, const char * argv[])
84 {
85  @autoreleasepool {
86  NSArray *helpArguments = @[@"-h", @"--help"];
87  for (NSString *helpArgument in helpArguments) {
88  if ([[[NSProcessInfo processInfo] arguments] indexOfObject:helpArgument] != NSNotFound) {
89  usage();
90  exit(EXIT_FAILURE);
91  }
92  }
93 
94 #if USE_SIM_SERVICE_CONTEXT
95  NSString *developerDirectory = getRequiredStringArgument(@"developerDir");
96 #endif
97  NSUUID *udid = [[NSUUID alloc] initWithUUIDString:getRequiredStringArgument(@"udid")];
98  NSString *appPath = getRequiredStringArgument(@"app");
99  NSString *productDirectory = getRequiredStringArgument(@"productDir");
100  NSArray *dumpToolArguments = getDumpToolArguments();
101 
102 #if USE_SIM_SERVICE_CONTEXT
103  NSError *error;
104  SimServiceContext *serviceContext = [SimServiceContext sharedServiceContextForDeveloperDir:developerDirectory error:&error];
105  if (!serviceContext) {
106  NSLog(@"Device context couldn't be found: %@", error);
107  exit(EXIT_FAILURE);
108  }
109  SimDeviceSet *deviceSet = [serviceContext defaultDeviceSetWithError:nil];
110  if (!deviceSet) {
111  NSLog(@"Default device set couldn't be found: %@", error);
112  exit(EXIT_FAILURE);
113  }
114  SimDevice *device = [deviceSet.devicesByUDID objectForKey:udid];
115 #else
116  SimDevice *device = [SimDeviceSet.defaultSet.devicesByUDID objectForKey:udid];
117 #endif
118  if (!device) {
119  NSLog(@"Device %@ couldn't be found", udid);
120  exit(EXIT_FAILURE);
121  }
122 
123  relayController = [[LTRelayController alloc] initWithDevice:device productDir:productDirectory appPath:appPath deviceUDID:udid dumpToolArguments:dumpToolArguments];
124  [relayController start];
125 
126  atexit(finish);
127  signal(SIGINT, receivedSignal);
128  signal(SIGTERM, receivedSignal);
129 
130  [[NSRunLoop mainRunLoop] run];
131  }
132  return 0;
133 }
211961

Tools/Scripts/build-layouttestrelay

1 #!/usr/bin/perl -w
2 
3 # Copyright (C) 2014-2015 Apple Inc. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 # THE POSSIBILITY OF SUCH DAMAGE.
25 
26 use strict;
27 use File::Basename;
28 use FindBin;
29 use Getopt::Long qw(:config pass_through);
30 use lib $FindBin::Bin;
31 use webkitdirs;
32 
33 my $showHelp = 0;
34 my $clean = 0;
35 
36 my $programName = basename($0);
37 my $usage = <<EOF;
38 Usage: $programName [options] [options to pass to build system]
39  --help Show this help message
40  --clean Clean up the build directory
41 EOF
42 
43 my $result = GetOptions(
44  'help' => \$showHelp,
45  'clean' => \$clean,
46 );
47 
48 if ($showHelp or not $result) {
49  print STDERR $usage;
50  exit 1;
51 }
52 
53 checkRequiredSystemConfig();
54 setConfiguration();
55 chdirWebKit();
56 
57 chdir "Tools/LayoutTestRelay" or die;
58 
59 # FIXME: This tool is only useful when building WebKit for iOS Simulator. For now,
60 # to avoid breaking some Apple Internal tools we support calling this script
61 # without --ios-simulator so long as we are building on a Mac.
62 if (isAppleMacWebKit() && !willUseIOSDeviceSDK()) {
63  # FIXME: Changing SDK at this point results in an inconsistent webkitdirs state.
64  # We should make it so that webkitdirs functions never see the wrong SDK.
65  setXcodeSDK(undef); # Force use of Mac SDK if --ios-simulator was passed
66  exit exitStatus(buildXCodeProject("LayoutTestRelay", $clean, XcodeOptions(), @ARGV));
67 }
68 
69 print STDERR "LayoutTestRelay is only supported for iOS Simulator.\n";
70 exit 1;
211961

Tools/Scripts/build-webkit

@@if (isAppleMacWebKit()) {
200200 push @copyLibrariesArgs, productDir();
201201 print(join(" ", @copyLibrariesArgs) . "\n");
202202 (system(@copyLibrariesArgs) == 0) or die;
203 
204  if (willUseIOSSimulatorSDK()) {
205  (system("perl", "Tools/Scripts/build-layouttestrelay", argumentsForConfiguration()) == 0) or die;
206  }
207203 }
208204
209205 # Build Tools needed for Apple ports
211961