Skip to content

Commit 4265f3a

Browse files
committed
test pass
1 parent d614c43 commit 4265f3a

File tree

18 files changed

+250
-55
lines changed

18 files changed

+250
-55
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0720"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "DFCEC6441C2EC01D0058EE65"
18+
BuildableName = "libNetDiag.a"
19+
BlueprintName = "NetDiag"
20+
ReferencedContainer = "container:NetDiag.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "DF8DFFCE1C61DA1B00174DA9"
36+
BuildableName = "NetDiagTests.xctest"
37+
BlueprintName = "NetDiagTests"
38+
ReferencedContainer = "container:NetDiag.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
<MacroExpansion>
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "DFCEC6441C2EC01D0058EE65"
46+
BuildableName = "libNetDiag.a"
47+
BlueprintName = "NetDiag"
48+
ReferencedContainer = "container:NetDiag.xcodeproj">
49+
</BuildableReference>
50+
</MacroExpansion>
51+
<AdditionalOptions>
52+
</AdditionalOptions>
53+
</TestAction>
54+
<LaunchAction
55+
buildConfiguration = "Debug"
56+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
57+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
58+
launchStyle = "0"
59+
useCustomWorkingDirectory = "NO"
60+
ignoresPersistentStateOnLaunch = "NO"
61+
debugDocumentVersioning = "YES"
62+
debugServiceExtension = "internal"
63+
allowLocationSimulation = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "DFCEC6441C2EC01D0058EE65"
68+
BuildableName = "libNetDiag.a"
69+
BlueprintName = "NetDiag"
70+
ReferencedContainer = "container:NetDiag.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
<AdditionalOptions>
74+
</AdditionalOptions>
75+
</LaunchAction>
76+
<ProfileAction
77+
buildConfiguration = "Release"
78+
shouldUseLaunchSchemeArgsEnv = "YES"
79+
savedToolIdentifier = ""
80+
useCustomWorkingDirectory = "NO"
81+
debugDocumentVersioning = "YES">
82+
<MacroExpansion>
83+
<BuildableReference
84+
BuildableIdentifier = "primary"
85+
BlueprintIdentifier = "DFCEC6441C2EC01D0058EE65"
86+
BuildableName = "libNetDiag.a"
87+
BlueprintName = "NetDiag"
88+
ReferencedContainer = "container:NetDiag.xcodeproj">
89+
</BuildableReference>
90+
</MacroExpansion>
91+
</ProfileAction>
92+
<AnalyzeAction
93+
buildConfiguration = "Debug">
94+
</AnalyzeAction>
95+
<ArchiveAction
96+
buildConfiguration = "Release"
97+
revealArchiveInOrganizer = "YES">
98+
</ArchiveAction>
99+
</Scheme>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0720"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "NO"
13+
buildForArchiving = "NO"
14+
buildForAnalyzing = "NO">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "DF8DFFCE1C61DA1B00174DA9"
18+
BuildableName = "NetDiagTests.xctest"
19+
BlueprintName = "NetDiagTests"
20+
ReferencedContainer = "container:NetDiag.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "DF8DFFCE1C61DA1B00174DA9"
36+
BuildableName = "NetDiagTests.xctest"
37+
BlueprintName = "NetDiagTests"
38+
ReferencedContainer = "container:NetDiag.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
<AdditionalOptions>
43+
</AdditionalOptions>
44+
</TestAction>
45+
<LaunchAction
46+
buildConfiguration = "Debug"
47+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
48+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49+
launchStyle = "0"
50+
useCustomWorkingDirectory = "NO"
51+
ignoresPersistentStateOnLaunch = "NO"
52+
debugDocumentVersioning = "YES"
53+
debugServiceExtension = "internal"
54+
allowLocationSimulation = "YES">
55+
<MacroExpansion>
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "DF8DFFCE1C61DA1B00174DA9"
59+
BuildableName = "NetDiagTests.xctest"
60+
BlueprintName = "NetDiagTests"
61+
ReferencedContainer = "container:NetDiag.xcodeproj">
62+
</BuildableReference>
63+
</MacroExpansion>
64+
<AdditionalOptions>
65+
</AdditionalOptions>
66+
</LaunchAction>
67+
<ProfileAction
68+
buildConfiguration = "Release"
69+
shouldUseLaunchSchemeArgsEnv = "YES"
70+
savedToolIdentifier = ""
71+
useCustomWorkingDirectory = "NO"
72+
debugDocumentVersioning = "YES">
73+
<MacroExpansion>
74+
<BuildableReference
75+
BuildableIdentifier = "primary"
76+
BlueprintIdentifier = "DF8DFFCE1C61DA1B00174DA9"
77+
BuildableName = "NetDiagTests.xctest"
78+
BlueprintName = "NetDiagTests"
79+
ReferencedContainer = "container:NetDiag.xcodeproj">
80+
</BuildableReference>
81+
</MacroExpansion>
82+
</ProfileAction>
83+
<AnalyzeAction
84+
buildConfiguration = "Debug">
85+
</AnalyzeAction>
86+
<ArchiveAction
87+
buildConfiguration = "Release"
88+
revealArchiveInOrganizer = "YES">
89+
</ArchiveAction>
90+
</Scheme>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6+
<false/>
7+
</dict>
8+
</plist>

NetDiag/QNNExternalIp.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ +(NSString*)getDiagUrl{
4949
NSLog(@"fetch http error %@", httpError);
5050
return nil;
5151
}
52-
NSLog(@"fetch http code %d", response.statusCode);
52+
NSLog(@"fetch http code %ld", (long)response.statusCode);
5353
NSString* s = [[NSString alloc]initWithData:d encoding:NSUTF8StringEncoding];
5454
if (s == nil || [s isEqualToString:@""]) {
55-
NSLog(@"fetch http code %d", response.statusCode);
55+
NSLog(@"fetch http code %ld", (long)response.statusCode);
5656
return nil;
5757
}
5858
NSRange range = [s rangeOfString:@"<iframe src=\""];
@@ -102,7 +102,7 @@ +(NSString*)checkExternal{
102102
if (httpError != nil || d == nil) {
103103
return @"check server error";
104104
}
105-
NSLog(@"http code %d", response.statusCode);
105+
NSLog(@"http code %ld", (long)response.statusCode);
106106
NSString* s = [[NSString alloc]initWithData:d encoding:NSUTF8StringEncoding];
107107
if (s == nil || [s isEqualToString:@""]) {
108108
return @"invalid encoding";

NetDiag/QNNHttp.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ -(NSString*) description{
1818
bodySummary = @"not utf8 string body";
1919
}
2020
}
21-
return [NSString stringWithFormat:@"code:%d duration:%f body:%@", _code, _duration, bodySummary];
21+
return [NSString stringWithFormat:@"code:%ld duration:%f body:%@", (long)_code, _duration, bodySummary];
2222
}
2323

2424
-(instancetype)init:(NSInteger)code
@@ -75,7 +75,7 @@ -(void)run{
7575
[_output write:[httpError description]];
7676

7777
}
78-
[_output write:[NSString stringWithFormat:@"complete duration:%f status %d\n", duration, response.statusCode]];
78+
[_output write:[NSString stringWithFormat:@"complete duration:%f status %ld\n", duration, (long)response.statusCode]];
7979
if (response != nil&& response.allHeaderFields != nil) {
8080
[response.allHeaderFields enumerateKeysAndObjectsUsingBlock: ^(NSString *key, NSString *obj, BOOL *stop) {
8181
[_output write:[NSString stringWithFormat:@"%@: %@\n", key, obj]];

NetDiag/QNNPing.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ @implementation QNNPingResult
3838

3939
-(NSString*) description{
4040
if (_code == 0 || _code == kQNNRequestStoped) {
41-
return [NSString stringWithFormat:@"%d packets transmitted, %d packets received, %f packet loss time %fms\n round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms", _count+_loss, _count, (double)_loss*100/(_count+_loss), _totalTime, _minRtt, _avgRtt, _maxRtt, _stddev];
41+
return [NSString stringWithFormat:@"%d packets transmitted, %ld packets received, %f packet loss time %fms\n round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms", (int)(_count+_loss), (long)_count, (double)_loss*100/(_count+_loss), _totalTime, _minRtt, _avgRtt, _maxRtt, _stddev];
4242
}
43-
return [NSString stringWithFormat:@"ping failed %d", _code];
43+
return [NSString stringWithFormat:@"ping failed %ld", (long)_code];
4444
}
4545

4646
-(instancetype)init:(NSInteger)code
@@ -222,24 +222,24 @@ @interface QNNPing ()
222222

223223
@implementation QNNPing
224224

225-
-(NSInteger)sendPacket:(ICMPPacket*)packet
225+
-(int)sendPacket:(ICMPPacket*)packet
226226
sock:(int)sock
227227
target:(struct sockaddr_in *)addr{
228-
int sent = sendto(sock, packet, (size_t)kQNNPacketSize, 0, (struct sockaddr*)addr, (socklen_t)sizeof(struct sockaddr));
228+
ssize_t sent = sendto(sock, packet, (size_t)kQNNPacketSize, 0, (struct sockaddr*)addr, (socklen_t)sizeof(struct sockaddr));
229229
if (sent < 0) {
230230
return errno;
231231
}
232232
return 0;
233233
}
234234

235-
-(NSInteger)ping:(struct sockaddr_in*)addr
235+
-(int)ping:(struct sockaddr_in*)addr
236236
seq:(uint16_t)seq
237237
identifier:(uint16_t)identifier
238238
sock:(int)sock
239239
ttl:(int*)ttlOut
240240
size:(int*)size{
241241
ICMPPacket* packet = build_packet(seq, identifier);
242-
NSInteger err = 0;
242+
int err = 0;
243243
err = [self sendPacket:packet sock:sock target:addr];
244244
free(packet);
245245
if (err != 0) {
@@ -250,16 +250,16 @@ -(NSInteger)ping:(struct sockaddr_in*)addr
250250
socklen_t addrLen = sizeof(ret_addr);;
251251
void *buffer = malloc(kQNNPacketBufferSize);
252252

253-
int bytesRead = recvfrom(sock, buffer, kQNNPacketBufferSize, 0,
253+
ssize_t bytesRead = recvfrom(sock, buffer, kQNNPacketBufferSize, 0,
254254
(struct sockaddr *)&ret_addr, &addrLen);
255255
if (bytesRead < 0) {
256256
err = errno;
257257
}else if(bytesRead == 0){
258258
err = EPIPE;
259259
}else{
260-
if (isValidResponse(buffer, bytesRead, seq, identifier)) {
260+
if (isValidResponse(buffer, (int)bytesRead, seq, identifier)) {
261261
*ttlOut = ((IPHeader*)buffer)->timeToLive;
262-
*size = bytesRead;
262+
*size = (int)bytesRead;
263263
}else {
264264
err = kQNNInvalidPingResponse;
265265
}
@@ -294,7 +294,7 @@ -(QNNPingResult*)buildResult:(NSInteger)code
294294
NSTimeInterval avg = sum/count;
295295
NSTimeInterval avg2 = sum2/count;
296296
NSTimeInterval stddev = sqrt(avg2 - avg*avg);
297-
return [[QNNPingResult alloc]init:0 max:max min:min avg:avg loss:loss count:count totalTime:time stddev:stddev];
297+
return [[QNNPingResult alloc]init:code max:max min:min avg:avg loss:loss count:count totalTime:time stddev:stddev];
298298
}
299299

300300
-(void)run{
@@ -322,7 +322,7 @@ -(void)run{
322322
}
323323

324324
NSTimeInterval* durations = (NSTimeInterval*)calloc(sizeof(NSTimeInterval)*_count, 1);
325-
NSInteger index = 0;
325+
int index = 0;
326326
int r = 0;
327327
uint16_t identifier = (uint16_t)arc4random();
328328
int ttl = 0;
@@ -339,10 +339,10 @@ -(void)run{
339339
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:t1];
340340
if (r == 0) {
341341
// ignore broadcast address
342-
[self.output write:[NSString stringWithFormat:@"%d bytes from %s: icmp_seq=%d ttl=%d time=%f ms\n", size, inet_ntoa(addr.sin_addr), index, ttl, duration*1000]];
342+
[self.output write:[NSString stringWithFormat:@"%d bytes from %s: icmp_seq=%ld ttl=%d time=%f ms\n", size, inet_ntoa(addr.sin_addr), (long)index, ttl, duration*1000]];
343343
durations[index - loss] = duration*1000;
344344
}else{
345-
[self.output write:[NSString stringWithFormat:@"Request timeout for icmp_seq %d\n", index]];
345+
[self.output write:[NSString stringWithFormat:@"Request timeout for icmp_seq %ld\n", (long)index]];
346346
loss++;
347347
}
348348

0 commit comments

Comments
 (0)