A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
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
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2015 LLNL
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
#include "ns3/build-profile.h"
22
#include "ns3/test.h"
23
37
namespace
ns3
{
38
39
namespace
tests
{
40
41
46
class
BuildProfileTestCase
:
public
TestCase
47
{
48
public
:
49
BuildProfileTestCase
();
50
virtual
~BuildProfileTestCase
()
51
{}
52
53
private
:
54
virtual
void
DoRun
(
void
);
55
};
56
57
BuildProfileTestCase::BuildProfileTestCase
(
void
)
58
:
TestCase
(
"Check build profile macros"
)
59
{}
60
61
void
62
BuildProfileTestCase::DoRun
(
void
)
63
{
64
int
i = 0;
65
int
j = 0;
66
67
/* *NS_CHECK_STYLE_OFF* */
68
#ifdef NS3_BUILD_PROFILE_DEBUG
69
std::cout <<
GetName
() <<
": running in build profile debug"
<< std::endl;
70
NS_BUILD_DEBUG
(++i; ++j);
71
#elif NS3_BUILD_PROFILE_RELEASE
72
std::cout <<
GetName
() <<
": running in build profile release"
<< std::endl;
73
NS_BUILD_RELEASE
(++i; ++j);
74
#elif NS3_BUILD_PROFILE_OPTIMIZED
75
std::cout <<
GetName
() <<
": running in build profile optimized"
<< std::endl;
76
NS_BUILD_OPTIMIZED
(++i; ++j);
77
#else
78
NS_TEST_ASSERT_MSG_EQ
(0, 1,
": no build profile case executed"
);
79
#endif
80
/* *NS_CHECK_STYLE_ON* */
81
82
if
(i == 1)
83
{
84
std::cout <<
"build profile executed first statement."
<< std::endl;
85
}
86
NS_TEST_ASSERT_MSG_EQ
(i, 1,
87
"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,
93
"build profile failed to execute second statement"
);
94
}
95
100
class
BuildProfileTestSuite
:
public
TestSuite
101
{
102
public
:
103
BuildProfileTestSuite
();
104
};
105
106
BuildProfileTestSuite::BuildProfileTestSuite
()
107
:
TestSuite
(
"build-profile"
)
108
{
109
AddTestCase
(
new
BuildProfileTestCase
);
110
}
111
116
static
BuildProfileTestSuite
g_BuildProfileTestSuite
;
117
118
119
}
// namespace tests
120
121
}
// namespace ns3
ns3::TestCase
encapsulates test code
Definition:
test.h:994
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3::TestCase::GetName
std::string GetName(void) const
Definition:
test.cc:370
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1188
ns3::tests::BuildProfileTestCase
Build profile test.
Definition:
build-profile-test-suite.cc:47
ns3::tests::BuildProfileTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
build-profile-test-suite.cc:62
ns3::tests::BuildProfileTestCase::~BuildProfileTestCase
virtual ~BuildProfileTestCase()
Definition:
build-profile-test-suite.cc:50
ns3::tests::BuildProfileTestCase::BuildProfileTestCase
BuildProfileTestCase()
Definition:
build-profile-test-suite.cc:57
ns3::tests::BuildProfileTestSuite
Build profile test suite.
Definition:
build-profile-test-suite.cc:101
ns3::tests::BuildProfileTestSuite::BuildProfileTestSuite
BuildProfileTestSuite()
Definition:
build-profile-test-suite.cc:106
ns3::tests::g_BuildProfileTestSuite
static BuildProfileTestSuite g_BuildProfileTestSuite
BuildProfileTestSuite instance variable.
Definition:
build-profile-test-suite.cc:116
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:141
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
test-ns3.tests
tests
Definition:
test-ns3.py:2134
src
core
test
build-profile-test-suite.cc
Generated on Tue Feb 6 2024 19:21:17 for ns-3 by
1.9.1