mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
test suite: fixes. testing boot gpio states
This commit is contained in:
@@ -197,6 +197,14 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
taskClear(Par1 - 1, true);
|
||||
}
|
||||
|
||||
//quickly clear all tasks, without saving (used by test suite)
|
||||
if (strcasecmp_P(Command, PSTR("TaskClearAll")) == 0)
|
||||
{
|
||||
success = true;
|
||||
for (byte t=0; t<TASKS_MAX; t++)
|
||||
taskClear(t, false);
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("wdconfig")) == 0)
|
||||
{
|
||||
success = true;
|
||||
|
||||
+9
-1
@@ -66,6 +66,7 @@ def step(title=""):
|
||||
|
||||
#run the test. if there is an exception we resume this test the next time
|
||||
test()
|
||||
log.info("Completed step")
|
||||
|
||||
|
||||
|
||||
@@ -117,4 +118,11 @@ def test_is(value, shouldbe):
|
||||
def pause(seconds):
|
||||
log.info("Waiting for {seconds} seconds".format(seconds=seconds))
|
||||
time.sleep(seconds)
|
||||
|
||||
|
||||
|
||||
|
||||
def completed():
|
||||
if os.path.exists("test.state"):
|
||||
os.unlink("test.state")
|
||||
|
||||
log.info("*** All tests completed ***")
|
||||
|
||||
+9
-6
@@ -184,16 +184,19 @@ class Node():
|
||||
|
||||
|
||||
|
||||
def http_post(self, page, params, data=None, twice=False):
|
||||
def http_post(self, page, params=None, data=None, twice=False):
|
||||
"""http post to espeasy webinterface. (GET if data is None)"""
|
||||
|
||||
# transform easy copy/pastable chromium data into a dict
|
||||
|
||||
params_dict={}
|
||||
for line in params.split("\n"):
|
||||
m=re.match(" *(.*?):(.*)",line)
|
||||
if (m):
|
||||
params_dict[m.group(1)]=m.group(2)
|
||||
if params:
|
||||
params_dict={}
|
||||
for line in params.split("\n"):
|
||||
m=re.match(" *(.*?):(.*)",line)
|
||||
if (m):
|
||||
params_dict[m.group(1)]=m.group(2)
|
||||
else:
|
||||
params_dict=None
|
||||
|
||||
if data:
|
||||
data_dict={}
|
||||
|
||||
@@ -15,6 +15,9 @@ def prepare():
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
node[0].serialcmd("resetFlashWriteCounter")
|
||||
node[1].reboot()
|
||||
node[1].pingserial()
|
||||
node[1].serialcmd("resetFlashWriteCounter")
|
||||
espeasy[1].controller_domoticz_mqtt()
|
||||
espeasy[1].post_device(1, """
|
||||
TDNUM:1
|
||||
@@ -40,3 +43,8 @@ def test():
|
||||
espeasy[0].control(cmd="gpio,12,0")
|
||||
values=controller.recv_domoticz_mqtt(SENSOR_TYPE_SWITCH,1000)
|
||||
test_is(values[0],0)
|
||||
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
completed()
|
||||
|
||||
@@ -70,3 +70,7 @@ def powercycle():
|
||||
test_in_range(results[0], -5,40)
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_SINGLE,2002)
|
||||
test_in_range(results[0], -5,40)
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
completed()
|
||||
|
||||
@@ -35,3 +35,7 @@ espeasy[0].post_device(1, data="""
|
||||
edit:1
|
||||
page:1
|
||||
""")
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
completed()
|
||||
|
||||
@@ -42,3 +42,7 @@ def test():
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_TEMP_HUM,4001)
|
||||
test_in_range(results[0], -5,40)
|
||||
test_in_range(results[1], 10,80)
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
completed()
|
||||
|
||||
@@ -136,3 +136,6 @@ for ( title, controller_config, controller_recv ) in [
|
||||
espeasy[0].device_p033(index=1, TDID1=5110, plugin_033_sensortype=SENSOR_TYPE_WIND)
|
||||
results=controller_recv(SENSOR_TYPE_WIND,5110)
|
||||
test_is(results, [ 5022, 5023, 5024 ])
|
||||
|
||||
if __name__=='__main__':
|
||||
completed()
|
||||
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from esptest import *
|
||||
|
||||
# hardware requirements:
|
||||
# - node 0 (will be output pin)
|
||||
# - node 1 (will be input/sender)
|
||||
# - D6 connected to eachother
|
||||
|
||||
# tests:
|
||||
# - GPIO boot state
|
||||
|
||||
pin_input=12;
|
||||
|
||||
@step()
|
||||
def prepare():
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
node[0].serialcmd("resetFlashWriteCounter")
|
||||
node[0].serialcmd("TaskClearAll")
|
||||
node[0].serialcmd("Save")
|
||||
node[1].reboot()
|
||||
node[1].pingserial()
|
||||
node[1].serialcmd("resetFlashWriteCounter")
|
||||
node[1].serialcmd("TaskClearAll")
|
||||
espeasy[1].controller_domoticz_mqtt()
|
||||
espeasy[1].post_device(1, """
|
||||
TDNUM:1
|
||||
TDN:
|
||||
TDE:on
|
||||
taskdevicepin1:{pin_input}
|
||||
plugin_001_type:1
|
||||
plugin_001_button:0
|
||||
TDSD1:on
|
||||
TDID1:1000
|
||||
TDT:0
|
||||
TDVN1:Switch
|
||||
edit:1
|
||||
""".format(pin_input=pin_input))
|
||||
|
||||
|
||||
@step()
|
||||
def test():
|
||||
|
||||
log.info("Setting bootsate to default and rebooting")
|
||||
node[0].http_post(
|
||||
page="hardware",
|
||||
data="""
|
||||
pled:-1
|
||||
pledi:on
|
||||
psda:4
|
||||
pscl:5
|
||||
sd:-1
|
||||
p0:0
|
||||
p2:0
|
||||
p4:0
|
||||
p5:0
|
||||
p9:0
|
||||
p10:0
|
||||
p12:0
|
||||
p13:0
|
||||
p14:0
|
||||
p15:0
|
||||
p16:0
|
||||
""")
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
#ignore everything up to this point
|
||||
controller.clear_mqtt()
|
||||
|
||||
|
||||
log.info("Setting bootsate to LOW rebooting")
|
||||
espeasy[0]._node.http_post(
|
||||
page="hardware",
|
||||
data="""
|
||||
pled:-1
|
||||
pledi:on
|
||||
psda:4
|
||||
pscl:5
|
||||
sd:-1
|
||||
p0:0
|
||||
p2:0
|
||||
p4:0
|
||||
p5:0
|
||||
p9:0
|
||||
p10:0
|
||||
p12:1
|
||||
p13:0
|
||||
p14:0
|
||||
p15:0
|
||||
p16:0
|
||||
""")
|
||||
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
|
||||
values=controller.recv_domoticz_mqtt(SENSOR_TYPE_SWITCH,1000)
|
||||
test_is(values[0],0)
|
||||
|
||||
|
||||
log.info("Setting bootsate to HIGH rebooting")
|
||||
espeasy[0]._node.http_post(
|
||||
page="hardware",
|
||||
data="""
|
||||
pled:-1
|
||||
pledi:on
|
||||
psda:4
|
||||
pscl:5
|
||||
sd:-1
|
||||
p0:0
|
||||
p2:0
|
||||
p4:0
|
||||
p5:0
|
||||
p9:0
|
||||
p10:0
|
||||
p12:2
|
||||
p13:0
|
||||
p14:0
|
||||
p15:0
|
||||
p16:0
|
||||
""")
|
||||
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
|
||||
values=controller.recv_domoticz_mqtt(SENSOR_TYPE_SWITCH,1000)
|
||||
test_is(values[0],1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
completed()
|
||||
Reference in New Issue
Block a user