@@ -102,46 +102,6 @@ - (void)testLoggerInterface {
102
102
XCTAssertNoThrow (GULLogDebug (@" my service" , NO , kMessageCode , @" Configure %@ ." , @" blah" ));
103
103
}
104
104
105
- // asl_set_filter does not perform as expected in unit test environment with simulator. The
106
- // following test only checks whether the logs have been sent to system with the default settings in
107
- // the unit test environment.
108
- - (void )testSystemLogWithDefaultStatus {
109
- #if !(BUG128) // Disable until https://github.com/firebase/firebase-ios-sdk/issues/128 is fixed
110
- // Test fails on device and iOS 9 simulators - b/38130372
111
- return ;
112
- #else
113
- // Sets the time interval that we need to wait in order to fetch all the logs.
114
- NSTimeInterval timeInterval = 0 .1f ;
115
- // Generates a random string each time and check whether it has been logged.
116
- // Log messages with Notice level and below should be logged to system/device by default.
117
- self.randomLogString = [NSUUID UUID ].UUIDString ;
118
- GULLogError (@" my service" , NO , kMessageCode , @" %@ " , self.randomLogString );
119
- [[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: timeInterval]];
120
- XCTAssertTrue ([self logExists ]);
121
-
122
- self.randomLogString = [NSUUID UUID ].UUIDString ;
123
- GULLogWarning (@" my service" , kMessageCode , @" %@ " , self.randomLogString );
124
- [[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: timeInterval]];
125
- XCTAssertTrue ([self logExists ]);
126
-
127
- self.randomLogString = [NSUUID UUID ].UUIDString ;
128
- GULLogNotice (@" my service" , kMessageCode , @" %@ " , self.randomLogString );
129
- [[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: timeInterval]];
130
- XCTAssertTrue ([self logExists ]);
131
-
132
- // Log messages with Info level and above should NOT be logged to system/device by default.
133
- self.randomLogString = [NSUUID UUID ].UUIDString ;
134
- GULLogInfo (@" my service" , kMessageCode , @" %@ " , self.randomLogString );
135
- [[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: timeInterval]];
136
- XCTAssertFalse ([self logExists ]);
137
-
138
- self.randomLogString = [NSUUID UUID ].UUIDString ;
139
- GULLogDebug (@" my service" , kMessageCode , @" %@ " , self.randomLogString );
140
- [[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: timeInterval]];
141
- XCTAssertFalse ([self logExists ]);
142
- #endif
143
- }
144
-
145
105
// The GULLoggerLevel enum must match the ASL_LEVEL_* constants, but we manually redefine
146
106
// them in GULLoggerLevel.h since we cannot include <asl.h> (see b/34976089 for more details).
147
107
// This test ensures the constants match.
@@ -153,43 +113,5 @@ - (void)testGULLoggerLevelValues {
153
113
XCTAssertEqual (GULLoggerLevelDebug, ASL_LEVEL_DEBUG);
154
114
}
155
115
156
- // Helper functions.
157
- - (BOOL )logExists {
158
- [self drainGULClientQueue ];
159
- NSString *correctMsg =
160
- [NSString stringWithFormat: @" %@ [%@ ] %@ " , @" my service" , kMessageCode , self .randomLogString];
161
- return [self messageWasLogged: correctMsg];
162
- }
163
-
164
- - (void )drainGULClientQueue {
165
- dispatch_semaphore_t workerSemaphore = dispatch_semaphore_create (0 );
166
- dispatch_async (getGULClientQueue (), ^{
167
- dispatch_semaphore_signal (workerSemaphore);
168
- });
169
- dispatch_semaphore_wait (workerSemaphore, DISPATCH_TIME_FOREVER);
170
- }
171
-
172
- - (BOOL )messageWasLogged : (NSString *)message {
173
- #pragma clang diagnostic push
174
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
175
- aslmsg query = asl_new (ASL_TYPE_QUERY);
176
- asl_set_query (query, ASL_KEY_FACILITY, kGULLoggerASLClientFacilityName , ASL_QUERY_OP_EQUAL);
177
- aslresponse r = asl_search (getGULLoggerClient (), query);
178
- asl_free (query);
179
- aslmsg m;
180
- const char *val;
181
- NSMutableArray *allMsg = [[NSMutableArray alloc ] init ];
182
- while ((m = asl_next (r)) != NULL ) {
183
- val = asl_get (m, ASL_KEY_MSG);
184
- if (val) {
185
- [allMsg addObject: [NSString stringWithUTF8String: val]];
186
- }
187
- }
188
- asl_free (m);
189
- asl_release (r);
190
- return [allMsg containsObject: message];
191
- #pragma clang pop
192
- }
193
-
194
116
@end
195
117
#endif
0 commit comments