A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
build-profile-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 LLNL
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/build-profile.h"
21
#include "ns3/test.h"
22
36
namespace
ns3
37
{
38
39
namespace
tests
40
{
41
46
class
BuildProfileTestCase
:
public
TestCase
47
{
48
public
:
49
BuildProfileTestCase
();
50
51
~BuildProfileTestCase
()
override
52
{
53
}
54
55
private
:
56
void
DoRun
()
override
;
57
};
58
59
BuildProfileTestCase::BuildProfileTestCase
()
60
:
TestCase
(
"Check build profile macros"
)
61
{
62
}
63
64
void
65
BuildProfileTestCase::DoRun
()
66
{
67
int
i = 0;
68
int
j = 0;
69
70
#ifdef NS3_BUILD_PROFILE_DEBUG
71
std::cout <<
GetName
() <<
": running in build profile debug"
<< std::endl;
72
NS_BUILD_DEBUG
(++i; ++j);
73
#elif NS3_BUILD_PROFILE_RELEASE
74
std::cout <<
GetName
() <<
": running in build profile release"
<< std::endl;
75
NS_BUILD_RELEASE
(++i; ++j);
76
#elif NS3_BUILD_PROFILE_OPTIMIZED
77
std::cout <<
GetName
() <<
": running in build profile optimized"
<< std::endl;
78
NS_BUILD_OPTIMIZED
(++i; ++j);
79
#else
80
NS_TEST_ASSERT_MSG_EQ
(0, 1,
": no build profile case executed"
);
81
#endif
82
83
if
(i == 1)
84
{
85
std::cout <<
"build profile executed first statement."
<< std::endl;
86
}
87
NS_TEST_ASSERT_MSG_EQ
(i, 1,
"build profile failed to execute first statement"
);
88
if
(j == 1)
89
{
90
std::cout <<
"build profile executed second statement."
<< std::endl;
91
}
92
NS_TEST_ASSERT_MSG_EQ
(j, 1,
"build profile failed to execute second statement"
);
93
}
94
99
class
BuildProfileTestSuite
:
public
TestSuite
100
{
101
public
:
102
BuildProfileTestSuite
();
103
};
104
105
BuildProfileTestSuite::BuildProfileTestSuite
()
106
:
TestSuite
(
"build-profile"
)
107
{
108
AddTestCase
(
new
BuildProfileTestCase
);
109
}
110
115
static
BuildProfileTestSuite
g_BuildProfileTestSuite
;
116
117
}
// namespace tests
118
119
}
// namespace ns3
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestCase::GetName
std::string GetName() const
Definition:
test.cc:373
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::tests::BuildProfileTestCase
Build profile test.
Definition:
build-profile-test-suite.cc:47
ns3::tests::BuildProfileTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
build-profile-test-suite.cc:65
ns3::tests::BuildProfileTestCase::BuildProfileTestCase
BuildProfileTestCase()
Definition:
build-profile-test-suite.cc:59
ns3::tests::BuildProfileTestCase::~BuildProfileTestCase
~BuildProfileTestCase() override
Definition:
build-profile-test-suite.cc:51
ns3::tests::BuildProfileTestSuite
Build profile test suite.
Definition:
build-profile-test-suite.cc:100
ns3::tests::BuildProfileTestSuite::BuildProfileTestSuite
BuildProfileTestSuite()
Definition:
build-profile-test-suite.cc:105
ns3::tests::g_BuildProfileTestSuite
static BuildProfileTestSuite g_BuildProfileTestSuite
BuildProfileTestSuite instance variable.
Definition:
build-profile-test-suite.cc:115
NS_BUILD_OPTIMIZED
#define NS_BUILD_OPTIMIZED(code)
Execute a code snippet in optimized builds.
Definition:
build-profile.h:82
NS_BUILD_RELEASE
#define NS_BUILD_RELEASE(code)
Execute a code snippet in release builds.
Definition:
build-profile.h:71
NS_BUILD_DEBUG
#define NS_BUILD_DEBUG(code)
Execute a code snippet in debug builds.
Definition:
build-profile.h:60
NS_TEST_ASSERT_MSG_EQ
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition:
test.h:144
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
core
test
build-profile-test-suite.cc
Generated on Sun Mar 3 2024 17:10:56 for ns-3 by
1.9.1