Skip to content

Commit

Permalink
selftest fix
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Nov 20, 2024
1 parent 3864fe0 commit 9d92cc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/selftest/selftest_energyMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ void Test_EnergyMeter_TurnOffScript() {
CMD_ExecuteCommand("SetupTestPower 230 0.01 0.5 0", 0);
int prevChannel10 = CHANNEL_Get(10);
for (int i = 0; i < 10; i++) {
Test_Power_RunEverySecond();
Sim_RunSeconds(1.5f, false);
int now10 = CHANNEL_Get(10);
SELFTEST_ASSERT(now10 > prevChannel10);
Expand All @@ -220,6 +221,7 @@ void Test_EnergyMeter_TurnOffScript() {
// now reset will kick in
CMD_ExecuteCommand("SetupTestPower 230 0.01 1.5 0", 0);
for (int i = 0; i < 10; i++) {
Test_Power_RunEverySecond();
Sim_RunSeconds(1.5f, false);
int now10 = CHANNEL_Get(10);
SELFTEST_ASSERT(now10 == 0);
Expand All @@ -231,6 +233,7 @@ void Test_EnergyMeter_TurnOffScript() {
Sim_RunSeconds(1.5f, false);
prevChannel10 = CHANNEL_Get(10);
for (int i = 0; i < 10; i++) {
Test_Power_RunEverySecond();
Sim_RunSeconds(1.5f, false);
int now10 = CHANNEL_Get(10);
SELFTEST_ASSERT(now10 > prevChannel10);
Expand All @@ -240,6 +243,7 @@ void Test_EnergyMeter_TurnOffScript() {
// now reset will kick in
CMD_ExecuteCommand("SetupTestPower 230 0.01 1.5 0", 0);
for (int i = 0; i < 10; i++) {
Test_Power_RunEverySecond();
Sim_RunSeconds(1.5f, false);
int now10 = CHANNEL_Get(10);
SELFTEST_ASSERT(now10 == 0);
Expand All @@ -249,6 +253,7 @@ void Test_EnergyMeter_TurnOffScript() {
CMD_ExecuteCommand("SetupTestPower 230 0.01 0.5 0", 0);
prevChannel10 = CHANNEL_Get(10);
for (int i = 0; i < 12; i++) {
Test_Power_RunEverySecond();
Sim_RunSeconds(1.5f, false);
int now10 = CHANNEL_Get(10);
SELFTEST_ASSERT(now10 > prevChannel10);
Expand All @@ -258,6 +263,7 @@ void Test_EnergyMeter_TurnOffScript() {
// this loop should trigger turn off
prevChannel10 = CHANNEL_Get(10);
for (int i = 0; i < 3; i++) {
Test_Power_RunEverySecond();
Sim_RunSeconds(1.5f, false);
int now10 = CHANNEL_Get(10);
SELFTEST_ASSERT(now10 > prevChannel10);
Expand Down
2 changes: 1 addition & 1 deletion src/win_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void Win_DoUnitTests() {
Test_Command_If_Else();
Test_MQTT();
Test_ChargeLimitDriver();
Test_EnergyMeter();
// this is slowest
Test_TuyaMCU_Basic();
Test_TuyaMCU_Mult();
Expand Down Expand Up @@ -171,7 +172,6 @@ void Win_DoUnitTests() {
Test_MultiplePinsOnChannel();
Test_Flags();
Test_DHT();
Test_EnergyMeter();
Test_Tasmota();
Test_NTP();
Test_NTP_SunsetSunrise();
Expand Down

0 comments on commit 9d92cc8

Please sign in to comment.