未验证 提交 4f7a5ea3 编写于 作者: Q Qianqian Zhu 提交者: GitHub

Merge pull request #1346 from YanhuiMa/heartbeat

watchdog: Heartbeat test for i6300esb
......@@ -70,3 +70,24 @@
test_type = watchdog_test_suit
watchdog_action = pause
watchdog_test_lib = "watchdog/watchdog-test-framework"
- heartbeat_test:
only i6300esb
test_type = heartbeat_test
del_module_cmd = "modprobe -r i6300esb"
reload_module_cmd = "modprobe i6300esb heartbeat=%s"
trigger_cmd = python -c "open('/dev/watchdog', 'w')"
watchdog_action = pause
dmesg_cmd = dmesg -c
variants:
- valid:
heartbeat = random_value
- invalid_1:
heartbeat = -1
- invalid_0:
heartbeat = 0
- invalid_min:
heartbeat = -2147483648
- invalid_max:
heartbeat = 2147483647
- invalid_excp:
heartbeat = 4294967296
......@@ -2,6 +2,7 @@ import os
import re
import time
import logging
import random
from avocado.utils import process
from virttest import error_context
......@@ -346,6 +347,66 @@ def run(test, params, env):
session.cmd_output("pkill watchdog-test")
session.cmd_output("rm -rf /home/%s" % test_dir)
def heartbeat_test():
"""
Heartbeat test for i6300esb
Test steps:
1.Start VM with "-watchdog-action pause" CLI option
2.Set heartbeat value and reload the i6300esb module
3.Trigger wathchdog action through open /dev/watchdog
4.Ensure watchdog_action takes effect after $heartbeat.
"""
del_module_cmd = params["del_module_cmd"]
reload_module_cmd = params["reload_module_cmd"]
_watchdog_device_check(test, session, watchdog_device_type)
error_context.context("set heartbeat value and reload the i6300esb "
"module", logging.info)
session.cmd(del_module_cmd)
heartbeat = params["heartbeat"]
if heartbeat == "random_value":
heartbeat = random.randint(1, 20)
else:
heartbeat = eval(heartbeat)
dmesg_cmd = params["dmesg_cmd"]
session.cmd(dmesg_cmd)
session.cmd_output(reload_module_cmd % heartbeat)
if heartbeat < -2147483648 or heartbeat > 2147483647:
o = session.cmd_output("dmesg | grep -i 'i6300esb.*invalid'")
if o:
logging.info("Heartbeat value %s is out of range, it is "
"expected." % heartbeat)
else:
test.fail("No invalid heartbeat info in dmesg.")
elif -2147483648 <= heartbeat < 1 or 2046 < heartbeat <= 2147483647:
o = session.cmd_output("dmesg | grep -i 'heartbeat=30'")
if not o:
test.fail("Heartbeat value isn't default 30 sec in dmesg, it "
"should be.")
heartbeat = 30
elif 1 <= heartbeat <= 2046:
o = session.cmd_output("dmesg | grep -i 'heartbeat=%s'" % heartbeat)
if not o:
test.fail("Heartbeat value isn't %s sec in dmesg" % heartbeat)
if heartbeat <= 2147483647 and heartbeat > -2147483648:
_watchdog_device_check(test, session, watchdog_device_type)
_trigger_watchdog(session, trigger_cmd)
error_context.context("Watchdog will fire after %s s" % heartbeat,
logging.info)
start_time = time.time()
end_time = start_time + float(heartbeat) + 2
while not vm.monitor.verify_status("paused"):
if time.time() > end_time:
test.fail("Monitor status is:%s, watchdog action '%s' didn't take"
"effect" % (vm.monitor.get_status(), watchdog_action))
time.sleep(1)
guest_pause_time = time.time() - start_time
if abs(guest_pause_time - float(heartbeat)) <= 2:
logging.info("Watchdog action '%s' took effect after '%s's." %
(watchdog_action, guest_pause_time))
else:
test.fail("Watchdog action '%s' took effect after '%s's, it is earlier"
" than expected." % (watchdog_action, guest_pause_time))
# main procedure
test_type = params.get("test_type")
check_watchdog_support()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册