]> git.saurik.com Git - apple/mdnsresponder.git/blob - unittests/ResourceRecordTest.c
d0530086ad5518cf392f56e7a09c630f7d65e73d
[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 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 UNITTEST_ASSERT_RETURN(authRec.resrec.RecordType == kDNSType_A);
32 // Add more verifications
33
34 UNITTEST_FOOTER
35
36
37 UNITTEST_HEADER(OPTSetupTest)
38 AuthRecord opt;
39 mDNSu32 updatelease = 7200;
40 /* mDNSu8 data[AbsoluteMaxDNSMessageData];
41 mDNSu8 *p = data;
42 mDNSu16 numAdditionals;
43 */
44 // Setup the OPT Record
45 mDNS_SetupResourceRecord(&opt, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, AuthRecordAny, mDNSNULL, mDNSNULL);
46
47 // Verify the basic initialization is all ok
48
49 opt.resrec.rrclass = NormalMaxDNSMessageData;
50 opt.resrec.rdlength = sizeof(rdataOPT); // One option in this OPT record
51 opt.resrec.rdestimate = sizeof(rdataOPT);
52 opt.resrec.rdata->u.opt[0].opt = kDNSOpt_Lease;
53 opt.resrec.rdata->u.opt[0].u.updatelease = updatelease;
54
55 // Put the resource record in and verify everything is fine
56 // p = PutResourceRecordTTLWithLimit(&data, p, &numAdditionals, &opt.resrec, opt.resrec.rroriginalttl, data + AbsoluteMaxDNSMessageData);
57
58
59 // Repeat with bad data to make sure it bails out cleanly
60 UNITTEST_FOOTER