Code review comments and bugfixes
- Making run_tests accept a target namespace as an argument. - Fixed asynchronous trigger callback mechanism. MCBF triggers working again. - Fixed numerical problems when calculating standard deviation for rand triggers.
This commit is contained in:
parent
081602633a
commit
7b46de3e27
3 changed files with 12 additions and 8 deletions
|
@ -63,9 +63,11 @@ var TestSuite = {
|
||||||
cleanup: func 0
|
cleanup: func 0
|
||||||
};
|
};
|
||||||
|
|
||||||
# run_tests()
|
# run_tests([namespace])
|
||||||
|
#
|
||||||
|
# Executes all test suites found in the given namespace. If no namespace is
|
||||||
|
# specified, then the namespace where run_tests is defined is used by default.
|
||||||
#
|
#
|
||||||
# Executes all test suites found in the namespace where run_tests is defined.
|
|
||||||
# An effective way to work with the framework is to just include the framework
|
# An effective way to work with the framework is to just include the framework
|
||||||
# from your test files:
|
# from your test files:
|
||||||
#
|
#
|
||||||
|
@ -82,9 +84,9 @@ var TestSuite = {
|
||||||
# well if it was io.include'd in my_test_suite.nas. Finally, all test suites
|
# well if it was io.include'd in my_test_suite.nas. Finally, all test suites
|
||||||
# in the "test" namespace are executed.
|
# in the "test" namespace are executed.
|
||||||
|
|
||||||
var run_tests = func () {
|
var run_tests = func(namespace=nil) {
|
||||||
|
|
||||||
var ns = closure(run_tests, 1);
|
var ns = namespace != nil ? namespace : closure(run_tests, 1);
|
||||||
|
|
||||||
var passed = 0;
|
var passed = 0;
|
||||||
var failed = 0;
|
var failed = 0;
|
||||||
|
|
|
@ -33,6 +33,9 @@ var set_unserviceable = func(path) {
|
||||||
|
|
||||||
var prop = path ~ "/serviceable";
|
var prop = path ~ "/serviceable";
|
||||||
|
|
||||||
|
if (props.globals.getNode(prop) == nil)
|
||||||
|
props.globals.initNode(prop, 1, "BOOL");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
parents: [FailureMgr.FailureActuator],
|
parents: [FailureMgr.FailureActuator],
|
||||||
set_failure_level: func(level) setprop(prop, level > 0 ? 0 : 1),
|
set_failure_level: func(level) setprop(prop, level > 0 ? 0 : 1),
|
||||||
|
@ -209,9 +212,8 @@ var MtbfTrigger = {
|
||||||
reset: func {
|
reset: func {
|
||||||
call(FailureMgr.Trigger.reset, [], me);
|
call(FailureMgr.Trigger.reset, [], me);
|
||||||
# TODO: use an elapsed time prop that accounts for speed-up and pause
|
# TODO: use an elapsed time prop that accounts for speed-up and pause
|
||||||
var std = math.sqrt(me.params["mtbf"] / 10 - 1);
|
|
||||||
me.fire_time = getprop(me._time_prop)
|
me.fire_time = getprop(me._time_prop)
|
||||||
+ norm_rand(me.params["mtbf"], std);
|
+ norm_rand(me.params["mtbf"], me.params["mtbf"] / 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
to_str: func {
|
to_str: func {
|
||||||
|
@ -343,7 +345,7 @@ var McbfTrigger = {
|
||||||
call(FailureMgr.Trigger.reset, [], me);
|
call(FailureMgr.Trigger.reset, [], me);
|
||||||
me.counter.reset();
|
me.counter.reset();
|
||||||
me.activation_cycles =
|
me.activation_cycles =
|
||||||
norm_rand(me.params["mcbf"], math.sqrt(me.params["mcbf"] / 10));
|
norm_rand(me.params["mcbf"], me.params["mcbf"] / 10);
|
||||||
|
|
||||||
me.enabled and me.counter.enable();
|
me.enabled and me.counter.enable();
|
||||||
},
|
},
|
||||||
|
|
|
@ -190,7 +190,7 @@ var _failmgr = {
|
||||||
if (trigger == nil) return;
|
if (trigger == nil) return;
|
||||||
|
|
||||||
trigger.bind(proproot ~ mode_id);
|
trigger.bind(proproot ~ mode_id);
|
||||||
trigger.on_fire = func me.on_trigger_activated(trigger);
|
trigger.on_fire = func _failmgr.on_trigger_activated(trigger);
|
||||||
trigger.reset();
|
trigger.reset();
|
||||||
|
|
||||||
if (trigger.requires_polling) {
|
if (trigger.requires_polling) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue