aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test')
-rw-r--r--lib/common_test/doc/src/ct_slave.xml139
-rw-r--r--lib/common_test/priv/Makefile.in4
-rw-r--r--lib/common_test/src/ct.erl2
-rw-r--r--lib/common_test/src/ct_util.erl31
-rw-r--r--lib/common_test/test/ct_misc_1_SUITE.erl62
5 files changed, 93 insertions, 145 deletions
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) -&gt; 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) -&gt; 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) -&gt; 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) -&gt; 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) -&gt; 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/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_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_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
%%%-----------------------------------------------------------------