A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
examples-as-tests-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Lawrence Livermore National Laboratory
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
7
*/
8
9
#include "ns3/example-as-test.h"
10
#include "ns3/system-path.h"
11
12
#include <vector>
13
14
using namespace
ns3
;
15
16
/**
17
* \file
18
* \ingroup examples-as-tests
19
* Examples-as-tests test suite
20
*/
21
22
/**
23
* \ingroup core-tests
24
* \ingroup testing
25
* \defgroup examples-as-tests Examples as tests test suite
26
*
27
* Runs several examples as tests in order to test ExampleAsTestSuite and ExampleAsTestCase.
28
*/
29
namespace
ns3
30
{
31
32
namespace
tests
33
{
34
35
/**
36
* \ingroup examples-as-tests
37
* Run command line example as a test case
38
*/
39
class
CommandLineExampleTestCase
:
public
ExampleAsTestCase
40
{
41
public
:
42
/**
43
* Default constructor
44
*/
45
CommandLineExampleTestCase
();
46
47
/**
48
* Destructor
49
*/
50
~CommandLineExampleTestCase
()
override
;
51
52
/**
53
* Override this function to filter the version string from
54
* the command-line-example output.
55
* Since the version changes each time a commit is made it shouldn't
56
* be tested as part of the command-line-example output.
57
*
58
* \returns The string of post-processing commands.
59
*/
60
std::string
GetPostProcessingCommand
()
const override
;
61
};
62
63
CommandLineExampleTestCase::CommandLineExampleTestCase
()
64
:
ExampleAsTestCase
(
"core-example-command-line"
,
65
"command-line-example"
,
66
NS_TEST_SOURCEDIR,
67
"--intArg=2 --boolArg --strArg=deadbeef --anti=t "
68
"--cbArg=beefstew --charbuf=stewmeat 3 4 extraOne extraTwo"
)
69
{
70
}
71
72
CommandLineExampleTestCase::~CommandLineExampleTestCase
()
73
{
74
}
75
76
std::string
77
CommandLineExampleTestCase::GetPostProcessingCommand
()
const
78
{
79
// Delete the line that starts with Program Version:
80
return
std::string(R
"__(| sed -e "/^Program Version:.*$/d")__");
81
}
82
83
/**
84
* \ingroup examples-as-tests
85
* Run examples as tests, checking stdout for regressions.
86
*/
87
class
ExamplesAsTestsTestSuite
:
public
TestSuite
88
{
89
public
:
90
ExamplesAsTestsTestSuite
();
91
};
92
93
ExamplesAsTestsTestSuite::ExamplesAsTestsTestSuite
()
94
:
TestSuite
(
"examples-as-tests-test-suite"
,
Type
::UNIT)
95
{
96
AddTestCase
(
97
new
ExampleAsTestCase
(
"core-example-simulator"
,
"sample-simulator"
, NS_TEST_SOURCEDIR));
98
99
AddTestCase
(
new
ExampleAsTestCase
(
"core-example-sample-random-variable"
,
100
"sample-random-variable"
,
101
NS_TEST_SOURCEDIR));
102
103
AddTestCase
(
new
CommandLineExampleTestCase
());
104
}
105
106
/**
107
* \ingroup examples-as-tests
108
* ExampleAsTestsTestSuite instance variable.
109
* Tests multiple examples in a single TestSuite using AddTestCase to add the examples to the suite.
110
*/
111
static
ExamplesAsTestsTestSuite
g_examplesAsTestsTestSuite
;
112
113
/**
114
* \ingroup examples-as-tests
115
* ExampleTestSuite instance variables.
116
*
117
* Tests ExampleTestSuite which runs a single example as test suite as specified in constructor
118
* arguments.
119
*/
120
121
static
ExampleAsTestSuite
g_exampleCommandLineTest
(
"core-example-simulator"
,
122
"sample-simulator"
,
123
NS_TEST_SOURCEDIR);
124
125
}
// namespace tests
126
127
}
// namespace ns3
ns3::ExampleAsTestCase
Execute an example program as a test, by comparing the output to a reference file.
Definition
example-as-test.h:38
ns3::ExampleAsTestSuite
Execute an example program as a test suite.
Definition
example-as-test.h:199
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
ns3::tests::CommandLineExampleTestCase
Run command line example as a test case.
Definition
examples-as-tests-test-suite.cc:40
ns3::tests::CommandLineExampleTestCase::CommandLineExampleTestCase
CommandLineExampleTestCase()
Default constructor.
Definition
examples-as-tests-test-suite.cc:63
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:77
ns3::tests::CommandLineExampleTestCase::~CommandLineExampleTestCase
~CommandLineExampleTestCase() override
Destructor.
Definition
examples-as-tests-test-suite.cc:72
ns3::tests::ExamplesAsTestsTestSuite
Run examples as tests, checking stdout for regressions.
Definition
examples-as-tests-test-suite.cc:88
ns3::tests::ExamplesAsTestsTestSuite::ExamplesAsTestsTestSuite
ExamplesAsTestsTestSuite()
Definition
examples-as-tests-test-suite.cc:93
ns3::tests::g_examplesAsTestsTestSuite
static ExamplesAsTestsTestSuite g_examplesAsTestsTestSuite
ExampleAsTestsTestSuite instance variable.
Definition
examples-as-tests-test-suite.cc:111
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 Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0