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
build-profile-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 LLNL
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
7
*/
8
9
#include "ns3/build-profile.h"
10
#include "ns3/test.h"
11
12
/**
13
* @file
14
* @ingroup core-tests
15
* @ingroup debugging
16
* @ingroup build-profile-tests
17
* NS_BUILD_PROFILE macros test suite.
18
*/
19
20
/**
21
* @ingroup core-tests
22
* @defgroup build-profile-tests NS_BUILD_PROFILE macros test suite
23
*/
24
25
namespace
ns3
26
{
27
28
namespace
tests
29
{
30
31
/**
32
* @ingroup build-profile-tests
33
* Build profile test
34
*/
35
class
BuildProfileTestCase
:
public
TestCase
36
{
37
public
:
38
BuildProfileTestCase
();
39
40
~BuildProfileTestCase
()
override
41
{
42
}
43
44
private
:
45
void
DoRun
()
override
;
46
};
47
48
BuildProfileTestCase::BuildProfileTestCase
()
49
:
TestCase
(
"Check build profile macros"
)
50
{
51
}
52
53
void
54
BuildProfileTestCase::DoRun
()
55
{
56
int
i = 0;
57
int
j = 0;
58
59
#ifdef NS3_BUILD_PROFILE_DEBUG
60
std::cout <<
GetName
() <<
": running in build profile debug"
<< std::endl;
61
NS_BUILD_DEBUG
(++i; ++j);
62
#elif NS3_BUILD_PROFILE_RELEASE
63
std::cout <<
GetName
() <<
": running in build profile release"
<< std::endl;
64
NS_BUILD_RELEASE
(++i; ++j);
65
#elif NS3_BUILD_PROFILE_OPTIMIZED
66
std::cout <<
GetName
() <<
": running in build profile optimized"
<< std::endl;
67
NS_BUILD_OPTIMIZED
(++i; ++j);
68
#else
69
NS_TEST_ASSERT_MSG_EQ
(0, 1,
": no build profile case executed"
);
70
#endif
71
72
if
(i == 1)
73
{
74
std::cout <<
"build profile executed first statement."
<< std::endl;
75
}
76
NS_TEST_ASSERT_MSG_EQ
(i, 1,
"build profile failed to execute first statement"
);
77
if
(j == 1)
78
{
79
std::cout <<
"build profile executed second statement."
<< std::endl;
80
}
81
NS_TEST_ASSERT_MSG_EQ
(j, 1,
"build profile failed to execute second statement"
);
82
}
83
84
/**
85
* @ingroup build-profile-tests
86
* Build profile test suite
87
*/
88
class
BuildProfileTestSuite
:
public
TestSuite
89
{
90
public
:
91
BuildProfileTestSuite
();
92
};
93
94
BuildProfileTestSuite::BuildProfileTestSuite
()
95
:
TestSuite
(
"build-profile"
)
96
{
97
AddTestCase
(
new
BuildProfileTestCase
);
98
}
99
100
/**
101
* @ingroup build-profile-tests
102
* BuildProfileTestSuite instance variable.
103
*/
104
static
BuildProfileTestSuite
g_BuildProfileTestSuite
;
105
106
}
// namespace tests
107
108
}
// namespace ns3
ns3::TestCase
encapsulates test code
Definition
test.h:1050
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::TestCase::GetName
std::string GetName() const
Definition
test.cc:367
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::tests::BuildProfileTestCase
Build profile test.
Definition
build-profile-test-suite.cc:36
ns3::tests::BuildProfileTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
build-profile-test-suite.cc:54
ns3::tests::BuildProfileTestCase::BuildProfileTestCase
BuildProfileTestCase()
Definition
build-profile-test-suite.cc:48
ns3::tests::BuildProfileTestCase::~BuildProfileTestCase
~BuildProfileTestCase() override
Definition
build-profile-test-suite.cc:40
ns3::tests::BuildProfileTestSuite
Build profile test suite.
Definition
build-profile-test-suite.cc:89
ns3::tests::BuildProfileTestSuite::BuildProfileTestSuite
BuildProfileTestSuite()
Definition
build-profile-test-suite.cc:94
ns3::tests::g_BuildProfileTestSuite
static BuildProfileTestSuite g_BuildProfileTestSuite
BuildProfileTestSuite instance variable.
Definition
build-profile-test-suite.cc:104
NS_BUILD_OPTIMIZED
#define NS_BUILD_OPTIMIZED(code)
Execute a code snippet in optimized builds.
Definition
build-profile.h:71
NS_BUILD_RELEASE
#define NS_BUILD_RELEASE(code)
Execute a code snippet in release builds.
Definition
build-profile.h:60
NS_BUILD_DEBUG
#define NS_BUILD_DEBUG(code)
Execute a code snippet in debug builds.
Definition
build-profile.h:49
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:134
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 Dec 1 2024 18:20:37 for ns-3 by
1.11.0