ObjFW  Check-in [294557d352]

Overview
Comment:OFUNIXDatagramSocketTests: Don't require files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | unix-sockets
Files: files | file ages | folders
SHA3-256: 294557d3528fed9222e0db448df39b47494a4b7230b60513765e2fa436896dfd
User & Date: js on 2021-10-24 15:48:05
Other Links: branch diff | manifest | tags
Context
2021-10-24
16:07
Don't try to use UNIX sockets on MorphOS check-in: 2f49b4aec2 user: js tags: unix-sockets
15:48
OFUNIXDatagramSocketTests: Don't require files check-in: 294557d352 user: js tags: unix-sockets
15:18
OFUNIXDatagramSocketTests: Clean up after test check-in: d126e27198 user: js tags: unix-sockets
Changes

Modified tests/OFUNIXDatagramSocketTests.m from [58f17d5fdb] to [9cfb905769].

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
{
	void *pool = objc_autoreleasePoolPush();
	OFString *path;
	OFUNIXDatagramSocket *sock;
	OFSocketAddress address1, address2;
	char buffer[5];


	path = [[OFSystemInfo temporaryDirectoryPath]
	    stringByAppendingPathComponent: [[OFUUID UUID] UUIDString]];









	@try {
		TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))

		TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path]))

		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 &&
		    OFSocketAddressEqual(&address1, &address2) &&
		    OFSocketAddressHash(&address1) ==
		    OFSocketAddressHash(&address2))
	} @finally {

		[[OFFileManager defaultManager] removeItemAtPath: path];

	}

	objc_autoreleasePoolPop(pool);
}
@end







>


>
>
>
>
>
>
>
>


















>

>





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
{
	void *pool = objc_autoreleasePoolPush();
	OFString *path;
	OFUNIXDatagramSocket *sock;
	OFSocketAddress address1, address2;
	char buffer[5];

#ifdef OF_HAVE_FILES
	path = [[OFSystemInfo temporaryDirectoryPath]
	    stringByAppendingPathComponent: [[OFUUID UUID] UUIDString]];
#else
	/*
	 * We can have sockets, including UNIX sockets, while file support is
	 * disabled.
	 */
	path = [OFString stringWithFormat: @"/tmp/%@",
					   [[OFUUID UUID] UUIDString]];
#endif

	@try {
		TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))

		TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path]))

		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 &&
		    OFSocketAddressEqual(&address1, &address2) &&
		    OFSocketAddressHash(&address1) ==
		    OFSocketAddressHash(&address2))
	} @finally {
#ifdef OF_HAVE_FILES
		[[OFFileManager defaultManager] removeItemAtPath: path];
#endif
	}

	objc_autoreleasePoolPop(pool);
}
@end