Commit 463700b3 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1866] auto-generate RRType defs for all (yet fully) unsupported types.

added some tests to check the definitions are complete and correct.
parent f575d8fc
......@@ -79,6 +79,35 @@ EXTRA_DIST += rdata/generic/afsdb_18.h
EXTRA_DIST += rdata/generic/any_255.txt
EXTRA_DIST += rdata/generic/axfr_252.txt
EXTRA_DIST += rdata/generic/ixfr_251.txt
EXTRA_DIST += rdata/generic/cert_37.txt
EXTRA_DIST += rdata/generic/gpos_27.txt
EXTRA_DIST += rdata/generic/hip_55.txt
EXTRA_DIST += rdata/generic/ipseckey_45.txt
EXTRA_DIST += rdata/generic/isdn_20.txt
EXTRA_DIST += rdata/generic/key_25.txt
EXTRA_DIST += rdata/generic/l32_105.txt
EXTRA_DIST += rdata/generic/l64_106.txt
EXTRA_DIST += rdata/generic/loc_29.txt
EXTRA_DIST += rdata/generic/lp_107.txt
EXTRA_DIST += rdata/generic/mb_7.txt
EXTRA_DIST += rdata/generic/md_3.txt
EXTRA_DIST += rdata/generic/mf_4.txt
EXTRA_DIST += rdata/generic/mg_8.txt
EXTRA_DIST += rdata/generic/mr_9.txt
EXTRA_DIST += rdata/generic/nid_104.txt
EXTRA_DIST += rdata/generic/null_10.txt
EXTRA_DIST += rdata/generic/nxt_30.txt
EXTRA_DIST += rdata/generic/proforma.txt
EXTRA_DIST += rdata/generic/rt_21.txt
EXTRA_DIST += rdata/generic/sig_24.txt
EXTRA_DIST += rdata/generic/tkey_249.txt
EXTRA_DIST += rdata/generic/tlsa_52.txt
EXTRA_DIST += rdata/generic/unspec_103.txt
EXTRA_DIST += rdata/generic/uri_256.txt
EXTRA_DIST += rdata/generic/x25_19.txt
EXTRA_DIST += rdata/generic/maila_254.txt
EXTRA_DIST += rdata/generic/mailb_253.txt
EXTRA_DIST += rdata/generic/caa_257.txt
EXTRA_DIST += rdata/hs_4/a_1.cc
EXTRA_DIST += rdata/hs_4/a_1.h
EXTRA_DIST += rdata/in_1/a_1.cc
......@@ -89,6 +118,13 @@ EXTRA_DIST += rdata/in_1/dhcid_49.cc
EXTRA_DIST += rdata/in_1/dhcid_49.h
EXTRA_DIST += rdata/in_1/srv_33.cc
EXTRA_DIST += rdata/in_1/srv_33.h
EXTRA_DIST += rdata/in_1/a6_38.txt
EXTRA_DIST += rdata/in_1/apl_42.txt
EXTRA_DIST += rdata/in_1/kx_36.txt
EXTRA_DIST += rdata/in_1/nsap-ptr_23.txt
EXTRA_DIST += rdata/in_1/nsap_22.txt
EXTRA_DIST += rdata/in_1/px_26.txt
EXTRA_DIST += rdata/in_1/wks_11.txt
EXTRA_DIST += rdata/none_254
#EXTRA_DIST += rdata/template.cc
#EXTRA_DIST += rdata/template.h
......
......@@ -40,7 +40,7 @@ new_rdata_factory_users = [('aaaa', 'in'),
('txt', 'generic')
]
re_typecode = re.compile('([\da-z]+)_(\d+)')
re_typecode = re.compile('([\da-z\-]+)_(\d+)')
classcode2txt = {}
typecode2txt = {}
# "AXFR"=>252 etc: for meta types and types well-known but not implemented
......@@ -286,7 +286,15 @@ def generate_typeclasscode(fileprefix, basemtime, code2txt, type_or_class):
pydef_txt = ''
for code in code2txt.keys():
codetxt = code2txt[code].upper()
declarationtxt += ' ' * 4 + 'static const RR' + cap_key + '& ' + codetxt + '();\n'
# Workaround by heuristics: there's a "NULL" RR type, but it would
# cause conflict with the C/C++ macro. We use Null as a special case.
if codetxt == 'NULL':
codetxt = 'Null'
# Likewise, convert "NSAP-PTR" to "NSAP_PTR".
if codetxt == 'NSAP-PTR':
codetxt = "NSAP_PTR"
declarationtxt += ' ' * 4 + 'static const RR' + cap_key + '& ' + \
codetxt + '();\n'
deftxt += '''inline const RR''' + cap_key + '''&
RR''' + cap_key + '''::''' + codetxt + '''() {
static RR''' + cap_key + ''' ''' + lower_key + '''(''' + code + ''');
......
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
This RR type is not yet implemented; this file is used to generate
the corresponding RRType constant and a mapping with its textual
representation, without the Rdata code. When the Rdata support is
complete this file must be removed.
......@@ -148,4 +148,29 @@ TEST_F(RRClassTest, LeftShiftOperator) {
oss << RRClass::IN();
EXPECT_EQ(RRClass::IN().toText(), oss.str());
}
// Below, we'll check definitions for all well-known RR classes; whether they
// are defined and have the correct parameter values. Test data are generated
// from the list available at:
// http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
struct ClassParam {
const char* const txt; // "IN", "CH", etc
const uint16_t code; // 1, 3,
const RRClass& (*obj)(); // RRClass::IN(), etc
} known_classes[] = {
{"IN", 1, RRClass::IN}, {"CH", 3, RRClass::CH}, {"HS", 4, RRClass::HS},
{"NONE", 254, RRClass::NONE}, {"ANY", 255, RRClass::ANY},
{NULL, 0, NULL}
};
TEST(RRClassConstTest, wellKnowns) {
for (int i = 0; known_classes[i].txt; ++i) {
SCOPED_TRACE("Checking well known RRClass: " +
string(known_classes[i].txt));
EXPECT_EQ(known_classes[i].code,
RRClass(known_classes[i].txt).getCode());
EXPECT_EQ(known_classes[i].code,
(*known_classes[i].obj)().getCode());
}
}
}
......@@ -145,4 +145,57 @@ TEST_F(RRTypeTest, LeftShiftOperator) {
oss << RRType::A();
EXPECT_EQ(RRType::A().toText(), oss.str());
}
// Below, we'll check definitions for all well-known RR types; whether they
// are defined and have the correct parameter values. Test data are generated
// from the list available at:
// http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
struct TypeParam {
const char* const txt; // "A", "AAAA", "NS", etc
const uint16_t code; // 1, 28, 2, etc
const RRType& (*obj)(); // RRType::A(), etc
} known_types[] = {
{"A", 1, RRType::A}, {"NS", 2, RRType::NS}, {"MD", 3, RRType::MD},
{"MF", 4, RRType::MF}, {"CNAME", 5, RRType::CNAME},
{"SOA", 6, RRType::SOA}, {"MB", 7, RRType::MB}, {"MG", 8, RRType::MG},
{"MR", 9, RRType::MR}, {"NULL", 10, RRType::Null},
{"WKS", 11, RRType::WKS}, {"PTR", 12, RRType::PTR},
{"HINFO", 13, RRType::HINFO}, {"MINFO", 14, RRType::MINFO},
{"MX", 15, RRType::MX}, {"TXT", 16, RRType::TXT}, {"RP", 17, RRType::RP},
{"AFSDB", 18, RRType::AFSDB}, {"X25", 19, RRType::X25},
{"ISDN", 20, RRType::ISDN}, {"RT", 21, RRType::RT},
{"NSAP", 22, RRType::NSAP}, {"NSAP-PTR", 23, RRType::NSAP_PTR},
{"SIG", 24, RRType::SIG}, {"KEY", 25, RRType::KEY},
{"PX", 26, RRType::PX}, {"GPOS", 27, RRType::GPOS},
{"AAAA", 28, RRType::AAAA}, {"LOC", 29, RRType::LOC},
{"NXT", 30, RRType::NXT}, {"SRV", 33, RRType::SRV},
{"NAPTR", 35, RRType::NAPTR}, {"KX", 36, RRType::KX},
{"CERT", 37, RRType::CERT}, {"A6", 38, RRType::A6},
{"DNAME", 39, RRType::DNAME}, {"OPT", 41, RRType::OPT},
{"APL", 42, RRType::APL}, {"DS", 43, RRType::DS},
{"SSHFP", 44, RRType::SSHFP}, {"IPSECKEY", 45, RRType::IPSECKEY},
{"RRSIG", 46, RRType::RRSIG}, {"NSEC", 47, RRType::NSEC},
{"DNSKEY", 48, RRType::DNSKEY}, {"DHCID", 49, RRType::DHCID},
{"NSEC3", 50, RRType::NSEC3}, {"NSEC3PARAM", 51, RRType::NSEC3PARAM},
{"TLSA", 52, RRType::TLSA}, {"HIP", 55, RRType::HIP},
{"SPF", 99, RRType::SPF}, {"UNSPEC", 103, RRType::UNSPEC},
{"NID", 104, RRType::NID}, {"L32", 105, RRType::L32},
{"L64", 106, RRType::L64}, {"LP", 107, RRType::LP},
{"TKEY", 249, RRType::TKEY}, {"TSIG", 250, RRType::TSIG},
{"IXFR", 251, RRType::IXFR}, {"AXFR", 252, RRType::AXFR},
{"MAILB", 253, RRType::MAILB}, {"MAILA", 254, RRType::MAILA},
{"ANY", 255, RRType::ANY}, {"URI", 256, RRType::URI},
{"CAA", 257, RRType::CAA}, {"DLV", 32769, RRType::DLV},
{NULL, 0, NULL}
};
TEST(RRTypeConstTest, wellKnowns) {
for (int i = 0; known_types[i].txt; ++i) {
SCOPED_TRACE("Checking well known RRType: " +
string(known_types[i].txt));
EXPECT_EQ(known_types[i].code, RRType(known_types[i].txt).getCode());
EXPECT_EQ(known_types[i].code,
(*known_types[i].obj)().getCode());
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment