ObjFW  Check-in [53a95fade7]

Overview
Comment:Migrate OFDNSResolverTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 53a95fade7794c78cd620bcbbb6fb9e07604e594588c11ff1f66296d7f26bb96
User & Date: js on 2024-02-12 22:49:03
Other Links: branch diff | manifest | tags
Context
2024-02-12
22:54
Migrate OFLocaleTests to ObjFWTest check-in: 7fafb1641d user: js tags: objfwtest
22:49
Migrate OFDNSResolverTests to ObjFWTest check-in: 53a95fade7 user: js tags: objfwtest
22:35
Migrate OFSystemInfoTests to ObjFWTest check-in: 6ae7f7cdbf user: js tags: objfwtest
Changes

Modified new_tests/Makefile from [f5774930f1] to [5e84369136].

39
40
41
42
43
44
45
46


47
48
49
50
51
52
53
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54







-
+
+







       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m
SRCS_SOCKETS = OFSocketTests.m
SRCS_SOCKETS = OFDNSResolverTests.m	\
	       OFSocketTests.m
SRCS_SUBPROCESSES = OFSubprocessTests.m
SRCS_THREADS = OFThreadTests.m

include ../buildsys.mk

testfile_bin.m: testfile.bin
	${SHELL} ../utils/objfw-embed testfile.bin testfile.bin $@

Renamed and modified tests/OFDNSResolverTests.m [979544c90c] to new_tests/OFDNSResolverTests.m [09e6956470].

11
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
11
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







-
+
+

-
-
+
+
+
+
+

-
+



+
-
+
+
+
+
+
+
+
+












-
+
-

-
-
+
+
-
-
-
-
+
+
-
-
+

-
-
+
-
-
-
+
-
-
-
-
+
+
-
-
-
+
+

-
-
-
+
+
+
+

-
+


 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "TestsAppDelegate.h"
#import "ObjFW.h"
#import "ObjFWTest.h"

@implementation TestsAppDelegate (OFDNSResolverTests)
- (void)DNSResolverTests
@interface OFDNSResolverTests: OTTestCase
@end

@implementation OFDNSResolverTests
+ (OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *)summary
{
	void *pool = objc_autoreleasePoolPush();
	OFMutableArray *summary = [OFMutableArray array];
	OFDNSResolver *resolver = [OFDNSResolver resolver];
	OFMutableString *staticHosts = [OFMutableString string];

#define ADD(name, value)						\
	[OFStdOut setForegroundColor: [OFColor lime]];
	[summary addObject: [OFPair pairWithFirstObject: name		\
					   secondObject: value]];
#define ADD_DOUBLE(name, value)						\
	ADD(name, [OFNumber numberWithDouble: value])
#define ADD_UINT(name, value)						\
	ADD(name, [OFNumber numberWithUnsignedInt: value]);
#define ADD_BOOL(name, value)						\
	ADD(name, [OFNumber numberWithBool: value]);

	for (OFString *host in resolver.staticHosts) {
		OFString *IPs;

		if (staticHosts.length > 0)
			[staticHosts appendString: @"; "];

		IPs = [[resolver.staticHosts objectForKey: host]
		    componentsJoinedByString: @", "];

		[staticHosts appendFormat: @"%@=(%@)", host, IPs];
	}
	[OFStdOut writeFormat: @"[OFDNSResolver] Static hosts: %@\n",
	ADD(@"Static hosts", staticHosts)
	    staticHosts];

	[OFStdOut writeFormat: @"[OFDNSResolver] Name servers: %@\n",
	    [resolver.nameServers componentsJoinedByString: @", "]];
	ADD(@"Name servers",
	    [resolver.nameServers componentsJoinedByString: @", "]);

	[OFStdOut writeFormat: @"[OFDNSResolver] Local domain: %@\n",
	    resolver.localDomain];

	ADD(@"Local domain", resolver.localDomain);
	ADD(@"Search domains",
	[OFStdOut writeFormat: @"[OFDNSResolver] Search domains: %@\n",
	    [resolver.searchDomains componentsJoinedByString: @", "]];
	    [resolver.searchDomains componentsJoinedByString: @", "]);

	[OFStdOut writeFormat: @"[OFDNSResolver] Timeout: %lf\n",
	    resolver.timeout];
	ADD_DOUBLE(@"Timeout", resolver.timeout);

	[OFStdOut writeFormat: @"[OFDNSResolver] Max attempts: %u\n",
	    resolver.maxAttempts];
	ADD_UINT(@"Max attempts", resolver.maxAttempts);

	[OFStdOut writeFormat:
	    @"[OFDNSResolver] Min number of dots in absolute name: %u\n",
	    resolver.minNumberOfDotsInAbsoluteName];
	ADD_UINT(@"Min number of dots in absolute name",
	    resolver.minNumberOfDotsInAbsoluteName);

	[OFStdOut writeFormat: @"[OFDNSResolver] Forces TCP: %u\n",
	    resolver.forcesTCP];
	ADD_BOOL(@"Forces TCP", resolver.forcesTCP);
	ADD_DOUBLE(@"Config reload interval", resolver.configReloadInterval);

	[OFStdOut writeFormat:
	    @"[OFDNSResolver] Config reload interval: %lf\n",
	    resolver.configReloadInterval];
#undef ADD
#undef ADD_DOUBLE
#undef ADD_UINT
#undef ADD_BOOL

	objc_autoreleasePoolPop(pool);
	return summary;
}
@end

Modified tests/Makefile from [42d6b45d97] to [a4259b631f].

30
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
30
31
32
33
34
35
36


37
38
39
40
41
42
43
44







-
-
+







       OFXMLParserTests.m		\
       RuntimeTests.m			\
       ${RUNTIME_ARC_TESTS_M}		\
       TestsAppDelegate.m		\
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_WINDOWS}
SRCS_SOCKETS = OFDNSResolverTests.m		\
	       ${OF_HTTP_CLIENT_TESTS_M}	\
SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M}	\
	       OFHTTPCookieTests.m		\
	       OFHTTPCookieManagerTests.m	\
	       OFKernelEventObserverTests.m	\
	       OFTCPSocketTests.m		\
	       OFUDPSocketTests.m		\
	       ${USE_SRCS_APPLETALK}		\
	       ${USE_SRCS_IPX}			\

Modified tests/TestsAppDelegate.h from [91bf45835f] to [6b34d4853a].

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
63
64
65
66
67
68
69




70
71
72
73
74
75
76







-
-
-
-







- (void)blockTests;
@end

@interface TestsAppDelegate (OFDDPSocketTests)
- (void)DDPSocketTests;
@end

@interface TestsAppDelegate (OFDNSResolverTests)
- (void)DNSResolverTests;
@end

@interface TestsAppDelegate (OFDataTests)
- (void)dataTests;
@end

@interface TestsAppDelegate (OFDictionaryTests)
- (void)dictionaryTests;
@end

Modified tests/TestsAppDelegate.m from [db4c4e8f5b] to [faae433041].

415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
415
416
417
418
419
420
421



422
423
424
425
426
427
428







-
-
-







	[self XMLNodeTests];
	[self XMLElementBuilderTests];

#ifdef OF_WINDOWS
	[self windowsRegistryKeyTests];
#endif

#ifdef OF_HAVE_SOCKETS
	[self DNSResolverTests];
#endif
	[self localeTests];

	[OFStdOut reset];

#if defined(OF_IOS)
	[OFStdOut writeFormat: @"%d tests failed!", _fails];
	[OFApplication terminateWithStatus: _fails];