A Discrete-Event Network Simulator
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 * 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: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
20/*
21 * This file includes testing for the following components:
22 * - EndDeviceStatus
23 * - GatewayStatus
24 * - NetworkStatus
25 */
26
27// Include headers of classes to test
28#include "utilities.h"
29
30#include "ns3/end-device-status.h"
31#include "ns3/log.h"
32#include "ns3/network-status.h"
33
34// An essential include is test.h
35#include "ns3/test.h"
36
37using namespace ns3;
38using namespace lorawan;
39
40NS_LOG_COMPONENT_DEFINE("NetworkStatusTestSuite");
41
42/**
43 * \ingroup lorawan
44 *
45 * It tests the constructor of the EndDeviceStatus class
46 */
48{
49 public:
50 EndDeviceStatusTest(); //!< Default constructor
51 ~EndDeviceStatusTest() override; //!< Destructor
52
53 private:
54 void DoRun() override;
55};
56
57// Add some help text to this case to describe what it is intended to test
59 : TestCase("Verify correct behavior of the EndDeviceStatus object")
60{
61}
62
63// Reminder that the test case should clean up after itself
65{
66}
67
68// This method is the pure virtual method from class TestCase that every
69// TestCase must implement
70void
72{
73 NS_LOG_DEBUG("EndDeviceStatusTest");
74
75 // Create an EndDeviceStatus object
77}
78
79/**
80 * \ingroup lorawan
81 *
82 * It tests the function NetworkStatus::AddNode
83 */
85{
86 public:
87 NetworkStatusTest(); //!< Default constructor
88 ~NetworkStatusTest() override; //!< Destructor
89
90 private:
91 void DoRun() override;
92};
93
94// Add some help text to this case to describe what it is intended to test
96 : TestCase("Verify correct behavior of the NetworkStatus object")
97{
98}
99
100// Reminder that the test case should clean up after itself
102{
103}
104
105// This method is the pure virtual method from class TestCase that every
106// TestCase must implement
107void
109{
110 NS_LOG_DEBUG("NetworkStatusTest");
111
112 // Create a NetworkStatus object
114
115 // Create a bunch of actual devices
116 NetworkComponents components = InitializeNetwork(1, 1);
117
118 Ptr<LoraChannel> channel = components.channel;
119 NodeContainer endDevices = components.endDevices;
120 NodeContainer gateways = components.gateways;
121
122 ns.AddNode(GetMacLayerFromNode<ClassAEndDeviceLorawanMac>(endDevices.Get(0)));
123}
124
125/**
126 * \ingroup lorawan
127 *
128 * The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the
129 * TestCases to be run. Typically, only the constructor for this class must be defined
130 */
132{
133 public:
134 NetworkStatusTestSuite(); //!< Default constructor
135};
136
138 : TestSuite("network-status", Type::UNIT)
139{
140 LogComponentEnable("NetworkStatusTestSuite", LOG_LEVEL_DEBUG);
141 // TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
144}
145
146// Do not forget to allocate an instance of this TestSuite
It tests the constructor of the EndDeviceStatus class.
EndDeviceStatusTest()
Default constructor.
~EndDeviceStatusTest() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
It tests the function NetworkStatus::AddNode.
NetworkStatusTest()
Default constructor.
~NetworkStatusTest() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
NetworkStatusTestSuite()
Default constructor.
keep track of a set of node pointers.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:302
A suite of tests to run.
Definition: test.h:1273
Type
Type of test.
Definition: test.h:1280
This class represents the network server's knowledge about an end device in the LoRaWAN network it is...
This class represents the knowledge about the state of the network that is available at the network s...
void AddNode(Ptr< ClassAEndDeviceLorawanMac > edMac)
Add a device to the ones that are tracked by this NetworkStatus object.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
NetworkComponents InitializeNetwork(int nDevices, int nGateways)
Definition: utilities.cc:128
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition: log.h:113
static NetworkStatusTestSuite lorawanTestSuite
Stores the main elements of a simulated LoRaWAN network.
Definition: utilities.h:40
Ptr< LoraChannel > channel
A pointer to the LoraChannel object.
Definition: utilities.h:41
NodeContainer endDevices
Container of the end device nodes.
Definition: utilities.h:42
NodeContainer gateways
Container of the gateway nodes.
Definition: utilities.h:43