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 * 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 "utilities.h"
17
18// An essential include is test.h
19#include "ns3/test.h"
20
21// Include headers of classes to test
22#include "ns3/class-a-end-device-lorawan-mac.h"
23#include "ns3/network-status.h"
24
25using namespace ns3;
26using namespace lorawan;
27
28NS_LOG_COMPONENT_DEFINE("NetworkStatusTestSuite");
29
30/**
31 * @ingroup lorawan
32 *
33 * It tests the constructor of the EndDeviceStatus class
34 */
36{
37 public:
38 EndDeviceStatusTest(); //!< Default constructor
39 ~EndDeviceStatusTest() override; //!< Destructor
40
41 private:
42 void DoRun() override;
43};
44
45// Add some help text to this case to describe what it is intended to test
47 : TestCase("Verify correct behavior of the EndDeviceStatus object")
48{
49}
50
51// Reminder that the test case should clean up after itself
55
56// This method is the pure virtual method from class TestCase that every
57// TestCase must implement
58void
60{
61 NS_LOG_DEBUG("EndDeviceStatusTest");
62
63 // Create an EndDeviceStatus object
65}
66
67/**
68 * @ingroup lorawan
69 *
70 * It tests the function NetworkStatus::AddNode
71 */
73{
74 public:
75 NetworkStatusTest(); //!< Default constructor
76 ~NetworkStatusTest() override; //!< Destructor
77
78 private:
79 void DoRun() override;
80};
81
82// Add some help text to this case to describe what it is intended to test
84 : TestCase("Verify correct behavior of the NetworkStatus object")
85{
86}
87
88// Reminder that the test case should clean up after itself
92
93// This method is the pure virtual method from class TestCase that every
94// TestCase must implement
95void
97{
98 NS_LOG_DEBUG("NetworkStatusTest");
99
100 // Create a NetworkStatus object
102
103 // Create a bunch of actual devices
104 NetworkComponents components = InitializeNetwork(1, 1);
105
106 Ptr<LoraChannel> channel = components.channel;
107 NodeContainer endDevices = components.endDevices;
108 NodeContainer gateways = components.gateways;
109
110 ns.AddNode(GetMacLayerFromNode<ClassAEndDeviceLorawanMac>(endDevices.Get(0)));
111}
112
113/**
114 * @ingroup lorawan
115 *
116 * The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the
117 * TestCases to be run. Typically, only the constructor for this class must be defined
118 */
120{
121 public:
122 NetworkStatusTestSuite(); //!< Default constructor
123};
124
126 : TestSuite("network-status", Type::UNIT)
127{
128 // LogComponentEnable("NetworkStatusTestSuite", LOG_LEVEL_DEBUG);
129
132}
133
134// 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:70
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:296
@ QUICK
Fast test.
Definition test.h:1057
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
Type
Type of test.
Definition test.h:1271
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:494
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...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:260
static LorawanTestSuite lorawanTestSuite
NetworkComponents InitializeNetwork(int nDevices, int nGateways)
Definition utilities.cc:124
Ptr< T > GetMacLayerFromNode(Ptr< Node > n)
Definition utilities.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Stores the main elements of a simulated LoRaWAN network.
Definition utilities.h:28
Ptr< LoraChannel > channel
A pointer to the LoraChannel object.
Definition utilities.h:29
NodeContainer endDevices
Container of the end device nodes.
Definition utilities.h:30
NodeContainer gateways
Container of the gateway nodes.
Definition utilities.h:31