From e78be5c09eda6a8738d07d801dd8935f3eaa5400 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Thu, 29 Sep 2011 00:21:27 +0200 Subject: Add documentation on timetraps and start flags --- lib/common_test/doc/src/common_test_app.xml | 32 +++++++++++++++++++------- lib/common_test/doc/src/write_test_chapter.xml | 14 +++++++---- lib/common_test/src/ct.erl | 2 +- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/lib/common_test/doc/src/common_test_app.xml b/lib/common_test/doc/src/common_test_app.xml index 57b032b3fd..f58b2ab0a9 100644 --- a/lib/common_test/doc/src/common_test_app.xml +++ b/lib/common_test/doc/src/common_test_app.xml @@ -133,9 +133,15 @@ {require,Name,Required} | {userdata,UserData} | {silent_connections,Conns} | {stylesheet,CSSFile} | {ct_hooks, CTHs} - Time = MilliSec | {seconds,integer()} | {minutes,integer()} - | {hours,integer()} + Time = TimeVal | TimeFunc + TimeVal = MilliSec | {seconds,integer()} | {minutes,integer()} | + {hours,integer()} + TimeFunc = {Mod,Func,Args} | Fun MilliSec = integer() + Mod = atom() + Func = atom() + Args = list() + Fun = fun() Required = Key | {Key,SubKeys} Key = atom() SubKeys = SubKey | [SubKey] @@ -161,7 +167,9 @@ test case is allowed to take (including init_per_testcase/2 and end_per_testcase/2). If the timetrap time is exceeded, the test case fails with reason - timetrap_timeout.

+ timetrap_timeout. If a TimeFunc function is specified, + it will be called initially and must return a value on + TimeVal format.

The require tag specifies configuration variables that are required by test cases in the suite. If the required @@ -248,7 +256,7 @@ -

MANDATORY (only if one or more groups are defined)

+

OPTIONAL

This function is called before execution of a test case group. It typically contains initialization which is common for @@ -279,7 +287,7 @@ -

MANDATORY (only if one or more groups are defined)

+

OPTIONAL

This function is called after the execution of a test case group is finished. It is meant to be used for cleaning up after init_per_group/2. @@ -353,9 +361,15 @@ Info = {timetrap,Time} | {require,Required} | {require,Name,Required} | {userdata,UserData} | {silent_connections,Conns} - Time = MilliSec | {seconds,integer()} | {minutes,integer()} - | {hours,integer()} + Time = TimeVal | TimeFunc + TimeVal = MilliSec | {seconds,integer()} | {minutes,integer()} | + {hours,integer()} + TimeFunc = {Mod,Func,Args} | Fun MilliSec = integer() + Mod = atom() + Func = atom() + Args = list() + Fun = fun() Required = Key | {Key,SubKeys} Key = atom() SubKeys = SubKey | [SubKey] @@ -378,7 +392,9 @@ exceeded, the test case fails with reason timetrap_timeout. init_per_testcase/2 and end_per_testcase/2 are included in the - timetrap time.

+ timetrap time. If a TimeFunc function is specified, + it will be called before the test case (or init_per_testcase/2) + and must return a value on TimeVal format.

The require tag specifies configuration variables that are required by the test case. If the required diff --git a/lib/common_test/doc/src/write_test_chapter.xml b/lib/common_test/doc/src/write_test_chapter.xml index 3f9fdb7121..e35888e68f 100644 --- a/lib/common_test/doc/src/write_test_chapter.xml +++ b/lib/common_test/doc/src/write_test_chapter.xml @@ -280,6 +280,8 @@ the timetrap time is exceeded, the test case fails with reason timetrap_timeout. Note that init_per_testcase and end_per_testcase are included in the timetrap time. + Please see the Timetrap + section for more details.

userdata @@ -699,8 +701,8 @@
- Timetrap timeouts + Timetrap timeouts

The default time limit for a test case is 30 minutes, unless a timetrap is specified either by the suite info function or a test case info function. The timetrap timeout value defined @@ -723,6 +725,13 @@ multipled by multiply_timetraps, and possibly scaled up if scale_timetraps is enabled, the function ct:sleep/1 may be called.

+

A function (fun or MFA) may be specified as timetrap value + in the suite- and test case info function, e.g:

+

{timetrap,{test_utils,get_timetrap_value,[?MODULE,system_start]}}

+

The function will be called initially by Common Test (before execution + of the suite or the test case) and must return a time value such as an + integer (millisec), or a {SecMinOrHourTag,Time} tuple. More + information can be found in the common_test reference manual.

@@ -818,6 +827,3 @@
- - - diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 4c215d1b1e..f3c2029734 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -151,7 +151,7 @@ run(TestDirs) -> %%% {refresh_logs,LogDir} | {logopts,LogOpts} | {basic_html,Bool} | %%% {ct_hooks, CTHs} %%% TestDirs = [string()] | string() -%%% Suites = [string()] | string() +%%% Suites = [string()] | [atom()] | string() | atom() %%% Cases = [atom()] | atom() %%% Groups = [atom()] | atom() %%% TestSpecs = [string()] | string() -- cgit v1.2.3