Differences From Artifact [951eb7a23c]:
- File
tests/OFSPXSocketTests.m
— part of check-in
[a54730b88f]
at
2022-10-22 18:41:45
on branch trunk
— OFSocket: Don't combine port for IP and IPX
While it works for those two protocols, it's a bad precedent as other
protocols have different types for ports. (user: js, size: 5395) [annotate] [blame] [check-ins using] [more...]
To Artifact [262f8617dc]:
- File tests/OFSPXSocketTests.m — part of check-in [26ddd2e4e4] at 2024-01-02 17:17:25 on branch trunk — Update copyright (user: js, size: 6111) [annotate] [blame] [check-ins using] [more...]
1 | 1 2 3 4 5 6 7 8 9 | - + | /* |
| ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | + |
void *pool = objc_autoreleasePoolPush();
OFSPXSocket *sockClient, *sockServer = nil, *sockAccepted;
OFSocketAddress address1;
const OFSocketAddress *address2;
uint32_t network;
unsigned char node[IPX_NODE_LEN], node2[IPX_NODE_LEN];
uint16_t port;
OFDictionary *networkInterfaces;
char buffer[5];
SPXSocketDelegate *delegate;
TEST(@"+[socket]", (sockClient = [OFSPXSocket socket]) &&
(sockServer = [OFSPXSocket socket]))
@try {
|
| ︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | + + + + + + + + + + + + + + + + + + - |
}
network = OFSocketAddressIPXNetwork(&address1);
OFSocketAddressGetIPXNode(&address1, node);
port = OFSocketAddressIPXPort(&address1);
TEST(@"-[listen]", R([sockServer listen]))
/*
* 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;
network = OFSocketAddressIPXNetwork([addresses itemAtIndex: 0]);
OFSocketAddressGetIPXNode([addresses itemAtIndex: 0], node);
}
TEST(@"-[connectToNetwork:node:port:]",
R([sockClient connectToNetwork: network node: node port: port]))
TEST(@"-[accept]", (sockAccepted = [sockServer accept]))
TEST(@"-[sendBuffer:length:]",
R([sockAccepted sendBuffer: "Hello" length: 5]))
TEST(@"-[receiveIntoBuffer:length:]",
[sockClient receiveIntoBuffer: buffer length: 5] == 5 &&
memcmp(buffer, "Hello", 5) == 0)
TEST(@"-[remoteAddress]",
(address2 = sockAccepted.remoteAddress) &&
|
| ︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | + + + + + + + |
[[OFRunLoop mainRunLoop] runUntilDate:
[OFDate dateWithTimeIntervalSinceNow: 2]];
TEST(@"-[asyncAccept] & -[asyncConnectToNetwork:node:port:]",
delegate->_accepted && delegate->_connected)
} @catch (OFObserveKernelEventsFailedException *e) {
/*
* Make sure it doesn't stay in the run loop and throws again
* next time we run the run loop.
*/
[sockClient cancelAsyncRequests];
[sockServer cancelAsyncRequests];
switch (e.errNo) {
case ENOTSOCK:
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFSPXSocket] -[asyncAccept] & "
@"-[asyncConnectToNetwork:node:port:]: select() "
@"not supported for SPX, skipping test"];
|
| ︙ |