A Discrete-Event Network Simulator
API
example-as-test.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 Lawrence Livermore National Laboratory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
19  */
20 
21 #ifndef NS3_EXAMPLE_AS_TEST_SUITE_H
22 #define NS3_EXAMPLE_AS_TEST_SUITE_H
23 
24 #include "ns3/test.h"
25 
26 #include <string>
27 
35 namespace ns3 {
36 
37 
50 {
51 public:
69  ExampleAsTestCase (const std::string name,
70  const std::string program,
71  const std::string dataDir,
72  const std::string args = "");
73 
75  virtual ~ExampleAsTestCase (void);
76 
83  virtual std::string GetCommandTemplate (void) const;
84 
94  virtual std::string GetPostProcessingCommand (void) const;
95 
96  // Inherited
97  virtual void DoRun (void);
98 
99 protected:
100  std::string m_program;
101  std::string m_dataDir;
102  std::string m_args;
104 }; // class ExampleAsTestCase
105 
197 {
198 public:
204  ExampleAsTestSuite (const std::string name,
205  const std::string program,
206  const std::string dataDir,
207  const std::string args = "",
208  const TestDuration duration = QUICK);
209 }; // class ExampleAsTestSuite
210 
211 
212 } // namespace ns3
213 
214 #endif /* NS3_EXAMPLE_TEST_SUITE_H */
Execute an example program as a test, by comparing the output to a reference file.
ExampleAsTestCase(const std::string name, const std::string program, const std::string dataDir, const std::string args="")
Constructor.
virtual std::string GetCommandTemplate(void) const
Customization point for more complicated patterns to invoke the example program.
virtual std::string GetPostProcessingCommand(void) const
Customization point for tests requiring post-processing of stdout.
std::string m_args
Any additional arguments to the program.
std::string m_dataDir
The source directory for the test.
virtual ~ExampleAsTestCase(void)
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::string m_program
The program to run.
Execute an example program as a test suite.
ExampleAsTestSuite(const std::string name, const std::string program, const std::string dataDir, const std::string args="", const TestDuration duration=QUICK)
Constructor.
encapsulates test code
Definition: test.h:994
TestDuration
How long the test takes to execute.
Definition: test.h:998
@ QUICK
Fast test.
Definition: test.h:999
A suite of tests to run.
Definition: test.h:1188
Every class exported by the ns3 library is enclosed in the ns3 namespace.