]> git.saurik.com Git - apple/mdnsresponder.git/blob - unittests/ResourceRecordTest.c
mDNSResponder-878.1.1.tar.gz
[apple/mdnsresponder.git] / unittests / ResourceRecordTest.c
1 #include "mDNSEmbeddedAPI.h"
2 #include "../mDNSCore/DNSCommon.h"
3 #include "ResourceRecordTest.h"
4
5 int TXTSetupTest(void);
6 int ASetupTest(void);
7 int OPTSetupTest(void);
8
9
10 UNITTEST_HEADER(ResourceRecordTest)
11 UNITTEST_TEST(TXTSetupTest)
12 UNITTEST_TEST(ASetupTest)
13 UNITTEST_TEST(OPTSetupTest)
14 UNITTEST_FOOTER
15
16
17 UNITTEST_HEADER(TXTSetupTest)
18
19 AuthRecord authRec;
20 mDNS_SetupResourceRecord(&authRec, mDNSNULL, mDNSInterface_Any, kDNSType_TXT, kStandardTTL, kDNSRecordTypeShared, AuthRecordAny,mDNSNULL, mDNSNULL);
21 // This fails >> UNITTEST_ASSERT_RETURN(authRec.resrec.RecordType == kDNSType_TXT);
22 UNITTEST_ASSERT_RETURN(authRec.resrec.rdata->MaxRDLength == sizeof(RDataBody));
23
24 // Retest with a RDataStorage set to a a buffer
25 UNITTEST_FOOTER
26
27
28 UNITTEST_HEADER(ASetupTest)
29 AuthRecord authRec;
30 mDNS_SetupResourceRecord(&authRec, mDNSNULL, mDNSInterface_Any, kDNSType_A, kHostNameTTL, kDNSRecordTypeUnique, AuthRecordAny, mDNSNULL, mDNSNULL);
31
32 // This fails >> UNITTEST_ASSERT_RETURN(authRec.resrec.RecordType == kDNSType_A);
33 // Add more verifications
34
35 UNITTEST_FOOTER
36
37
38 UNITTEST_HEADER(OPTSetupTest)
39 AuthRecord opt;
40 mDNSu32 updatelease = 7200;
41 /* mDNSu8 data[AbsoluteMaxDNSMessageData];
42 mDNSu8 *p = data;
43 mDNSu16 numAdditionals;
44 */
45 // Setup the OPT Record
46 mDNS_SetupResourceRecord(&opt, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, AuthRecordAny, mDNSNULL, mDNSNULL);
47
48 // Verify the basic initialization is all ok
49
50 opt.resrec.rrclass = NormalMaxDNSMessageData;
51 opt.resrec.rdlength = sizeof(rdataOPT); // One option in this OPT record
52 opt.resrec.rdestimate = sizeof(rdataOPT);
53 opt.resrec.rdata->u.opt[0].opt = kDNSOpt_Lease;
54 opt.resrec.rdata->u.opt[0].u.updatelease = updatelease;
55
56 // Put the resource record in and verify everything is fine
57 // p = PutResourceRecordTTLWithLimit(&data, p, &numAdditionals, &opt.resrec, opt.resrec.rroriginalttl, data + AbsoluteMaxDNSMessageData);
58
59
60 // Repeat with bad data to make sure it bails out cleanly
61 UNITTEST_FOOTER