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
network-status-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018 University of Padova
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
/*
10
* This file includes testing for the following components:
11
* - EndDeviceStatus
12
* - GatewayStatus
13
* - NetworkStatus
14
*/
15
16
// Include headers of classes to test
17
#include "
utilities.h
"
18
19
#include "ns3/end-device-status.h"
20
#include "ns3/log.h"
21
#include "ns3/network-status.h"
22
23
// An essential include is test.h
24
#include "ns3/test.h"
25
26
using namespace
ns3
;
27
using namespace
lorawan;
28
29
NS_LOG_COMPONENT_DEFINE
(
"NetworkStatusTestSuite"
);
30
31
/**
32
* \ingroup lorawan
33
*
34
* It tests the constructor of the EndDeviceStatus class
35
*/
36
class
EndDeviceStatusTest
:
public
TestCase
37
{
38
public
:
39
EndDeviceStatusTest
();
//!< Default constructor
40
~EndDeviceStatusTest
()
override
;
//!< Destructor
41
42
private
:
43
void
DoRun
()
override
;
44
};
45
46
// Add some help text to this case to describe what it is intended to test
47
EndDeviceStatusTest::EndDeviceStatusTest
()
48
:
TestCase
(
"Verify correct behavior of the EndDeviceStatus object"
)
49
{
50
}
51
52
// Reminder that the test case should clean up after itself
53
EndDeviceStatusTest::~EndDeviceStatusTest
()
54
{
55
}
56
57
// This method is the pure virtual method from class TestCase that every
58
// TestCase must implement
59
void
60
EndDeviceStatusTest::DoRun
()
61
{
62
NS_LOG_DEBUG
(
"EndDeviceStatusTest"
);
63
64
// Create an EndDeviceStatus object
65
EndDeviceStatus
eds =
EndDeviceStatus
();
66
}
67
68
/**
69
* \ingroup lorawan
70
*
71
* It tests the function NetworkStatus::AddNode
72
*/
73
class
NetworkStatusTest
:
public
TestCase
74
{
75
public
:
76
NetworkStatusTest
();
//!< Default constructor
77
~NetworkStatusTest
()
override
;
//!< Destructor
78
79
private
:
80
void
DoRun
()
override
;
81
};
82
83
// Add some help text to this case to describe what it is intended to test
84
NetworkStatusTest::NetworkStatusTest
()
85
:
TestCase
(
"Verify correct behavior of the NetworkStatus object"
)
86
{
87
}
88
89
// Reminder that the test case should clean up after itself
90
NetworkStatusTest::~NetworkStatusTest
()
91
{
92
}
93
94
// This method is the pure virtual method from class TestCase that every
95
// TestCase must implement
96
void
97
NetworkStatusTest::DoRun
()
98
{
99
NS_LOG_DEBUG
(
"NetworkStatusTest"
);
100
101
// Create a NetworkStatus object
102
NetworkStatus
ns =
NetworkStatus
();
103
104
// Create a bunch of actual devices
105
NetworkComponents
components =
InitializeNetwork
(1, 1);
106
107
Ptr<LoraChannel>
channel = components.
channel
;
108
NodeContainer
endDevices = components.
endDevices
;
109
NodeContainer
gateways = components.
gateways
;
110
111
ns.AddNode(
GetMacLayerFromNode<ClassAEndDeviceLorawanMac>
(endDevices.
Get
(0)));
112
}
113
114
/**
115
* \ingroup lorawan
116
*
117
* The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the
118
* TestCases to be run. Typically, only the constructor for this class must be defined
119
*/
120
class
NetworkStatusTestSuite
:
public
TestSuite
121
{
122
public
:
123
NetworkStatusTestSuite
();
//!< Default constructor
124
};
125
126
NetworkStatusTestSuite::NetworkStatusTestSuite
()
127
:
TestSuite
(
"network-status"
,
Type
::UNIT)
128
{
129
LogComponentEnable
(
"NetworkStatusTestSuite"
,
LOG_LEVEL_DEBUG
);
130
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
131
AddTestCase
(
new
EndDeviceStatusTest
,
Duration::QUICK
);
132
AddTestCase
(
new
NetworkStatusTest
,
Duration::QUICK
);
133
}
134
135
// Do not forget to allocate an instance of this TestSuite
136
static
NetworkStatusTestSuite
lorawanTestSuite
;
EndDeviceStatusTest
It tests the constructor of the EndDeviceStatus class.
Definition
network-status-test-suite.cc:37
EndDeviceStatusTest::EndDeviceStatusTest
EndDeviceStatusTest()
Default constructor.
Definition
network-status-test-suite.cc:47
EndDeviceStatusTest::~EndDeviceStatusTest
~EndDeviceStatusTest() override
Destructor.
Definition
network-status-test-suite.cc:53
EndDeviceStatusTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
network-status-test-suite.cc:60
NetworkStatusTest
It tests the function NetworkStatus::AddNode.
Definition
network-status-test-suite.cc:74
NetworkStatusTest::NetworkStatusTest
NetworkStatusTest()
Default constructor.
Definition
network-status-test-suite.cc:84
NetworkStatusTest::~NetworkStatusTest
~NetworkStatusTest() override
Destructor.
Definition
network-status-test-suite.cc:90
NetworkStatusTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
network-status-test-suite.cc:97
NetworkStatusTestSuite
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
Definition
network-status-test-suite.cc:121
NetworkStatusTestSuite::NetworkStatusTestSuite
NetworkStatusTestSuite()
Default constructor.
Definition
network-status-test-suite.cc:126
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
ns3::NodeContainer::Get
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Definition
node-container.cc:67
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
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::Duration::QUICK
@ QUICK
Fast test.
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
ns3::lorawan::EndDeviceStatus
This class represents the network server's knowledge about an end device in the LoRaWAN network it is...
Definition
end-device-status.h:72
ns3::lorawan::NetworkStatus
This class represents the knowledge about the state of the network that is available at the network s...
Definition
network-status.h:38
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
ns3::lorawan::InitializeNetwork
NetworkComponents InitializeNetwork(int nDevices, int nGateways)
Definition
utilities.cc:117
ns3::lorawan::GetMacLayerFromNode
Ptr< T > GetMacLayerFromNode(Ptr< Node > n)
Definition
utilities.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LogComponentEnable
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition
log.cc:291
ns3::LOG_LEVEL_DEBUG
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition
log.h:102
lorawanTestSuite
static NetworkStatusTestSuite lorawanTestSuite
Definition
network-status-test-suite.cc:136
ns3::lorawan::NetworkComponents
Stores the main elements of a simulated LoRaWAN network.
Definition
utilities.h:29
ns3::lorawan::NetworkComponents::channel
Ptr< LoraChannel > channel
A pointer to the LoraChannel object.
Definition
utilities.h:30
ns3::lorawan::NetworkComponents::endDevices
NodeContainer endDevices
Container of the end device nodes.
Definition
utilities.h:31
ns3::lorawan::NetworkComponents::gateways
NodeContainer gateways
Container of the gateway nodes.
Definition
utilities.h:32
utilities.h
src
lorawan
test
network-status-test-suite.cc
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0