Skip to content

Commit 777b7c8

Browse files
committed
energy: Fix valgrind issues in test suite
1 parent bb7b228 commit 777b7c8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/energy/test/generic-battery-test.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,23 @@ DischargeBatteryTestCase::DoRun()
5151
batteryModel->AppendDeviceEnergyModel(consumptionEnergyModel);
5252
consumptionEnergyModel->SetNode(node);
5353

54+
// Needed to initialize battery model
55+
batteryModel->UpdateEnergySource();
56+
5457
// Discharge the battery with a constant current of 2.33 A (1C)
5558
consumptionEnergyModel->SetCurrentA(2.33);
5659

5760
Simulator::Stop(Seconds(3459));
5861
Simulator::Run();
59-
Simulator::Destroy();
6062

6163
NS_TEST_ASSERT_MSG_EQ_TOL(batteryModel->GetSupplyVoltage(),
6264
3.0,
6365
1.0e-2,
6466
"Cutoff voltage not reached");
67+
node->Dispose();
68+
consumptionEnergyModel->Dispose();
69+
batteryModel->Dispose();
70+
Simulator::Destroy();
6571
}
6672

6773
/**

0 commit comments

Comments
 (0)