BOOST_AUTO_TEST_SUITE(syncres_cc2)
-BOOST_AUTO_TEST_CASE(test_referral_depth)
+void do_test_referral_depth(bool limited)
{
std::unique_ptr<SyncRes> sr;
initSR(sr);
return 0;
});
- /* Set the maximum depth low */
- SyncRes::s_maxdepth = 10;
-
- try {
- vector<DNSRecord> ret;
- sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
- BOOST_CHECK(false);
+ if (limited) {
+ /* Set the maximum depth low */
+ SyncRes::s_maxdepth = 10;
+ try {
+ vector<DNSRecord> ret;
+ sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
+ BOOST_CHECK(false);
+ }
+ catch (const ImmediateServFailException& e) {
+ BOOST_CHECK(e.reason.find("max-recursion-depth") != string::npos);
+ }
}
- catch (const ImmediateServFailException& e) {
- BOOST_CHECK(e.reason.find("max-recursion-depth") != string::npos);
+ else {
+ // Check if the setup with high limit is OK.
+ SyncRes::s_maxdepth = 50;
+ try {
+ vector<DNSRecord> ret;
+ int rcode = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
+ BOOST_CHECK_EQUAL(rcode, RCode::NoError);
+ BOOST_REQUIRE_EQUAL(ret.size(), 1U);
+ BOOST_CHECK_EQUAL(ret[0].d_name, target);
+ BOOST_REQUIRE(ret[0].d_type == QType::A);
+ BOOST_CHECK(getRR<ARecordContent>(ret[0])->getCA() == ComboAddress("192.0.2.2"));
+ }
+ catch (const ImmediateServFailException& e) {
+ BOOST_CHECK(false);
+ }
}
+}
- // Then check if the setup with high limit is OK.
- SyncRes::s_maxdepth = 50;
- try {
- vector<DNSRecord> ret;
- int rcode = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
- BOOST_CHECK_EQUAL(rcode, RCode::NoError);
- BOOST_CHECK_EQUAL(ret.size(), 1U);
- BOOST_CHECK_EQUAL(ret[0].d_name, target);
- BOOST_REQUIRE(ret[0].d_type == QType::A);
- BOOST_CHECK(getRR<ARecordContent>(ret[0])->getCA() == ComboAddress("192.0.2.2"));
- }
- catch (const ImmediateServFailException& e) {
- BOOST_CHECK(false);
- }
+BOOST_AUTO_TEST_CASE(test_referral_depth)
+{
+ // Test with limit
+ do_test_referral_depth(true);
+}
+
+BOOST_AUTO_TEST_CASE(test_referral_depth_ok)
+{
+ // Test with default limit
+ do_test_referral_depth(false);
}
BOOST_AUTO_TEST_CASE(test_cname_qperq)
state = Indeterminate;
- if(s_maxdepth && depth > s_maxdepth)
- throw ImmediateServFailException("More than "+std::to_string(s_maxdepth)+" (max-recursion-depth) levels of recursion needed while resolving "+qname.toLogString());
-
+ if (s_maxdepth && depth > s_maxdepth) {
+ string msg = "More than " + std::to_string(s_maxdepth) + " (max-recursion-depth) levels of recursion needed while resolving " + qname.toLogString();
+ LOG(prefix << qname << ": " << msg << endl);
+ throw ImmediateServFailException(msg);
+ }
int res=0;
// This is a difficult way of expressing "this is a normal query", i.e. not getRootNS.