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
rocketfuel-topology-reader-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Hajime Tazaki
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
7
*/
8
9
//-----------------------------------------------------------------------------
10
// Unit tests
11
//-----------------------------------------------------------------------------
12
13
#include "ns3/abort.h"
14
#include "ns3/attribute.h"
15
#include "ns3/log.h"
16
#include "ns3/node-container.h"
17
#include "ns3/object-factory.h"
18
#include "ns3/rocketfuel-topology-reader.h"
19
#include "ns3/simulator.h"
20
#include "ns3/test.h"
21
22
using namespace
ns3
;
23
24
/**
25
* \defgroup topology-test Topology module tests
26
* \ingroup topology
27
* \ingroup tests
28
*/
29
30
/**
31
* \file
32
* \ingroup topology-test
33
* ns3::RockefuelTopologyReader test suite.
34
*/
35
36
/**
37
* \ingroup topology-test
38
39
* \brief Rocketfuel Topology Reader Weights Test
40
*/
41
class
RocketfuelTopologyReaderWeightsTest
:
public
TestCase
42
{
43
public
:
44
RocketfuelTopologyReaderWeightsTest
();
45
46
private
:
47
void
DoRun
()
override
;
48
};
49
50
RocketfuelTopologyReaderWeightsTest::RocketfuelTopologyReaderWeightsTest
()
51
:
TestCase
(
"RocketfuelTopologyReaderWeightsTest"
)
52
{
53
}
54
55
void
56
RocketfuelTopologyReaderWeightsTest::DoRun
()
57
{
58
Ptr<RocketfuelTopologyReader>
inFile;
59
NodeContainer
nodes
;
60
61
std::string input(
"./src/topology-read/examples/RocketFuel_toposample_1239_weights.txt"
);
62
63
inFile =
CreateObject<RocketfuelTopologyReader>
();
64
inFile->SetFileName(input);
65
66
if
(inFile)
67
{
68
nodes
= inFile->Read();
69
}
70
71
NS_TEST_ASSERT_MSG_NE
(
nodes
.
GetN
(), 0,
"Problems reading node information the topology file.."
);
72
73
NS_TEST_ASSERT_MSG_NE
(inFile->LinksSize(), 0,
"Problems reading the topology file."
);
74
75
NS_TEST_EXPECT_MSG_EQ
(
nodes
.
GetN
(), 315,
"nodes"
);
76
NS_TEST_EXPECT_MSG_EQ
(inFile->LinksSize(), 972,
"links"
);
77
Simulator::Destroy
();
78
}
79
80
/**
81
* \ingroup topology-test
82
* \brief Rocketfuel Topology Reader Maps Test
83
*/
84
class
RocketfuelTopologyReaderMapsTest
:
public
TestCase
85
{
86
public
:
87
RocketfuelTopologyReaderMapsTest
();
88
89
private
:
90
void
DoRun
()
override
;
91
};
92
93
RocketfuelTopologyReaderMapsTest::RocketfuelTopologyReaderMapsTest
()
94
:
TestCase
(
"RocketfuelTopologyReaderMapsTest"
)
95
{
96
}
97
98
void
99
RocketfuelTopologyReaderMapsTest::DoRun
()
100
{
101
Ptr<RocketfuelTopologyReader>
inFile;
102
NodeContainer
nodes
;
103
104
std::string input(
"./src/topology-read/examples/RocketFuel_sample_4755.r0.cch_maps.txt"
);
105
106
inFile =
CreateObject<RocketfuelTopologyReader>
();
107
inFile->SetFileName(input);
108
109
if
(inFile)
110
{
111
nodes
= inFile->Read();
112
}
113
114
NS_TEST_ASSERT_MSG_NE
(
nodes
.
GetN
(), 0,
"Problems reading node information the topology file.."
);
115
116
NS_TEST_ASSERT_MSG_NE
(inFile->LinksSize(), 0,
"Problems reading the topology file."
);
117
118
NS_TEST_EXPECT_MSG_EQ
(
nodes
.
GetN
(), 12,
"nodes"
);
119
NS_TEST_EXPECT_MSG_EQ
(inFile->LinksSize(), 24,
"links"
);
120
Simulator::Destroy
();
121
}
122
123
/**
124
* \ingroup topology-test
125
*
126
* \brief Rocketfuel Topology Reader TestSuite
127
*/
128
class
RocketfuelTopologyReaderTestSuite
:
public
TestSuite
129
{
130
public
:
131
RocketfuelTopologyReaderTestSuite
();
132
133
private
:
134
};
135
136
RocketfuelTopologyReaderTestSuite::RocketfuelTopologyReaderTestSuite
()
137
:
TestSuite
(
"rocketfuel-topology-reader"
,
Type
::UNIT)
138
{
139
AddTestCase
(
new
RocketfuelTopologyReaderWeightsTest
(), TestCase::Duration::QUICK);
140
AddTestCase
(
new
RocketfuelTopologyReaderMapsTest
(), TestCase::Duration::QUICK);
141
}
142
143
/**
144
* \ingroup topology-test
145
* Static variable for test initialization
146
*/
147
static
RocketfuelTopologyReaderTestSuite
g_rocketfuelTopologyReaderTestSuite
;
RocketfuelTopologyReaderMapsTest
Rocketfuel Topology Reader Maps Test.
Definition
rocketfuel-topology-reader-test-suite.cc:85
RocketfuelTopologyReaderMapsTest::RocketfuelTopologyReaderMapsTest
RocketfuelTopologyReaderMapsTest()
Definition
rocketfuel-topology-reader-test-suite.cc:93
RocketfuelTopologyReaderMapsTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
rocketfuel-topology-reader-test-suite.cc:99
RocketfuelTopologyReaderTestSuite
Rocketfuel Topology Reader TestSuite.
Definition
rocketfuel-topology-reader-test-suite.cc:129
RocketfuelTopologyReaderTestSuite::RocketfuelTopologyReaderTestSuite
RocketfuelTopologyReaderTestSuite()
Definition
rocketfuel-topology-reader-test-suite.cc:136
RocketfuelTopologyReaderWeightsTest
Rocketfuel Topology Reader Weights Test.
Definition
rocketfuel-topology-reader-test-suite.cc:42
RocketfuelTopologyReaderWeightsTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
rocketfuel-topology-reader-test-suite.cc:56
RocketfuelTopologyReaderWeightsTest::RocketfuelTopologyReaderWeightsTest
RocketfuelTopologyReaderWeightsTest()
Definition
rocketfuel-topology-reader-test-suite.cc:50
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
ns3::NodeContainer::GetN
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
Definition
node-container.cc:61
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition
simulator.cc:131
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::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
NS_TEST_EXPECT_MSG_EQ
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition
test.h:241
NS_TEST_ASSERT_MSG_NE
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Definition
test.h:554
g_rocketfuelTopologyReaderTestSuite
static RocketfuelTopologyReaderTestSuite g_rocketfuelTopologyReaderTestSuite
Static variable for test initialization.
Definition
rocketfuel-topology-reader-test-suite.cc:147
nodes
NodeContainer nodes
Definition
lr-wpan-bootstrap.cc:43
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
topology-read
test
rocketfuel-topology-reader-test-suite.cc
Generated on Mon Nov 4 2024 19:38:07 for ns-3 by
1.11.0