00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <atf-c.h>
00024
00025 #include <unistd.h>
00026
00027 #include <dns/rdataset.h>
00028 #include <dns/rdatastruct.h>
00029
00030 #include "dnstest.h"
00031
00032
00033
00034
00035
00036
00037
00038 ATF_TC(trimttl);
00039 ATF_TC_HEAD(trimttl, tc) {
00040 atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() loads a "
00041 "valid master file and returns success");
00042 }
00043 ATF_TC_BODY(trimttl, tc) {
00044 isc_result_t result;
00045 dns_rdataset_t rdataset, sigrdataset;
00046 dns_rdata_rrsig_t rrsig;
00047 isc_stdtime_t ttltimenow, ttltimeexpire;
00048
00049 ttltimenow = 10000000;
00050 ttltimeexpire = ttltimenow + 800;
00051
00052 UNUSED(tc);
00053
00054 dns_rdataset_init(&rdataset);
00055 dns_rdataset_init(&sigrdataset);
00056
00057 result = dns_test_begin(NULL, ISC_FALSE);
00058 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00059
00060 rdataset.ttl = 900;
00061 sigrdataset.ttl = 1000;
00062 rrsig.timeexpire = ttltimeexpire;
00063 rrsig.originalttl = 1000;
00064
00065 dns_rdataset_trimttl(&rdataset, &sigrdataset, &rrsig, ttltimenow,
00066 ISC_TRUE);
00067 ATF_REQUIRE_EQ(rdataset.ttl, 800);
00068 ATF_REQUIRE_EQ(sigrdataset.ttl, 800);
00069
00070 rdataset.ttl = 900;
00071 sigrdataset.ttl = 1000;
00072 rrsig.timeexpire = ttltimenow - 200;
00073 rrsig.originalttl = 1000;
00074
00075 dns_rdataset_trimttl(&rdataset, &sigrdataset, &rrsig, ttltimenow,
00076 ISC_TRUE);
00077 ATF_REQUIRE_EQ(rdataset.ttl, 120);
00078 ATF_REQUIRE_EQ(sigrdataset.ttl, 120);
00079
00080 rdataset.ttl = 900;
00081 sigrdataset.ttl = 1000;
00082 rrsig.timeexpire = ttltimenow - 200;
00083 rrsig.originalttl = 1000;
00084
00085 dns_rdataset_trimttl(&rdataset, &sigrdataset, &rrsig, ttltimenow,
00086 ISC_FALSE);
00087 ATF_REQUIRE_EQ(rdataset.ttl, 0);
00088 ATF_REQUIRE_EQ(sigrdataset.ttl, 0);
00089
00090 sigrdataset.ttl = 900;
00091 rdataset.ttl = 1000;
00092 rrsig.timeexpire = ttltimeexpire;
00093 rrsig.originalttl = 1000;
00094
00095 dns_rdataset_trimttl(&rdataset, &sigrdataset, &rrsig, ttltimenow,
00096 ISC_TRUE);
00097 ATF_REQUIRE_EQ(rdataset.ttl, 800);
00098 ATF_REQUIRE_EQ(sigrdataset.ttl, 800);
00099
00100 sigrdataset.ttl = 900;
00101 rdataset.ttl = 1000;
00102 rrsig.timeexpire = ttltimenow - 200;
00103 rrsig.originalttl = 1000;
00104
00105 dns_rdataset_trimttl(&rdataset, &sigrdataset, &rrsig, ttltimenow,
00106 ISC_TRUE);
00107 ATF_REQUIRE_EQ(rdataset.ttl, 120);
00108 ATF_REQUIRE_EQ(sigrdataset.ttl, 120);
00109
00110 sigrdataset.ttl = 900;
00111 rdataset.ttl = 1000;
00112 rrsig.timeexpire = ttltimenow - 200;
00113 rrsig.originalttl = 1000;
00114
00115 dns_rdataset_trimttl(&rdataset, &sigrdataset, &rrsig, ttltimenow,
00116 ISC_FALSE);
00117 ATF_REQUIRE_EQ(rdataset.ttl, 0);
00118 ATF_REQUIRE_EQ(sigrdataset.ttl, 0);
00119
00120 dns_test_end();
00121 }
00122
00123
00124
00125
00126 ATF_TP_ADD_TCS(tp) {
00127 ATF_TP_ADD_TC(tp, trimttl);
00128
00129 return (atf_no_error());
00130 }
00131