A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
examples-as-tests-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Lawrence Livermore National Laboratory
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
18
*/
19
20
#include "ns3/example-as-test.h"
21
#include "ns3/system-path.h"
22
23
#include <vector>
24
25
using namespace
ns3
;
26
39
namespace
ns3
40
{
41
42
namespace
tests
43
{
44
49
class
CommandLineExampleTestCase
:
public
ExampleAsTestCase
50
{
51
public
:
55
CommandLineExampleTestCase
();
56
60
~CommandLineExampleTestCase
()
override
;
61
70
std::string
GetPostProcessingCommand
()
const override
;
71
};
72
73
CommandLineExampleTestCase::CommandLineExampleTestCase
()
74
:
ExampleAsTestCase
(
"core-example-command-line"
,
75
"command-line-example"
,
76
NS_TEST_SOURCEDIR,
77
"--intArg=2 --boolArg --strArg=deadbeef --anti=t "
78
"--cbArg=beefstew --charbuf=stewmeat 3 4 extraOne extraTwo"
)
79
{
80
}
81
82
CommandLineExampleTestCase::~CommandLineExampleTestCase
()
83
{
84
}
85
86
std::string
87
CommandLineExampleTestCase::GetPostProcessingCommand
()
const
88
{
89
// Delete the line that starts with Program Version:
90
return
std::string(R
"__(| sed -e "/^Program Version:.*$/d")__");
91
}
92
97
class
ExamplesAsTestsTestSuite
:
public
TestSuite
98
{
99
public
:
100
ExamplesAsTestsTestSuite
();
101
};
102
103
ExamplesAsTestsTestSuite::ExamplesAsTestsTestSuite
()
104
:
TestSuite
(
"examples-as-tests-test-suite"
, UNIT)
105
{
106
AddTestCase
(
107
new
ExampleAsTestCase
(
"core-example-simulator"
,
"sample-simulator"
, NS_TEST_SOURCEDIR));
108
109
AddTestCase
(
new
ExampleAsTestCase
(
"core-example-sample-random-variable"
,
110
"sample-random-variable"
,
111
NS_TEST_SOURCEDIR));
112
113
AddTestCase
(
new
CommandLineExampleTestCase
());
114
}
115
121
static
ExamplesAsTestsTestSuite
g_examplesAsTestsTestSuite
;
122
131
static
ExampleAsTestSuite
g_exampleCommandLineTest
(
"core-example-simulator"
,
132
"sample-simulator"
,
133
NS_TEST_SOURCEDIR);
134
135
}
// namespace tests
136
137
}
// namespace ns3
ns3::ExampleAsTestCase
Execute an example program as a test, by comparing the output to a reference file.
Definition:
example-as-test.h:49
ns3::ExampleAsTestSuite
Execute an example program as a test suite.
Definition:
example-as-test.h:210
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::tests::CommandLineExampleTestCase
Run command line example as a test case.
Definition:
examples-as-tests-test-suite.cc:50
ns3::tests::CommandLineExampleTestCase::CommandLineExampleTestCase
CommandLineExampleTestCase()
Default constructor.
Definition:
examples-as-tests-test-suite.cc:73
ns3::tests::CommandLineExampleTestCase::GetPostProcessingCommand
std::string GetPostProcessingCommand() const override
Override this function to filter the version string from the command-line-example output.
Definition:
examples-as-tests-test-suite.cc:87
ns3::tests::CommandLineExampleTestCase::~CommandLineExampleTestCase
~CommandLineExampleTestCase() override
Destructor.
Definition:
examples-as-tests-test-suite.cc:82
ns3::tests::ExamplesAsTestsTestSuite
Run examples as tests, checking stdout for regressions.
Definition:
examples-as-tests-test-suite.cc:98
ns3::tests::ExamplesAsTestsTestSuite::ExamplesAsTestsTestSuite
ExamplesAsTestsTestSuite()
Definition:
examples-as-tests-test-suite.cc:103
ns3::tests::g_examplesAsTestsTestSuite
static ExamplesAsTestsTestSuite g_examplesAsTestsTestSuite
ExampleAsTestsTestSuite instance variable.
Definition:
examples-as-tests-test-suite.cc:121
ns3::tests::g_exampleCommandLineTest
static ExampleAsTestSuite g_exampleCommandLineTest("core-example-simulator", "sample-simulator", NS_TEST_SOURCEDIR)
ExampleTestSuite instance variables.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
core
test
examples-as-tests-test-suite.cc
Generated on Sun Mar 3 2024 17:10:56 for ns-3 by
1.9.1