mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-28 09:37:10 -04:00
Check parsed resconf values
Add 'attempts' check, fix 'ndots' data. Create a bunch of verification functions and check parsed values, not just return codes.
This commit is contained in:
parent
dbf71b3f68
commit
48d5b50313
3 changed files with 54 additions and 4 deletions
|
|
@ -42,6 +42,43 @@ setup_test(void) {
|
|||
assert_return_code(chdir(TESTS_DIR), 0);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
check_number(unsigned int n, unsigned int expected) {
|
||||
return ((n == expected) ? ISC_R_SUCCESS : ISC_R_BADNUMBER);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
check_attempts(irs_resconf_t *resconf) {
|
||||
return (check_number(irs_resconf_getattempts(resconf), 4));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
check_timeout(irs_resconf_t *resconf) {
|
||||
return (check_number(irs_resconf_gettimeout(resconf), 1));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
check_ndots(irs_resconf_t *resconf) {
|
||||
return (check_number(irs_resconf_getndots(resconf), 2));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
check_options(irs_resconf_t *resconf) {
|
||||
if (irs_resconf_getattempts(resconf) != 3) {
|
||||
return ISC_R_BADNUMBER; /* default value only */
|
||||
}
|
||||
|
||||
if (irs_resconf_getndots(resconf) != 2) {
|
||||
return ISC_R_BADNUMBER;
|
||||
}
|
||||
|
||||
if (irs_resconf_gettimeout(resconf) != 1) {
|
||||
return ISC_R_BADNUMBER;
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/* test irs_resconf_load() */
|
||||
static void
|
||||
irs_resconf_load_test(void **state) {
|
||||
|
|
@ -61,15 +98,18 @@ irs_resconf_load_test(void **state) {
|
|||
ISC_R_SUCCESS },
|
||||
{ "testdata/nameserver-v6-scoped.conf", ISC_R_SUCCESS, NULL,
|
||||
ISC_R_SUCCESS },
|
||||
{ "testdata/options-attempts.conf", ISC_R_SUCCESS,
|
||||
check_attempts, ISC_R_SUCCESS },
|
||||
{ "testdata/options-debug.conf", ISC_R_SUCCESS, NULL,
|
||||
ISC_R_SUCCESS },
|
||||
{ "testdata/options-ndots.conf", ISC_R_SUCCESS, NULL,
|
||||
{ "testdata/options-ndots.conf", ISC_R_SUCCESS, check_ndots,
|
||||
ISC_R_SUCCESS },
|
||||
{ "testdata/options-timeout.conf", ISC_R_SUCCESS, NULL,
|
||||
{ "testdata/options-timeout.conf", ISC_R_SUCCESS, check_timeout,
|
||||
ISC_R_SUCCESS },
|
||||
{ "testdata/options-unknown.conf", ISC_R_SUCCESS, NULL,
|
||||
ISC_R_SUCCESS },
|
||||
{ "testdata/options.conf", ISC_R_SUCCESS, NULL, ISC_R_SUCCESS },
|
||||
{ "testdata/options.conf", ISC_R_SUCCESS, check_options,
|
||||
ISC_R_SUCCESS },
|
||||
{ "testdata/options-bad-ndots.conf", ISC_R_RANGE, NULL,
|
||||
ISC_R_SUCCESS },
|
||||
{ "testdata/options-empty.conf", ISC_R_UNEXPECTEDEND, NULL,
|
||||
|
|
|
|||
10
lib/irs/tests/testdata/options-attempts.conf
vendored
Normal file
10
lib/irs/tests/testdata/options-attempts.conf
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
options attempts:4
|
||||
2
lib/irs/tests/testdata/options-ndots.conf
vendored
2
lib/irs/tests/testdata/options-ndots.conf
vendored
|
|
@ -7,4 +7,4 @@
|
|||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
option ndots:2
|
||||
options ndots:2
|
||||
|
|
|
|||
Loading…
Reference in a new issue