Differences From Artifact [abf65b2714]:
- File
tests/OFIPXSocketTests.m
— part of check-in
[af0f8118d0]
at
2022-11-06 21:24:30
on branch trunk
— OFIPXSocketTests: Do not compare sender network
It can be different due to IPX internal networks. (user: js, size: 2301) [annotate] [blame] [check-ins using] [more...]
To Artifact [0ae4e44d89]:
- File tests/OFIPXSocketTests.m — part of check-in [26ddd2e4e4] at 2024-01-02 17:17:25 on branch trunk — Update copyright (user: js, size: 3374) [annotate] [blame] [check-ins using] [more...]
1 | 1 2 3 4 5 6 7 8 9 | - + | /* |
| ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | + + |
@implementation TestsAppDelegate (OFIPXSocketTests)
- (void)IPXSocketTests
{
const unsigned char zeroNode[IPX_NODE_LEN] = { 0 };
void *pool = objc_autoreleasePoolPush();
OFIPXSocket *sock;
OFSocketAddress address1, address2;
OFDictionary *networkInterfaces;
char buffer[5];
unsigned char node1[IPX_NODE_LEN], node2[IPX_NODE_LEN];
unsigned char node[IPX_NODE_LEN];
TEST(@"+[socket]", (sock = [OFIPXSocket socket]))
@try {
TEST(@"-[bindToNetwork:node:port:packetType:]",
R(address1 = [sock bindToNetwork: 0
node: zeroNode
|
| ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
default:
@throw e;
}
objc_autoreleasePoolPop(pool);
return;
}
/*
* Find any network interface with IPX and send to it. Any should be
* fine since we bound to 0.0.
*/
networkInterfaces = [OFSystemInfo networkInterfaces];
for (OFString *name in networkInterfaces) {
OFNetworkInterface interface = [networkInterfaces
objectForKey: name];
OFData *addresses = [interface
objectForKey: OFNetworkInterfaceIPXAddresses];
if (addresses.count == 0)
continue;
OFSocketAddressSetIPXNetwork(&address1,
OFSocketAddressIPXNetwork([addresses itemAtIndex: 0]));
OFSocketAddressGetIPXNode([addresses itemAtIndex: 0], node);
OFSocketAddressSetIPXNode(&address1, node);
}
OFSocketAddressGetIPXNode(&address1, node);
if (OFSocketAddressIPXNetwork(&address1) == 0 &&
memcmp(node, zeroNode, 6) == 0) {
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"[OFIPXSocket] -[sendBuffer:length:receiver:]: "
@"Could not determine own address, skipping tests"];
objc_autoreleasePoolPop(pool);
return;
}
TEST(@"-[sendBuffer:length:receiver:]",
R([sock sendBuffer: "Hello" length: 5 receiver: &address1]))
TEST(@"-[receiveIntoBuffer:length:sender:]",
[sock receiveIntoBuffer: buffer length: 5 sender: &address2] == 5 &&
memcmp(buffer, "Hello", 5) == 0 &&
|
| ︙ |