diff options
Diffstat (limited to 'lib/common_test')
20 files changed, 401 insertions, 245 deletions
diff --git a/lib/common_test/doc/src/Makefile b/lib/common_test/doc/src/Makefile index 6322860088..1a767a8197 100644 --- a/lib/common_test/doc/src/Makefile +++ b/lib/common_test/doc/src/Makefile @@ -51,7 +51,7 @@ CT_MODULES = \ CT_XML_FILES = $(CT_MODULES:=.xml) XML_APPLICATION_FILES = ref_man.xml -XML_REF1_FILES = run_test.xml +XML_REF1_FILES = ct_run.xml XML_REF3_FILES = $(CT_XML_FILES) XML_REF6_FILES = common_test_app.xml diff --git a/lib/common_test/doc/src/config_file_chapter.xml b/lib/common_test/doc/src/config_file_chapter.xml index 77b0c0c0b7..59151a73ec 100644 --- a/lib/common_test/doc/src/config_file_chapter.xml +++ b/lib/common_test/doc/src/config_file_chapter.xml @@ -248,7 +248,7 @@ <p><c>Callback:check_parameter/1</c></p> <p>The input argument will be passed from Common Test, as defined in the test - specification or given as an option to <c>run_test</c>.</p> + specification or given as an option to <c>ct_run</c> or <c>ct:run_test</c>.</p> <p>The return value should be any of the following values indicating if given configuration parameter is valid:</p> diff --git a/lib/common_test/doc/src/cover_chapter.xml b/lib/common_test/doc/src/cover_chapter.xml index 6e4f59ef73..377409ed7b 100644 --- a/lib/common_test/doc/src/cover_chapter.xml +++ b/lib/common_test/doc/src/cover_chapter.xml @@ -94,10 +94,10 @@ <p>To activate the code coverage support, you simply specify the name of the cover specification file as you start Common Test. - This you do either by using the <c>-cover</c> flag with <c>run_test</c>. + This you do either by using the <c>-cover</c> flag with <c>ct_run</c>. Example:</p> - <p><c>$ run_test -dir $TESTOBJS/db -cover $TESTOBJS/db/config/db.coverspec</c></p> + <p><c>$ ct_run -dir $TESTOBJS/db -cover $TESTOBJS/db/config/db.coverspec</c></p> <p>You may also pass the cover specification file name in a call to <c>ct:run_test/1</c>, by adding a <c>{cover,CoverSpec}</c> diff --git a/lib/common_test/doc/src/ct_junit_report.xml b/lib/common_test/doc/src/ct_junit_report.xml new file mode 100644 index 0000000000..49a40cc1de --- /dev/null +++ b/lib/common_test/doc/src/ct_junit_report.xml @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="latin1" ?> +<!DOCTYPE erlref SYSTEM "erlref.dtd"> +<erlref> +<header> +<title>ct_junit_report</title> +<prepared></prepared> +<responsible></responsible> +<docno>1</docno> +<approved></approved> +<checked></checked> +<date></date> +<rev>A</rev> +<file>ct_junit_report.xml</file></header> +<module>ct_junit_report</module> +<modulesummary>Common Test Framework functions handling test specifications.</modulesummary> +<description> +<p>Common Test Framework functions handling test specifications.</p> + + <p>This module creates a junit report of the test run if plugged in + as a suite_callback.</p></description> +<funcs> +<func> +<name>init(Opts) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="init-1"/> + </desc></func> +<func> +<name>post_end_group(Group, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="post_end_group-3"/> + </desc></func> +<func> +<name>post_end_suite(Suite, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="post_end_suite-3"/> + </desc></func> +<func> +<name>post_end_tc(TC, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="post_end_tc-3"/> + </desc></func> +<func> +<name>post_init_group(Group, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="post_init_group-3"/> + </desc></func> +<func> +<name>post_init_suite(Suite, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="post_init_suite-3"/> + </desc></func> +<func> +<name>pre_end_group(Group, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="pre_end_group-3"/> + </desc></func> +<func> +<name>pre_end_suite(Suite, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="pre_end_suite-3"/> + </desc></func> +<func> +<name>pre_init_group(Group, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="pre_init_group-3"/> + </desc></func> +<func> +<name>pre_init_suite(Suite, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="pre_init_suite-3"/> + </desc></func> +<func> +<name>pre_init_tc(TC, Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="pre_init_tc-3"/> + </desc></func> +<func> +<name>terminate(Config, State) -> term() +</name> +<fsummary> </fsummary> + +<desc><marker id="terminate-2"/> + </desc></func></funcs> + +<authors> +<aname> </aname> +<email> </email></authors></erlref>
\ No newline at end of file diff --git a/lib/common_test/doc/src/ct_master_chapter.xml b/lib/common_test/doc/src/ct_master_chapter.xml index 01f8e61d36..f4f0ecad62 100644 --- a/lib/common_test/doc/src/ct_master_chapter.xml +++ b/lib/common_test/doc/src/ct_master_chapter.xml @@ -188,7 +188,7 @@ <seealso marker="run_test_chapter#test_specifications">Running Test Suites</seealso> chapter). The result is that any test specified to run on a node with the same name as the Common Test node in question (typically <c>ct@somehost</c> if started - with the <c>run_test</c> program), will be performed. Tests without explicit + with the <c>ct_run</c> program), will be performed. Tests without explicit node association will always be performed too of course!</p> <note><p>It is recommended that absolute paths are used for log directories, diff --git a/lib/common_test/doc/src/run_test.xml b/lib/common_test/doc/src/ct_run.xml index 2f0a94afba..1ab563d74f 100644 --- a/lib/common_test/doc/src/run_test.xml +++ b/lib/common_test/doc/src/ct_run.xml @@ -21,7 +21,7 @@ </legalnotice> - <title>The run_test program</title> + <title>The ct_run program</title> <prepared>Peter Andersson</prepared> <responsible>Peter Andersson</responsible> <docno></docno> @@ -29,18 +29,18 @@ <checked></checked> <date>2010-04-01</date> <rev>PA2</rev> - <file>run_test.xml</file> + <file>ct_run.xml</file> </header> - <com>run_test</com> + <com>ct_run</com> <comsummary>Program used for starting Common Test from the OS command line. </comsummary> <description> - <p>The <c>run_test</c> program is automatically installed with Erlang/OTP + <p>The <c>ct_run</c> program is automatically installed with Erlang/OTP and Common Test (please see the Installation chapter in the Common Test User's Guide for more information). The program accepts a number - of different start flags. Some flags trigger <c>run_test</c> + of different start flags. Some flags trigger <c>ct_run</c> to start the Common Test application and pass on data to it. Some flags start an Erlang node prepared for running Common Test in a particular mode.</p> @@ -50,20 +50,20 @@ shell (or an Erlang program). Please see the <c>ct</c> man page for details.</p> - <p><c>run_test</c> also accepts Erlang emulator flags. These are used - when <c>run_test</c> calls <c>erl</c> to start the Erlang node + <p><c>ct_run</c> also accepts Erlang emulator flags. These are used + when <c>ct_run</c> calls <c>erl</c> to start the Erlang node (making it possible to e.g. add directories to the code server path, change the cookie on the node, start additional applications, etc).</p> <p>With the optional flag:</p> <pre>-erl_args</pre> - <p>it's possible to divide the options on the <c>run_test</c> command line into + <p>it's possible to divide the options on the <c>ct_run</c> command line into two groups, one that Common Test should process (those preceding <c>-erl_args</c>), and one it should completely ignore and pass on directly to the emulator (those following <c>-erl_args</c>). Options preceding <c>-erl_args</c> that Common Test doesn't recognize, also get passed on to the emulator untouched. By means of <c>-erl_args</c> the user may specify flags with the same name, but - with different destinations, on the <c>run_test</c> command line.</p> + with different destinations, on the <c>ct_run</c> command line.</p> <p>If <c>-pa</c> or <c>-pz</c> flags are specified in the Common Test group of options (preceding <c>-erl_args</c>), relative directories will be converted to absolute and re-inserted into the code path by Common Test (to avoid @@ -72,17 +72,17 @@ following <c>-erl_args</c> on the command line. These directories are added to the code path normally (i.e. on specified form)</p> - <p>If <c>run_test</c> is called with option:</p> + <p>If <c>ct_run</c> is called with option:</p> <pre>-help</pre> <p>it prints all valid start flags to stdout.</p> </description> - <marker id="run_test"></marker> + <marker id="ct_run"></marker> <section> <title>Run tests from command line</title> <pre> - run_test [-dir TestDir1 TestDir2 .. TestDirN] | + ct_run [-dir TestDir1 TestDir2 .. TestDirN] | [-suite Suite1 Suite2 .. SuiteN [[-group Group1 Group2 .. GroupN] [-case Case1 Case2 .. CaseN]]] [-step [config | keep_inactive]] @@ -110,7 +110,7 @@ <section> <title>Run tests using test specification</title> <pre> - run_test -spec TestSpec1 TestSpec2 .. TestSpecN + ct_run -spec TestSpec1 TestSpec2 .. TestSpecN [-config ConfigFile1 ConfigFile2 .. ConfigFileN] [-userconfig CallbackModule1 ConfigString1 and CallbackModule2 ConfigString2 and .. and CallbackModuleN ConfigStringN] @@ -136,7 +136,7 @@ <section> <title>Run tests in web based GUI</title> <pre> - run_test -vts [-browser Browser] + ct_run -vts [-browser Browser] [-dir TestDir1 TestDir2 .. TestDirN] | [-suite Suite [[-group Group] [-case Case]]] [-config ConfigFile1 ConfigFile2 .. ConfigFileN] @@ -152,12 +152,12 @@ <section> <title>Refresh the HTML index files</title> <pre> - run_test -refresh_logs [-logdir LogDir] [-basic_html]</pre> + ct_run -refresh_logs [-logdir LogDir] [-basic_html]</pre> </section> <section> <title>Run CT in interactive mode</title> <pre> - run_test -shell + ct_run -shell [-config ConfigFile1 ConfigFile2 ... ConfigFileN] [-userconfig CallbackModule1 ConfigString1 and CallbackModule2 ConfigString2 and .. and CallbackModuleN ConfigStringN] @@ -166,7 +166,7 @@ <section> <title>Start a Common Test Master node</title> <pre> - run_test -ctmaster</pre> + ct_run -ctmaster</pre> </section> <section> diff --git a/lib/common_test/doc/src/ct_slave.xml b/lib/common_test/doc/src/ct_slave.xml deleted file mode 100644 index ceebf51f1a..0000000000 --- a/lib/common_test/doc/src/ct_slave.xml +++ /dev/null @@ -1,139 +0,0 @@ -<?xml version="1.0" encoding="latin1" ?> -<!DOCTYPE erlref SYSTEM "erlref.dtd"> -<erlref> -<header> -<title>ct_slave</title> -<prepared></prepared> -<responsible></responsible> -<docno>1</docno> -<approved></approved> -<checked></checked> -<date></date> -<rev>A</rev> -<file>ct_slave.xml</file></header> -<module>ct_slave</module> -<modulesummary>Common Test Framework functions for starting and stopping nodes for -Large Scale Testing.</modulesummary> -<description> -<p>Common Test Framework functions for starting and stopping nodes for -Large Scale Testing.</p> - - <p>This module exports functions which are used by the Common Test Master - to start and stop "slave" nodes. It is the default callback module for the - <c>{init, node_start}</c> term of the Test Specification.</p></description> -<funcs> -<func> -<name>start(Node) -> Result</name> -<fsummary>Starts an Erlang node with name Node on the local host.</fsummary> -<type> -<v>Node = atom()</v><v>Result = {ok, NodeName} | {error, already_started, NodeName} | {error, started_not_connected, NodeName} | {error, boot_timeout, NodeName} | {error, init_timeout, NodeName} | {error, startup_timeout, NodeName} | {error, not_alive, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="start-1"/> - -<p>Starts an Erlang node with name <c>Node</c> on the local host.</p> -<p><em>See also:</em> <seealso marker="#start-3">start/3</seealso>.</p> -</desc></func> -<func> -<name>start(Host, Node) -> Result</name> -<fsummary>Starts an Erlang node with name Node on host - Host with the default options.</fsummary> -<type> -<v>Node = atom()</v><v>Host = atom()</v><v>Result = {ok, NodeName} | {error, already_started, NodeName} | {error, started_not_connected, NodeName} | {error, boot_timeout, NodeName} | {error, init_timeout, NodeName} | {error, startup_timeout, NodeName} | {error, not_alive, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="start-2"/> - -<p>Starts an Erlang node with name <c>Node</c> on host - <c>Host</c> with the default options.</p> -<p><em>See also:</em> <seealso marker="#start-3">start/3</seealso>.</p> -</desc></func> -<func> -<name>start(Host, Node, Options::Opts) -> Result</name> -<fsummary>Starts an Erlang node with name Node on host - Host as specified by the combination of options in - Opts.</fsummary> -<type> -<v>Node = atom()</v><v>Host = atom()</v><v>Opts = [OptTuples]</v><v>OptTuples = {username, Username} | {password, Password} | {boot_timeout, BootTimeout} | {init_timeout, InitTimeout} | {startup_timeout, StartupTimeout} | {startup_functions, StartupFunctions} | {monitor_master, Monitor} | {kill_if_fail, KillIfFail} | {erl_flags, ErlangFlags}</v><v>Username = string()</v><v>Password = string()</v><v>BootTimeout = integer()</v><v>InitTimeout = integer()</v><v>StartupTimeout = integer()</v><v>StartupFunctions = [StartupFunctionSpec]</v><v>StartupFunctionSpec = {Module, Function, Arguments}</v><v>Module = atom()</v><v>Function = atom()</v><v>Arguments = [term]</v><v>Monitor = bool()</v><v>KillIfFail = bool()</v><v>ErlangFlags = string()</v><v>Result = {ok, NodeName} | {error, already_started, NodeName} | {error, started_not_connected, NodeName} | {error, boot_timeout, NodeName} | {error, init_timeout, NodeName} | {error, startup_timeout, NodeName} | {error, not_alive, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="start-3"/> - -<p>Starts an Erlang node with name <c>Node</c> on host - <c>Host</c> as specified by the combination of options in - <c>Opts</c>.</p> - - <p>Options <c>Username</c> and <c>Password</c> will be used - to log in onto the remote host <c>Host</c>. - Username, if omitted, defaults to the current user name, - and password is empty by default.</p> - - <p>A list of functions specified in the <c>Startup</c> option will be - executed after startup of the node. Note that all used modules should be - present in the code path on the <c>Host</c>.</p> - - <p>The timeouts are applied as follows: - <list> - <item> - <c>BootTimeout</c> - time to start the Erlang node, in seconds. - Defaults to 3 seconds. If node does not become pingable within this time, - the result <c>{error, boot_timeout, NodeName}</c> is returned; - </item> - <item> - <c>InitTimeout</c> - time to wait for the node until it calls the - internal callback function informing master about successfull startup. - Defaults to one second. - In case of timed out message the result - <c>{error, init_timeout, NodeName}</c> is returned; - </item> - <item> - <c>StartupTimeout</c> - time to wait intil the node finishes to run - the <c>StartupFunctions</c>. Defaults to one second. - If this timeout occurs, the result - <c>{error, startup_timeout, NodeName}</c> is returned. - </item> - </list></p> - - <p>Option <c>monitor_master</c> specifies, if the slave node should be - stopped in case of master node stop. Defaults to false.</p> - - <p>Option <c>kill_if_fail</c> specifies, if the slave node should be - killed in case of a timeout during initialization or startup. - Defaults to true. Note that node also may be still alive it the boot - timeout occurred, but it will not be killed in this case.</p> - - <p>Option <c>erlang_flags</c> specifies, which flags will be added - to the parameters of the <c>erl</c> executable.</p> - - <p>Special return values are: - <list> - <item><c>{error, already_started, NodeName}</c> - if the node with - the given name is already started on a given host;</item> - <item><c>{error, started_not_connected, NodeName}</c> - if node is - started, but not connected to the master node.</item> - <item><c>{error, not_alive, NodeName}</c> - if node on which the - <c>ct_slave:start/3</c> is called, is not alive. Note that - <c>NodeName</c> is the name of current node in this case.</item> - </list></p> - -</desc></func> -<func> -<name>stop(Node) -> Result</name> -<fsummary>Stops the running Erlang node with name Node on - the localhost.</fsummary> -<type> -<v>Node = atom()</v><v>Result = {ok, NodeName} | {error, not_started, NodeName} | {error, not_connected, NodeName} | {error, stop_timeout, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="stop-1"/> - -<p>Stops the running Erlang node with name <c>Node</c> on - the localhost.</p> -</desc></func> -<func> -<name>stop(Host, Node) -> Result</name> -<fsummary>Stops the running Erlang node with name Node on - host Host.</fsummary> -<type> -<v>Host = atom()</v><v>Node = atom()</v><v>Result = {ok, NodeName} | {error, not_started, NodeName} | {error, not_connected, NodeName} | {error, stop_timeout, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="stop-2"/> - -<p>Stops the running Erlang node with name <c>Node</c> on - host <c>Host</c>.</p> -</desc></func></funcs> - -<authors> -<aname> </aname> -<email> </email></authors></erlref>
\ No newline at end of file diff --git a/lib/common_test/doc/src/event_handler_chapter.xml b/lib/common_test/doc/src/event_handler_chapter.xml index 7f5144b760..904876ac46 100644 --- a/lib/common_test/doc/src/event_handler_chapter.xml +++ b/lib/common_test/doc/src/event_handler_chapter.xml @@ -63,12 +63,12 @@ <section> <title>Usage</title> <p>Event handlers may be installed by means of an <c>event_handler</c> - start flag (<c>run_test</c>) or option (<c>ct:run_test/1</c>), where the + start flag (<c>ct_run</c>) or option (<c>ct:run_test/1</c>), where the argument specifies the names of one or more event handler modules. Example:</p> - <p><c>$ run_test -suite test/my_SUITE -event_handler handlers/my_evh1 + <p><c>$ ct_run -suite test/my_SUITE -event_handler handlers/my_evh1 handlers/my_evh2 -pa $PWD/handlers</c></p> - <p>Use the <c><![CDATA[run_test -event_handler_init]]></c> option instead of + <p>Use the <c><![CDATA[ct_run -event_handler_init]]></c> option instead of <c><![CDATA[-event_handler]]></c> to pass start arguments to the event handler init function.</p> <p>All event handler modules must have gen_event behaviour. Note also that diff --git a/lib/common_test/doc/src/install_chapter.xml b/lib/common_test/doc/src/install_chapter.xml index 828588a673..89c497962d 100644 --- a/lib/common_test/doc/src/install_chapter.xml +++ b/lib/common_test/doc/src/install_chapter.xml @@ -34,8 +34,8 @@ <title>General information</title> <p>The two main interfaces for running tests with Common Test - are an executable program named run_test and an - erlang module named <c>ct</c>. The run_test program + are an executable program named ct_run and an + erlang module named <c>ct</c>. The ct_run program is compiled for the underlying operating system (e.g. Unix/Linux or Windows) during the build of the Erlang/OTP system, and is installed automatically with other executable programs in @@ -43,22 +43,22 @@ The <c>ct</c> interface functions can be called from the Erlang shell, or from any Erlang function, on any supported platform.</p> - <p>A legacy Bourne shell script - also named run_test - exists, + <p>A legacy Bourne shell script - named run_test - exists, which may be manually generated and installed. This script may be used - instead of the run_test program mentioned above, e.g. if the user + instead of the ct_run program mentioned above, e.g. if the user wishes to modify or customize the Common Test start flags in a simpler - way than making changes to the run_test C program.</p> + way than making changes to the ct_run C program.</p> <p>The Common Test application is installed with the Erlang/OTP system and no additional installation step is required to start using - Common Test by means of the run_test executable program, and/or the interface + Common Test by means of the ct_run executable program, and/or the interface functions in the <c>ct</c> module. If you wish to use the legacy Bourne - shell script version of run_test, however, this script needs to be + shell script version run_test, however, this script needs to be generated first, according to the instructions below.</p> <p><note>Before reading on, please note that since Common Test version 1.5, the run_test shell script is no longer required for starting - tests with Common Test from the OS command line. The run_test + tests with Common Test from the OS command line. The ct_run program (descibed above) is the new recommended command line interface for Common Test. The shell script exists mainly for legacy reasons and may not be updated in future releases of Common Test. It may even be removed. diff --git a/lib/common_test/doc/src/ref_man.xml b/lib/common_test/doc/src/ref_man.xml index 8be234d979..d5985bb021 100644 --- a/lib/common_test/doc/src/ref_man.xml +++ b/lib/common_test/doc/src/ref_man.xml @@ -63,7 +63,7 @@ Server application.</p> </description> <xi:include href="common_test_app.xml"/> - <xi:include href="run_test.xml"/> + <xi:include href="ct_run.xml"/> <!-- If you make modifications in the module list below, you also need to update CT_MODULES in Makefile. --> <xi:include href="ct.xml"/> diff --git a/lib/common_test/doc/src/run_test_chapter.xml b/lib/common_test/doc/src/run_test_chapter.xml index 1efff25f5b..94fcf6bf01 100644 --- a/lib/common_test/doc/src/run_test_chapter.xml +++ b/lib/common_test/doc/src/run_test_chapter.xml @@ -71,7 +71,7 @@ <p>If test suites or help modules include header files stored in other locations than the test directory, you may specify these include directories - by means of the <c><![CDATA[-include]]></c> flag with <c><![CDATA[run_test]]></c>, + by means of the <c><![CDATA[-include]]></c> flag with <c><![CDATA[ct_run]]></c>, or the <c><![CDATA[include]]></c> option with <c><![CDATA[ct:run_test/1]]></c>. In addition to this, an include path may be specified with an OS environment variable; <c><![CDATA[CT_INCLUDE_PATH]]></c>. Example (bash):</p> @@ -93,7 +93,7 @@ there instead.</p> <p>It is possible to disable the automatic compilation feature by using the - <c><![CDATA[-no_auto_compile]]></c> flag with <c><![CDATA[run_test]]></c>, or + <c><![CDATA[-no_auto_compile]]></c> flag with <c><![CDATA[ct_run]]></c>, or the <c><![CDATA[{auto_compile,false}]]></c> option with <c><![CDATA[ct:run_test/1]]></c>. With automatic compilation disabled, the user is responsible for compiling the test suite modules @@ -108,26 +108,26 @@ <section> <title>Running tests from the OS command line</title> - <p>The <c>run_test</c> program can be used for running tests from + <p>The <c>ct_run</c> program can be used for running tests from the OS command line, e.g. </p> <list> - <item><c><![CDATA[run_test -config <configfilenames> -dir <dirs>]]></c></item> - <item><c><![CDATA[run_test -config <configfilenames> -suite <suiteswithfullpath>]]></c> + <item><c><![CDATA[ct_run -config <configfilenames> -dir <dirs>]]></c></item> + <item><c><![CDATA[ct_run -config <configfilenames> -suite <suiteswithfullpath>]]></c> </item> - <item><c><![CDATA[run_test -userconfig <callbackmodulename> <configfilenames> -suite <suiteswithfullpath>]]></c> + <item><c><![CDATA[ct_run -userconfig <callbackmodulename> <configfilenames> -suite <suiteswithfullpath>]]></c> </item> - <item><c><![CDATA[run_test -config <configfilenames> -suite <suitewithfullpath> + <item><c><![CDATA[ct_run -config <configfilenames> -suite <suitewithfullpath> -group <groupnames> -case <casenames>]]></c></item> </list> <p>Examples:</p> - <p><c>$ run_test -config $CFGS/sys1.cfg $CFGS/sys2.cfg -dir $SYS1_TEST $SYS2_TEST</c></p> - <p><c>$ run_test -userconfig ct_config_xml $CFGS/sys1.xml $CFGS/sys2.xml -dir $SYS1_TEST $SYS2_TEST</c></p> - <p><c>$ run_test -suite $SYS1_TEST/setup_SUITE $SYS2_TEST/config_SUITE</c></p> - <p><c>$ run_test -suite $SYS1_TEST/setup_SUITE -case start stop</c></p> - <p><c>$ run_test -suite $SYS1_TEST/setup_SUITE -group installation -case start stop</c></p> + <p><c>$ ct_run -config $CFGS/sys1.cfg $CFGS/sys2.cfg -dir $SYS1_TEST $SYS2_TEST</c></p> + <p><c>$ ct_run -userconfig ct_config_xml $CFGS/sys1.xml $CFGS/sys2.xml -dir $SYS1_TEST $SYS2_TEST</c></p> + <p><c>$ ct_run -suite $SYS1_TEST/setup_SUITE $SYS2_TEST/config_SUITE</c></p> + <p><c>$ ct_run -suite $SYS1_TEST/setup_SUITE -case start stop</c></p> + <p><c>$ ct_run -suite $SYS1_TEST/setup_SUITE -group installation -case start stop</c></p> - <p>Other flags that may be used with <c>run_test</c>:</p> + <p>Other flags that may be used with <c>ct_run</c>:</p> <list> <item><c><![CDATA[-logdir <dir>]]></c>, specifies where the HTML log files are to be written.</item> <item><c><![CDATA[-label <name_of_test_run>]]></c>, associates the test run with a name that gets printed @@ -167,20 +167,20 @@ <note><p>Directories passed to Common Test may have either relative or absolute paths.</p></note> <note><p>Arbitrary start flags to the Erlang Runtime System may also be passed as - parameters to <c>run_test</c>. It is, for example, useful to be able to + parameters to <c>ct_run</c>. It is, for example, useful to be able to pass directories that should be added to the Erlang code server search path with the <c>-pa</c> or <c>-pz</c> flag. If you have common help- or library modules for test suites (separately compiled), stored in other directories than the test suite directories, these help/lib directories are preferrably added to the code path this way. Example:</p> - <p><c>$ run_test -dir ./chat_server -logdir ./chat_server/testlogs -pa $PWD/chat_server/ebin</c></p> + <p><c>$ ct_run -dir ./chat_server -logdir ./chat_server/testlogs -pa $PWD/chat_server/ebin</c></p> <p>Note how in this example, the absolute path of the <c>chat_server/ebin</c> directory is passed to the code server. This is essential since relative paths are stored by the code server as relative, and Common Test changes the current working directory of the Erlang Runtime System during the test run!</p> </note> - <p>For more information about the <c>run_test</c> program, see the + <p>For more information about the <c>ct_run</c> program, see the <seealso marker="install_chapter#general">Installation</seealso> chapter. </p> </section> @@ -188,7 +188,7 @@ <section> <title>Running tests from the Web based GUI</title> - <p>The web based GUI, VTS, is started with the <c>run_test</c> + <p>The web based GUI, VTS, is started with the <c>ct_run</c> program. From the GUI you can load config files, and select directories, suites and cases to run. You can also state the config files, directories, suites and cases on the command line @@ -196,22 +196,22 @@ </p> <list> - <item><c>run_test -vts</c></item> - <item><c><![CDATA[run_test -vts -config <configfilename>]]></c></item> - <item><c><![CDATA[run_test -vts -config <configfilename> -suite <suitewithfullpath> + <item><c>ct_run -vts</c></item> + <item><c><![CDATA[ct_run -vts -config <configfilename>]]></c></item> + <item><c><![CDATA[ct_run -vts -config <configfilename> -suite <suitewithfullpath> -case <casename>]]></c></item> </list> <p>From the GUI you can run tests and view the result and the logs. </p> - <p>Note that <c>run_test -vts</c> will try to open the Common Test start + <p>Note that <c>ct_run -vts</c> will try to open the Common Test start page in an existing web browser window or start the browser if it is not running. Which browser should be started may be specified with the browser start command option:</p> - <p><c><![CDATA[run_test -vts -browser <browser_start_cmd>]]></c></p> + <p><c><![CDATA[ct_run -vts -browser <browser_start_cmd>]]></c></p> <p>Example:</p> - <p><c><![CDATA[$ run_test -vts -browser 'firefox&']]></c></p> + <p><c><![CDATA[$ ct_run -vts -browser 'firefox&']]></c></p> <p>Note that the browser must run as a separate OS process or VTS will hang!</p> <p>If no specific browser start command is specified, Firefox will be the default browser on Unix platforms and Internet Explorer on Windows. @@ -227,10 +227,10 @@ <p>Common Test provides an Erlang API for running tests. The main (and most flexible) function for specifying and executing tests is called <c>ct:run_test/1</c>. This function takes the same start parameters as - the <c>run_test</c> program described above, only the flags are instead + the <c>ct_run</c> program described above, only the flags are instead given as options in a list of key-value tuples. E.g. a test specified - with <c>run_test</c> like:</p> - <p><c>$ run_test -suite ./my_SUITE -logdir ./results</c></p> + with <c>ct_run</c> like:</p> + <p><c>$ ct_run -suite ./my_SUITE -logdir ./results</c></p> <p>is with <c>ct:run_test/1</c> specified as:</p> <p><c>1> ct:run_test([{suite,"./my_SUITE"},{logdir,"./results"}]).</c></p> <p>For detailed documentation, please see the <c>ct</c> manual page.</p> @@ -253,17 +253,17 @@ manually and call <c>ct:install/1</c> to install any configuration data you might need (use <c>[]</c> as argument otherwise), then call <c>ct:start_interactive/0</c> to start Common Test. If you use - the <c>run_test</c> program, you may start the Erlang shell and Common Test + the <c>ct_run</c> program, you may start the Erlang shell and Common Test in the same go by using the <c>-shell</c> and, optionally, the <c>-config</c> and/or <c>-userconfig</c> flag. Examples: </p> <list> - <item><c>run_test -shell</c></item> - <item><c><![CDATA[run_test -shell -config cfg/db.cfg]]></c></item> - <item><c><![CDATA[run_test -shell -userconfig db_login testuser x523qZ]]></c></item> + <item><c>ct_run -shell</c></item> + <item><c><![CDATA[ct_run -shell -config cfg/db.cfg]]></c></item> + <item><c><![CDATA[ct_run -shell -userconfig db_login testuser x523qZ]]></c></item> </list> - <p>If no config file is given with the <c>run_test</c> command, + <p>If no config file is given with the <c>ct_run</c> command, a warning will be displayed. If Common Test has been run from the same directory earlier, the same config file(s) will be used again. If Common Test has not been run from this directory before, no @@ -293,7 +293,7 @@ <c>ctlog.html</c> in the <c><![CDATA[ct_run.<timestamp>]]></c> directory. A link to this file will be available in the file named <c>last_interactive.html</c> in the directory from which - you executed <c>run_test</c>. Currently, specifying a different + you executed <c>ct_run</c>. Currently, specifying a different root directory for the logs than the current working directory, is not supported.</p> @@ -309,7 +309,7 @@ <section> <title>Step by step execution of test cases with the Erlang Debugger</title> - <p>By means of <c>run_test -step [opts]</c>, or by passing the + <p>By means of <c>ct_run -step [opts]</c>, or by passing the <c>{step,Opts}</c> option to <c>ct:run_test/1</c>, it is possible to get the Erlang Debugger started automatically and use its graphical interface to investigate the state of the current test @@ -345,12 +345,12 @@ for <c>ct</c>). There are two general types of terms: configuration terms and test specification terms.</p> <p>With configuration terms it is possible to e.g. label the test - run (similar to <c>run_test -label</c>), evaluate arbitrary expressions + run (similar to <c>ct_run -label</c>), evaluate arbitrary expressions before starting a test, import configuration data (similar to - <c>run_test -config/-userconfig</c>), specify HTML log directories (similar + <c>ct_run -config/-userconfig</c>), specify HTML log directories (similar to - <c>run_test -logdir</c>), give aliases to test nodes and test + <c>ct_run -logdir</c>), give aliases to test nodes and test directories (to make a specification easier to read and maintain), enable code coverage analysis (see the <seealso marker="cover_chapter#cover">Code Coverage @@ -359,7 +359,7 @@ Event Handling</seealso> chapter). There is also a term for specifying include directories that should be passed on to the compiler when automatic compilation is performed (similar - to <c>run_test -include</c>, see above).</p> + to <c>ct_run -include</c>, see above).</p> <p>With test specification terms it is possible to state exactly which tests should run and in which order. A test term specifies either one or more suites, one or more test case groups, or one @@ -535,7 +535,7 @@ <p>It is possible for the user to provide a test specification that includes (for Common Test) unrecognizable terms. If this is desired, the <c>-allow_user_terms</c> flag should be used when starting tests with - <c>run_test</c>. This forces Common Test to ignore unrecognizable terms. + <c>ct_run</c>. This forces Common Test to ignore unrecognizable terms. Note that in this mode, Common Test is not able to check the specification for errors as efficiently as if the scanner runs in default mode. If <c>ct:run_test/1</c> is used for starting the tests, the relaxed scanner @@ -661,11 +661,11 @@ </pre> <p>To install the CSS file (Common Test inlines the definition in the - HTML code), the name may be provided when executing <c>run_test</c>. + HTML code), the name may be provided when executing <c>ct_run</c>. Example:</p> <pre> - $ run_test -dir $TEST/prog -stylesheet $TEST/styles/test_categories.css + $ ct_run -dir $TEST/prog -stylesheet $TEST/styles/test_categories.css </pre> <p>Categories in a CSS file installed with the <c>-stylesheet</c> flag @@ -738,7 +738,7 @@ means of time, it is also possible to specify what action Common Test should take upon timeout. Either Common Test performs all tests in the current run before stopping, or it stops as soon as the current test job is finished. Repetition can be activated by - means of <c>run_test</c> start flags, or tuples in the <c>ct:run:test/1</c> + means of <c>ct_run</c> start flags, or tuples in the <c>ct:run:test/1</c> option list argument. The flags (options in parenthesis) are:</p> <list> <item><c>-repeat N ({repeat,N})</c>, where <c>N</c> is a positive integer.</item> @@ -774,7 +774,7 @@ <p>Example 1:</p> <pre> - $ run_test -dir $TEST_ROOT/to1 $TEST_ROOT/to2 -duration 001000 -force_stop</pre> + $ ct_run -dir $TEST_ROOT/to1 $TEST_ROOT/to2 -duration 001000 -force_stop</pre> <p>Here the suites in test directory to1, followed by the suites in to2, will be executed in one test run. A timeout event will occur after 10 minutes. As long as there is time left, Common Test will repeat the test run (i.e. starting over with the to1 test). @@ -787,7 +787,7 @@ $ date Fri Sep 28 15:00:00 MEST 2007 - $ run_test -dir $TEST_ROOT/to1 $TEST_ROOT/to2 -until 160000</pre> + $ ct_run -dir $TEST_ROOT/to1 $TEST_ROOT/to2 -until 160000</pre> <p>Here the same test run as in the example above will be executed (and possibly repeated). In this example, however, the timeout will occur after 1 hour and when that happens, Common Test will finish the entire test run before stopping (i.e. the to1 and to2 test @@ -795,7 +795,7 @@ <p>Example 3:</p> <pre> - $ run_test -dir $TEST_ROOT/to1 $TEST_ROOT/to2 -repeat 5</pre> + $ ct_run -dir $TEST_ROOT/to1 $TEST_ROOT/to2 -repeat 5</pre> <p>Here the test run, including both the to1 and the to2 test, will be repeated 5 times.</p> <note><p>This feature should not be confused with the <c>repeat</c> property of a test @@ -814,7 +814,7 @@ of the <c>-silent_connections</c> flag:</p> <pre> - run_test -silent_connections [conn_types] + ct_run -silent_connections [conn_types] </pre> <p>where <c>conn_types</c> specifies <c>telnet, ftp, rpc</c> and/or <c>snmp</c>.</p> @@ -822,11 +822,11 @@ <p>Example:</p> <pre> - run_test ... -silent_connections telnet ftp</pre> + ct_run ... -silent_connections telnet ftp</pre> <p>switches off logging for telnet and ftp connections.</p> <pre> - run_test ... -silent_connections</pre> + ct_run ... -silent_connections</pre> <p>switches off logging for all connection types.</p> diff --git a/lib/common_test/doc/src/test_structure_chapter.xml b/lib/common_test/doc/src/test_structure_chapter.xml index cd38ae0c7c..b9ca59135d 100644 --- a/lib/common_test/doc/src/test_structure_chapter.xml +++ b/lib/common_test/doc/src/test_structure_chapter.xml @@ -144,7 +144,7 @@ be used when the test suite needs to write to files. </item> - <tag><em>run_test</em></tag> + <tag><em>ct_run</em></tag> <item> The name of an executable program that may be used as an interface for specifying and running diff --git a/lib/common_test/priv/Makefile.in b/lib/common_test/priv/Makefile.in index 6372bbc8d5..a6ac0f1a02 100644 --- a/lib/common_test/priv/Makefile.in +++ b/lib/common_test/priv/Makefile.in @@ -56,8 +56,8 @@ ifneq ($(findstring win32,$(TARGET)),win32) # # Files # -FILES = -SCRIPTS = +FILES = vts.tool +SCRIPTS = IMAGES = tile1.jpg # diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 8ae175f10d..1dbf83ee10 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -694,7 +694,7 @@ userdata(TestDir, Suite, Case) -> %%%----------------------------------------------------------------- -%%% @spec get_status() -> TestStatus | {error,Reason} +%%% @spec get_status() -> TestStatus | {error,Reason} | no_tests_running %%% TestStatus = [StatusElem] %%% StatusElem = {current,{Suite,TestCase}} | {successful,Successful} | %%% {failed,Failed} | {skipped,Skipped} | {total,Total} diff --git a/lib/common_test/src/ct_master.erl b/lib/common_test/src/ct_master.erl index 42e4cf08f4..2ea2ba106a 100644 --- a/lib/common_test/src/ct_master.erl +++ b/lib/common_test/src/ct_master.erl @@ -101,12 +101,14 @@ run([TS|TestSpecs],AllowUserTerms,InclNodes,ExclNodes) when is_list(TS), TSRec=#testspec{logdir=AllLogDirs, config=StdCfgFiles, userconfig=UserCfgFiles, + include=AllIncludes, init=AllInitOpts, event_handler=AllEvHs} -> AllCfgFiles = {StdCfgFiles, UserCfgFiles}, RunSkipPerNode = ct_testspec:prepare_tests(TSRec), RunSkipPerNode2 = exclude_nodes(ExclNodes,RunSkipPerNode), - run_all(RunSkipPerNode2,AllLogDirs,AllCfgFiles,AllEvHs,[],[],AllInitOpts,TS1) + run_all(RunSkipPerNode2,AllLogDirs,AllCfgFiles,AllEvHs, + AllIncludes,[],[],AllInitOpts,TS1) end, [{TS,Result} | run(TestSpecs,AllowUserTerms,InclNodes,ExclNodes)]; run([],_,_,_) -> @@ -163,11 +165,13 @@ run_on_node([TS|TestSpecs],AllowUserTerms,Node) when is_list(TS),is_atom(Node) - TSRec=#testspec{logdir=AllLogDirs, config=StdCfgFiles, init=AllInitOpts, + include=AllIncludes, userconfig=UserCfgFiles, event_handler=AllEvHs} -> AllCfgFiles = {StdCfgFiles, UserCfgFiles}, {Run,Skip} = ct_testspec:prepare_tests(TSRec,Node), - run_all([{Node,Run,Skip}],AllLogDirs,AllCfgFiles,AllEvHs,[],[],AllInitOpts,TS1) + run_all([{Node,Run,Skip}],AllLogDirs,AllCfgFiles,AllEvHs, + AllIncludes, [],[],AllInitOpts,TS1) end, [{TS,Result} | run_on_node(TestSpecs,AllowUserTerms,Node)]; run_on_node([],_,_) -> @@ -189,7 +193,7 @@ run_on_node(TestSpecs,Node) -> run_all([{Node,Run,Skip}|Rest],AllLogDirs, {AllStdCfgFiles, AllUserCfgFiles}=AllCfgFiles, - AllEvHs,NodeOpts,LogDirs,InitOptions,Specs) -> + AllEvHs,AllIncludes,NodeOpts,LogDirs,InitOptions,Specs) -> LogDir = lists:foldl(fun({N,Dir},_Found) when N == Node -> Dir; @@ -211,6 +215,14 @@ run_all([{Node,Run,Skip}|Rest],AllLogDirs, ({_N,_F},Fs) -> Fs; (F,Fs) -> [{userconfig, F}|Fs] end,[],AllUserCfgFiles), + + Includes = lists:foldr(fun({N,I},Acc) when N =:= Node -> + [I|Acc]; + ({_,_},Acc) -> + Acc; + (I,Acc) -> + [I | Acc] + end, [], AllIncludes), EvHs = lists:foldr(fun({N,H,A},Hs) when N == Node -> [{H,A}|Hs]; ({_N,_H,_A},Hs) -> Hs; @@ -219,10 +231,13 @@ run_all([{Node,Run,Skip}|Rest],AllLogDirs, NO = {Node,[{prepared_tests,{Run,Skip},Specs}, {logdir,LogDir}, + {include, Includes}, {config,StdCfgFiles}, {event_handler,EvHs}] ++ UserCfgFiles}, - run_all(Rest,AllLogDirs,AllCfgFiles,AllEvHs,[NO|NodeOpts],[LogDir|LogDirs],InitOptions,Specs); -run_all([],AllLogDirs,_,AllEvHs,NodeOpts,LogDirs,InitOptions,Specs) -> + run_all(Rest,AllLogDirs,AllCfgFiles,AllEvHs,AllIncludes, + [NO|NodeOpts],[LogDir|LogDirs],InitOptions,Specs); +run_all([],AllLogDirs,_,AllEvHs,_AllIncludes, + NodeOpts,LogDirs,InitOptions,Specs) -> Handlers = [{H,A} || {Master,H,A} <- AllEvHs, Master == master], MasterLogDir = case lists:keysearch(master,1,AllLogDirs) of {value,{_,Dir}} -> Dir; diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index 0a434666fa..b5ab4cbb6e 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -556,10 +556,37 @@ listenv(Telnet) -> %%% @hidden %%% @equiv ct:parse_table/1 parse_table(Data) -> - [Heading|Lines]= - [remove_space(string:tokens(L, "|"),[]) || L <- Data, hd(L)==$|], + {Heading, Rest} = get_headings(Data), + Lines = parse_row(Rest,[],size(Heading)), {Heading,Lines}. +get_headings(["|" ++ Headings | Rest]) -> + {remove_space(string:tokens(Headings, "|"),[]), Rest}; +get_headings([_ | Rest]) -> + get_headings(Rest); +get_headings([]) -> + {{},[]}. + +parse_row(["|" ++ _ = Row | T], Rows, NumCols) when NumCols > 1 -> + case string:tokens(Row, "|") of + Values when length(Values) =:= NumCols -> + parse_row(T,[remove_space(Values,[])|Rows], NumCols); + Values when length(Values) < NumCols -> + parse_row([Row ++"\n"++ hd(T) | tl(T)], Rows, NumCols) + end; +parse_row(["|" ++ _ = Row | T], Rows, 1 = NumCols) -> + case string:rchr(Row, $|) of + 1 -> + parse_row([Row ++"\n"++hd(T) | tl(T)], Rows, NumCols); + _Else -> + parse_row(T, [remove_space(string:tokens(Row,"|"),[])|Rows], + NumCols) + end; +parse_row([_Skip | T], Rows, NumCols) -> + parse_row(T, Rows, NumCols); +parse_row([], Rows, _NumCols) -> + lists:reverse(Rows). + remove_space([Str|Rest],Acc) -> remove_space(Rest,[string:strip(string:strip(Str),both,$')|Acc]); remove_space([],Acc) -> diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl index e0e1f93db2..5ac2866227 100644 --- a/lib/common_test/test/ct_master_SUITE.erl +++ b/lib/common_test/test/ct_master_SUITE.erl @@ -33,6 +33,13 @@ -define(eh, ct_test_support_eh). +-define(TEMP_DIR, case os:type() of + {win32,_} -> + "c:/Temp"; + _ -> + "/tmp" + end). + %%-------------------------------------------------------------------- %% TEST SERVER CALLBACK FUNCTIONS %%-------------------------------------------------------------------- @@ -43,18 +50,39 @@ %% there will be clashes with logging processes etc). %%-------------------------------------------------------------------- init_per_suite(Config) -> - Config1 = ct_test_support:init_per_suite(Config), - Config1. + ct_test_support:init_per_suite(Config). end_per_suite(Config) -> ct_test_support:end_per_suite(Config). init_per_testcase(TestCase, Config) -> - ct_test_support:init_per_testcase(TestCase, [{master, true}|Config]). + NodeCount = 5, + NodeNames = [list_to_atom("t_"++integer_to_list(N)) || + N <- lists:seq(1, NodeCount)], + ct_test_support:init_per_testcase( + TestCase,[{node_names,NodeNames}, + {master, true}|Config]). end_per_testcase(TestCase, Config) -> + case os:type() of + {win32,_} -> + %% If this is a windows run the logs are saved to /tmp and + %% then moved to private_dir as a tar because otherwise + %% the file names become too long! :( + Files = filelib:wildcard(filename:join(?TEMP_DIR,"slave.*")), + erl_tar:create( + filename:join( + proplists:get_value(priv_dir,Config),"slaves.tar.gz"), + Files,[compressed]), + os:cmd("rm -rf "++filename:join(?TEMP_DIR,"slave.*")); + _ -> + ok + end, + ct_test_support:end_per_testcase(TestCase, Config). +all() -> + all(suite). all(doc) -> [""]; @@ -67,15 +95,35 @@ all(suite) -> %% TEST CASES %%-------------------------------------------------------------------- ct_master_test(Config) when is_list(Config)-> - NodeCount = 5, + NodeNames = proplists:get_value(node_names, Config), DataDir = ?config(data_dir, Config), PrivDir = ?config(priv_dir, Config), - NodeNames = [list_to_atom("testnode_"++integer_to_list(N)) || - N <- lists:seq(1, NodeCount)], + FileName = filename:join(PrivDir, "ct_master_spec.spec"), Suites = [master_SUITE], TSFile = make_spec(DataDir, FileName, NodeNames, Suites, Config), + ERPid = ct_test_support:start_event_receiver(Config), + spawn(ct@ancalagon, + fun() -> + dbg:tracer(),dbg:p(all,c), + dbg:tpl(erlang, spawn_link, 4,x), + receive ok -> ok end + end), + [{TSFile, ok}] = run_test(ct_master_test, FileName, Config), + + Events = ct_test_support:get_events(ERPid, Config), + + ct_test_support:log_events(groups_suite_1, + reformat(Events, ?eh), + ?config(priv_dir, Config)), + find_events(NodeNames, [{tc_start,{master_SUITE,init_per_suite}}, + {tc_start,{master_SUITE,first_testcase}}, + {tc_start,{master_SUITE,second_testcase}}, + {tc_start,{master_SUITE,third_testcase}}, + {tc_start,{master_SUITE,end_per_suite}}], + Events), + ok. %%%----------------------------------------------------------------- @@ -112,13 +160,25 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config)-> PrivDir = ?config(priv_dir, Config), LD = lists:map(fun(NodeName)-> - {logdir, NodeName, get_log_dir(PrivDir, NodeName)} + {logdir, NodeName, get_log_dir(os:type(),PrivDir, NodeName)} end, NodeNames) ++ [{logdir, master, PrivDir}], - - ct_test_support:write_testspec(N++C++S++LD++NS, FileName). - -get_log_dir(PrivDir, NodeName)-> + EvHArgs = [{cbm,ct_test_support},{trace_level,?config(trace_level,Config)}], + EH = [{event_handler,master,[?eh],EvHArgs}], + + Include = [{include,filename:join([DataDir,"master/include"])}], + + ct_test_support:write_testspec(N++Include++EH++C++S++LD++NS, FileName). + +get_log_dir({win32,_},PrivDir, NodeName)-> + case filelib:is_dir(?TEMP_DIR) of + false -> + file:make_dir(?TEMP_DIR); + _ -> + ok + end, + get_log_dir(tmp, ?TEMP_DIR,NodeName); +get_log_dir(_,PrivDir,NodeName) -> LogDir = filename:join(PrivDir, io_lib:format("slave.~p", [NodeName])), file:make_dir(LogDir), LogDir. @@ -126,11 +186,34 @@ get_log_dir(PrivDir, NodeName)-> run_test(_Name, FileName, Config)-> [{FileName, ok}] = ct_test_support:run(ct_master, run, [FileName], Config). -reformat_events(Events, EH) -> +reformat(Events, EH) -> ct_test_support:reformat(Events, EH). %%%----------------------------------------------------------------- %%% TEST EVENTS %%%----------------------------------------------------------------- +find_events([], _CheckEvents, _) -> + ok; +find_events([NodeName|NodeNames],CheckEvents,AllEvents) -> + find_events(NodeNames, CheckEvents, + remove_events(add_host(NodeName),CheckEvents, AllEvents, [])). + +remove_events(Node,[{Name,Data} | RestChecks], + [{?eh,#event{ name = Name, node = Node, data = Data }}|RestEvs], + Acc) -> + remove_events(Node, RestChecks, RestEvs, Acc); +remove_events(Node, Checks, [Event|RestEvs], Acc) -> + remove_events(Node, Checks, RestEvs, [Event | Acc]); +remove_events(_Node, [], [], Acc) -> + lists:reverse(Acc); +remove_events(Node, Events, [], Acc) -> + test_server:format("Could not find events: ~p in ~p for node ~p", + [Events, lists:reverse(Acc), Node]), + exit(event_not_found). + +add_host(NodeName) -> + {ok, HostName} = inet:gethostname(), + list_to_atom(atom_to_list(NodeName)++"@"++HostName). + expected_events(_)-> -[]. + []. diff --git a/lib/common_test/test/ct_master_SUITE_data/master/include/test.hrl b/lib/common_test/test/ct_master_SUITE_data/master/include/test.hrl new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/lib/common_test/test/ct_master_SUITE_data/master/include/test.hrl diff --git a/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl index e37ec3659c..032d69ad9f 100644 --- a/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl +++ b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl @@ -28,6 +28,7 @@ -compile(export_all). -include_lib("common_test/include/ct.hrl"). +-include("test.hrl"). suite() -> []. diff --git a/lib/common_test/test/ct_misc_1_SUITE.erl b/lib/common_test/test/ct_misc_1_SUITE.erl index eb6c6aa101..8c8b2d0d41 100644 --- a/lib/common_test/test/ct_misc_1_SUITE.erl +++ b/lib/common_test/test/ct_misc_1_SUITE.erl @@ -62,7 +62,7 @@ all(doc) -> all(suite) -> [ - beam_me_up + beam_me_up, parse_table ]. %%-------------------------------------------------------------------- @@ -106,6 +106,66 @@ beam_me_up(Config) when is_list(Config) -> TestEvents = events_to_check(beam_me_up, 1), ok = ct_test_support:verify_events(TestEvents, Events, Config). + +parse_table(suite) -> + [parse_table_empty, parse_table_single, + parse_table_multiline_row, + parse_table_one_column_multiline, + parse_table_one_column_simple]. + +parse_table_empty(Config) when is_list(Config) -> + + String = ["+----+-------+---------+---------+----------+------+--------+", + "| id | col11 | col2222 | col3333 | col4 | col5 | col6666 |", + "+----+-------+---------+---------+----------+------+--------+", + "+----+-------+---------+---------+----------+------+--------+", + "Query Done: 0 records selected"], + + {{"id","col11","col2222","col3333","col4","col5","col6666"},[]} = + ct:parse_table(String). + + +parse_table_single(Config) when is_list(Config) -> + + String = ["+------+--------+--------------+------------+------------------+---------+--------+---------+-----------+", + "| id | col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 |", +"+------+--------+--------------+------------+------------------+---------+--------+---------+-----------+", + "| 0 | 0 | -1407231560 | -256 | -1407231489 | 1500 | 1 | 1 | 1 |", + "+------+--------+--------------+------------+------------------+---------+--------+---------+-----------+" + "Query Done: 1 record selected"], + + {{"id","col1","col2","col3","col4","col5","col6","col7","col8"}, + [{"0","0","-1407231560","-256","-1407231489", "1500","1","1","1"}]} = + ct:parse_table(String). + +parse_table_multiline_row(Config) when is_list(Config) -> + + String = ["+------+--------+--------------+------------+------------------+---------+--------+---------+-----------+", + "| id | col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 |", +"+------+--------+--------------+------------+------------------+---------+--------+---------+-----------+", + "| 0 | 0 | Free test string", + " on more lines", + "than one", + "| -256 | -1407231489 | 1500 | 1 | 1 | 1 |", + "+------+--------+--------------+------------+------------------+---------+--------+---------+-----------+" + "Query Done: 1 record selected"], + + {{"id","col1","col2","col3","col4","col5","col6","col7","col8"}, + [{"0","0","Free test string\n on more lines\nthan one\n", + "-256","-1407231489", "1500","1","1","1"}]} = + ct:parse_table(String). + +parse_table_one_column_simple(Config) when is_list(Config) -> + + String = ["|test|","|test value|"], + + {{"test"},[{"test value"}]} = ct:parse_table(String). + +parse_table_one_column_multiline(Config) when is_list(Config) -> + String = ["|test|","|test","value|"], + + {{"test"},[{"test\nvalue"}]} = ct:parse_table(String). + %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- |