Browse Source

[1960] Differentiate program exit codes.

Marcin Siodelski 12 years ago
parent
commit
861b389131

+ 0 - 1
tests/tools/perfdhcp/command_options.cc

@@ -83,7 +83,6 @@ CommandOptions::reset() {
     wrapped_.clear();
     server_name_.clear();
     generateDuidTemplate();
-    commandline_.clear();
 }
 
 void

+ 0 - 2
tests/tools/perfdhcp/command_options.h

@@ -455,8 +455,6 @@ private:
     std::string wrapped_;
     /// Server name specified as last argument of command line.
     std::string server_name_;
-    /// Entire command line as typed in by the user.
-    std::string command_line_;
 };
 
 } // namespace perfdhcp

+ 10 - 5
tests/tools/perfdhcp/main.cc

@@ -26,25 +26,30 @@ using namespace isc::perfdhcp;
 int
 main(int argc, char* argv[]) {
     CommandOptions& command_options = CommandOptions::instance();
+    std::string diags(command_options.getDiags());
+    int ret_code = 0;
     try {
         command_options.parse(argc, argv);
     } catch(isc::Exception& e) {
+        ret_code = 1;
         std::cout << "Error parsing command line options: "
                   << e.what() << std::endl;
         command_options.usage();
-        return(1);
+        if (diags.find('e') != std::string::npos) {
+            std::cout << "Fatal error" << std::endl;
+        }
+        return (ret_code);
     }
     try{
         TestControl& test_control = TestControl::instance();
-        test_control.run();
+        ret_code =  test_control.run();
     } catch (isc::Exception& e) {
+        ret_code = 1;
         std::cout << "Error running perfdhcp: " << e.what() << std::endl;
-        std::string diags(command_options.getDiags());
         if (diags.find('e') != std::string::npos) {
             std::cout << "Fatal error" << std::endl;
         }
-        return(1);
     }
-    return(0);
+    return (ret_code);
 }
 

+ 10 - 1
tests/tools/perfdhcp/test_control.cc

@@ -905,7 +905,7 @@ TestControl::reset() {
     interrupted_ = false;
 }
 
-void
+int
 TestControl::run() {
     // Reset singleton state before test starts.
     reset();
@@ -1057,6 +1057,15 @@ TestControl::run() {
     if (testDiags('e')) {
         std::cout << "Interrupted" << std::endl;
     }
+
+    int ret_code = 0;
+    // Check if any packet drops occured.
+    if (options.getIpVersion() == 4) {
+        ret_code = stats_mgr4_->droppedPackets() ? 3 : 0;
+    } else if (options.getIpVersion() == 6)  {
+        ret_code = stats_mgr6_->droppedPackets() ? 3 : 0;
+    }
+    return (ret_code);
 }
 
 void

+ 3 - 1
tests/tools/perfdhcp/test_control.h

@@ -199,7 +199,9 @@ public:
     ///
     /// \throw isc::InvalidOperation if command line options are not parsed.
     /// \throw isc::Unexpected if internal Test Controler error occured.
-    void run();
+    /// \return error_code, 3 if number of received packets is not equal
+    /// to number of sent packets, 0 if everything is ok.
+    int run();
 
     /// \brief Set new transaction id generator.
     ///