Overview
Comment: | Migrate OFSPXStreamSocketTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
ddfac3014954908a3d70f2dfb1c35fee |
User & Date: | js on 2024-02-14 00:31:25 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-14
| ||
00:41 | Migrate OFDDPSocketTests to ObjFWTest check-in: 572bcb3d8b user: js tags: objfwtest | |
00:31 | Migrate OFSPXStreamSocketTests to ObjFWTest check-in: ddfac30149 user: js tags: objfwtest | |
00:16 | Migrate OFSPXSocketTests to ObjFWTest check-in: dfcd2ee66f user: js tags: objfwtest | |
Changes
Modified new_tests/Makefile from [b42f0321a2] to [f40a953208].
︙ | ︙ | |||
49 50 51 52 53 54 55 | SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFDNSResolverTests.m \ OFSocketTests.m \ OFTCPSocketTests.m \ OFUDPSocketTests.m \ ${USE_SRCS_IPX} \ ${USE_SRCS_UNIX_SOCKETS} | | | > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFDNSResolverTests.m \ OFSocketTests.m \ OFTCPSocketTests.m \ OFUDPSocketTests.m \ ${USE_SRCS_IPX} \ ${USE_SRCS_UNIX_SOCKETS} SRCS_IPX = OFIPXSocketTests.m \ OFSPXSocketTests.m \ OFSPXStreamSocketTests.m SRCS_UNIX_SOCKETS = OFUNIXDatagramSocketTests.m \ OFUNIXStreamSocketTests.m SRCS_SUBPROCESSES = OFSubprocessTests.m SRCS_THREADS = OFThreadTests.m include ../buildsys.mk |
︙ | ︙ |
Renamed and modified tests/OFSPXStreamSocketTests.m [37e7d0cfd1] to new_tests/OFSPXStreamSocketTests.m [096521a07d].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> | > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSPXStreamSocketTests: OTTestCase { OFSPXStreamSocket *_sockServer; OFSocketAddress _addrServer; } @end @interface SPXStreamSocketDelegate: OFObject <OFSPXStreamSocketDelegate> { @public OFStreamSocket *_expectedServerSocket; OFSPXStreamSocket *_expectedClientSocket; uint32_t _expectedNetwork; unsigned char _expectedNode[IPX_NODE_LEN]; uint16_t _expectedPort; bool _accepted; bool _connected; } @end @implementation OFSPXStreamSocketTests - (void)setUp { const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; _sockServer = [[OFSPXStreamSocket alloc] init]; @try { _addrServer = [_sockServer bindToNetwork: 0 node: zeroNode port: 0]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: OTSkip(@"IPX unsupported"); case ESOCKTNOSUPPORT: case EPROTONOSUPPORT: OTSkip(@"SPX unsupported"); case EADDRNOTAVAIL: OTSkip(@"IPX not configured"); default: @throw e; } } } - (void)dealloc { [_sockServer release]; [super dealloc]; } - (void)testSPXStreamSocket { OFSPXStreamSocket *sockClient, *sockAccepted; const OFSocketAddress *addrAccepted; uint32_t network; unsigned char node[IPX_NODE_LEN], node2[IPX_NODE_LEN]; uint16_t port; OFDictionary *networkInterfaces; char buffer[5]; sockClient = [OFSPXStreamSocket socket]; network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); port = OFSocketAddressIPXPort(&_addrServer); [_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); } [sockClient connectToNetwork: network node: node port: port]; sockAccepted = [_sockServer accept]; [sockAccepted writeBuffer: "Hello" length: 5]; /* Test reassembly (this would not work with OFSPXSocket) */ OTAssertEqual([sockClient readIntoBuffer: buffer length: 2], 2); OTAssertEqual([sockClient readIntoBuffer: buffer + 2 length: 3], 3); OTAssertEqual(memcmp(buffer, "Hello", 5), 0); addrAccepted = sockAccepted.remoteAddress; OFSocketAddressGetIPXNode(addrAccepted, node2); OTAssertEqual(memcmp(node, node2, IPX_NODE_LEN), 0); } - (void)testAsyncSPXStreamSocket { SPXStreamSocketDelegate *delegate = [[[SPXStreamSocketDelegate alloc] init] autorelease]; uint32_t network; unsigned char node[IPX_NODE_LEN]; uint16_t port; OFDictionary *networkInterfaces; OFSPXStreamSocket *sockClient; delegate->_expectedServerSocket = _sockServer; _sockServer.delegate = delegate; sockClient = [OFSPXStreamSocket socket]; delegate->_expectedClientSocket = sockClient; sockClient.delegate = delegate; [_sockServer listen]; [_sockServer asyncAccept]; network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); port = OFSocketAddressIPXPort(&_addrServer); /* * 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); } delegate->_expectedNetwork = network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); delegate->_expectedPort = port = OFSocketAddressIPXPort(&_addrServer); @try { [sockClient asyncConnectToNetwork: network node: node port: port]; [[OFRunLoop mainRunLoop] runUntilDate: [OFDate dateWithTimeIntervalSinceNow: 2]]; OTAssertTrue(delegate->_accepted); OTAssertTrue(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: OTSkip(@"select() not supported for SPX"); default: @throw e; } } } @end @implementation SPXStreamSocketDelegate - (bool)socket: (OFStreamSocket *)sock didAcceptSocket: (OFStreamSocket *)accepted exception: (id)exception |
︙ | ︙ | |||
62 63 64 65 66 67 68 69 | network == _expectedNetwork && memcmp(node, _expectedNode, IPX_NODE_LEN) == 0 && port == _expectedPort && exception == nil); if (_accepted && _connected) [[OFRunLoop mainRunLoop] stop]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 229 230 231 232 233 234 235 236 | network == _expectedNetwork && memcmp(node, _expectedNode, IPX_NODE_LEN) == 0 && port == _expectedPort && exception == nil); if (_accepted && _connected) [[OFRunLoop mainRunLoop] stop]; } @end |
Modified tests/Makefile from [74a0ebc06a] to [b466f143bd].
︙ | ︙ | |||
30 31 32 33 34 35 36 | ${USE_SRCS_FILES} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_WINDOWS} SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieTests.m \ OFHTTPCookieManagerTests.m \ OFKernelEventObserverTests.m \ | | < < | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ${USE_SRCS_FILES} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_WINDOWS} SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieTests.m \ OFHTTPCookieManagerTests.m \ OFKernelEventObserverTests.m \ ${USE_SRCS_APPLETALK} SRCS_APPLETALK = OFDDPSocketTests.m SRCS_WINDOWS = OFWindowsRegistryKeyTests.m IOS_USER ?= mobile IOS_TMP ?= /tmp/objfw-test include ../buildsys.mk |
︙ | ︙ |
Modified tests/TestsAppDelegate.h from [80208600a5] to [eb02d80761].
︙ | ︙ | |||
103 104 105 106 107 108 109 | - (void)runtimeTests; @end @interface TestsAppDelegate (RuntimeARCTests) - (void)runtimeARCTests; @end | < < < < | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | - (void)runtimeTests; @end @interface TestsAppDelegate (RuntimeARCTests) - (void)runtimeARCTests; @end @interface TestsAppDelegate (OFStreamTests) - (void)streamTests; @end @interface TestsAppDelegate (OFStringTests) - (void)stringTests; @end |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [7ac3914ad0] to [ee32dd4840].
︙ | ︙ | |||
379 380 381 382 383 384 385 | [self dictionaryTests]; [self listTests]; [self valueTests]; [self streamTests]; [self memoryStreamTests]; [self notificationCenterTests]; #ifdef OF_HAVE_SOCKETS | < < < | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | [self dictionaryTests]; [self listTests]; [self valueTests]; [self streamTests]; [self memoryStreamTests]; [self notificationCenterTests]; #ifdef OF_HAVE_SOCKETS # ifdef OF_HAVE_APPLETALK [self DDPSocketTests]; # endif [self kernelEventObserverTests]; #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) [self HTTPClientTests]; |
︙ | ︙ |