]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2573] defined MasterLoader::getRRCount().
authorJINMEI Tatuya <jinmei@isc.org>
Fri, 11 Jan 2013 23:48:14 +0000 (15:48 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Sat, 12 Jan 2013 04:44:42 +0000 (20:44 -0800)
src/lib/dns/master_loader.cc
src/lib/dns/master_loader.h
src/lib/dns/tests/master_loader_unittest.cc

index 400db43ea274715aa831b9f001e54591b91ccedf..bf093ef00052f71a7e8b84bb97b1d691a3f54a52 100644 (file)
@@ -76,7 +76,8 @@ public:
         previous_name_(false),
         complete_(false),
         seen_error_(false),
-        warn_rfc1035_ttl_(true)
+        warn_rfc1035_ttl_(true),
+        rr_count_(0)
     {}
 
     void pushSource(const std::string& filename, const Name& current_origin) {
@@ -418,12 +419,14 @@ private:
     vector<IncludeInfo> include_info_;
     bool previous_name_; // True if there was a previous name in this file
                          // (false at the beginning or after an $INCLUDE line)
+
 public:
     bool complete_;             // All work done.
     bool seen_error_;           // Was there at least one error during the
                                 // load?
     bool warn_rfc1035_ttl_;     // should warn if implicit TTL determination
                                 // from the previous RR is used.
+    size_t rr_count_;    // number of RRs successfully loaded
 };
 
 // A helper method of loadIncremental, parsing the first token of a new line.
@@ -554,6 +557,7 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
                               rdata);
                 // Good, we loaded another one
                 ++count;
+                ++rr_count_;
             } else {
                 seen_error_ = true;
                 if (!many_errors_) {
@@ -630,5 +634,10 @@ MasterLoader::loadedSucessfully() const {
     return (impl_->complete_ && !impl_->seen_error_);
 }
 
+size_t
+MasterLoader::getRRCount() const {
+    return (impl_->rr_count_);
+}
+
 } // end namespace dns
 } // end namespace isc
index 9d8a75552aa2c15bf2359c239c7e374837725340..6a9f4136a050340d1937079626845aaa2b1e3b6d 100644 (file)
@@ -142,6 +142,10 @@ public:
     ///     finishing the load.
     bool loadedSucessfully() const;
 
+    size_t getRRCount() const;
+    size_t getSize() const;
+    size_t getPosition() const;
+
 private:
     class MasterLoaderImpl;
     MasterLoaderImpl* impl_;
@@ -151,3 +155,7 @@ private:
 } // end namespace isc
 
 #endif // MASTER_LOADER_H
+
+// Local Variables:
+// mode: c++
+// End:
index 051c6625cd15e421c02dfbbe31c310747926df9a..b3db65060fd1e9e8b2022815931cfcf8e467cdd2 100644 (file)
@@ -153,11 +153,13 @@ TEST_F(MasterLoaderTest, basicLoad) {
               RRClass::IN(), MasterLoader::MANY_ERRORS);
 
     EXPECT_FALSE(loader_->loadedSucessfully());
+    EXPECT_EQ(0, loader_->getRRCount());
     loader_->load();
     EXPECT_TRUE(loader_->loadedSucessfully());
 
     EXPECT_TRUE(errors_.empty());
     EXPECT_TRUE(warnings_.empty());
+    EXPECT_EQ(4, loader_->getRRCount());
 
     checkBasicRRs();
 }
@@ -260,7 +262,7 @@ TEST_F(MasterLoaderTest, popAfterError) {
     const string include_str = "$include " TEST_DATA_SRCDIR
         "/broken.zone\nwww 3600 IN AAAA 2001:db8::1\n";
     stringstream ss(include_str);
-    // We don't test without MANY_ERRORS, we want to see what happens
+    // We perform the test with MANY_ERRORS, we want to see what happens
     // after the error.
     setLoader(ss, Name("example.org."), RRClass::IN(),
               MasterLoader::MANY_ERRORS);
@@ -269,6 +271,7 @@ TEST_F(MasterLoaderTest, popAfterError) {
     EXPECT_FALSE(loader_->loadedSucessfully());
     EXPECT_EQ(1, errors_.size()); // For the broken RR
     EXPECT_EQ(1, warnings_.size()); // For missing EOLN
+    EXPECT_EQ(1, loader_->getRRCount()); // broken RR shouldn't be counted
 
     // The included file doesn't contain anything usable, but the
     // line after the include should be there.