Commit 4e3a85f9 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2097] added test case for too-many-RDATAs exceeding the threshold.

as suggested in review.
also updated getRRSIGWithRdataCount() to generate the data from write,
not from text as I found it took much longer time if I did it from text
(which is simpler).  with large number of RRSIGs it's noticeable and not
good for unittests to run frequently.
parent a851fd51
......@@ -143,6 +143,11 @@ TEST_F(RdataSetTest, createManyRRs) {
getRRsetWithRdataCount(8192),
ConstRRsetPtr()),
RdataSetError);
// To be very sure even try larger number than the threshold
EXPECT_THROW(RdataSet::create(mem_sgmt_, encoder_,
getRRsetWithRdataCount(65535),
ConstRRsetPtr()),
RdataSetError);
}
TEST_F(RdataSetTest, createWithRRSIG) {
......@@ -169,12 +174,22 @@ ConstRRsetPtr
getRRSIGWithRdataCount(size_t sig_count) {
RRsetPtr rrset(new RRset(Name("example.com"), RRClass::IN(),
RRType::RRSIG(), RRTTL(3600)));
// We use a base wire-format image and tweak the original TTL field to
// generate unique RDATAs in the loop. (Creating them from corresponding
// text is simpler, but doing so for a large number of RRSIGs is
// relatively heavy and could be too long for unittests).
ConstRdataPtr rrsig_base =
rdata::createRdata(RRType::RRSIG(), RRClass::IN(),
"A 5 2 3600 20120814220826 20120715220826 1234 "
"example.com. FAKE");
isc::util::OutputBuffer ob(0);
rrsig_base->toWire(ob);
for (size_t i = 0; i < sig_count; ++i) {
rrset->addRdata(rdata::createRdata(
RRType::RRSIG(), RRClass::IN(),
"A 5 2 3600 20120814220826 20120715220826 " +
lexical_cast<std::string>(i) +
" example.com. FAKE"));
ob.writeUint16At((i >> 16) & 0xffff, 4);
ob.writeUint16At(i & 0xffff, 6);
isc::util::InputBuffer ib(ob.getData(), ob.getLength());
rrset->addRdata(rdata::createRdata(RRType::RRSIG(), RRClass::IN(),
ib, ib.getLength()));
}
return (rrset);
}
......@@ -205,6 +220,10 @@ TEST_F(RdataSetTest, createManyRRSIGs) {
EXPECT_THROW(RdataSet::create(mem_sgmt_, encoder_, a_rrset_,
getRRSIGWithRdataCount(65536)),
RdataSetError);
// To be very sure even try larger number than the threshold
EXPECT_THROW(RdataSet::create(mem_sgmt_, encoder_, a_rrset_,
getRRSIGWithRdataCount(70000)),
RdataSetError);
}
TEST_F(RdataSetTest, createWithRRSIGOnly) {
......
Supports Markdown
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