aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_dbg_SUITE.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2018-08-09 10:19:13 +0200
committerHans Nilsson <[email protected]>2018-08-13 12:27:51 +0200
commitc376b4b89e7780a17d6e3f6eb1046763c7729622 (patch)
tree7e43477b38ca23ef330166bc42d460c7b4d6b10a /lib/ssh/test/ssh_dbg_SUITE.erl
parent6bd4fc6943112db14c0b71fac707cf3def22aa83 (diff)
downloadotp-c376b4b89e7780a17d6e3f6eb1046763c7729622.tar.gz
otp-c376b4b89e7780a17d6e3f6eb1046763c7729622.tar.bz2
otp-c376b4b89e7780a17d6e3f6eb1046763c7729622.zip
ssh: Test group for circular buffer tracing
Diffstat (limited to 'lib/ssh/test/ssh_dbg_SUITE.erl')
-rw-r--r--lib/ssh/test/ssh_dbg_SUITE.erl56
1 files changed, 54 insertions, 2 deletions
diff --git a/lib/ssh/test/ssh_dbg_SUITE.erl b/lib/ssh/test/ssh_dbg_SUITE.erl
index 33763dbf15..ab7918fa90 100644
--- a/lib/ssh/test/ssh_dbg_SUITE.erl
+++ b/lib/ssh/test/ssh_dbg_SUITE.erl
@@ -38,7 +38,8 @@ suite() ->
{timetrap,{seconds,60}}].
all() ->
- [{group, dbg}
+ [{group, dbg},
+ {group, circ_buf}
].
groups() ->
@@ -46,7 +47,11 @@ groups() ->
dbg_alg_terminate,
dbg_ssh_messages,
dbg_connections,
- dbg_channels]}
+ dbg_channels]},
+ {circ_buf, [], [cb_basic,
+ cb_print,
+ cb_macros_print
+ ]}
].
%%--------------------------------------------------------------------
@@ -346,6 +351,53 @@ dbg_channels(Config) ->
stop_and_fail_if_unhandled_dbg_msgs(Ref, [C,D], Pid).
%%--------------------------------------------------------------------
+cb_basic(_Config) ->
+ %% Check that the circular buffer is disabled at start:
+ [] = ssh_dbg:cbuf_list(),
+ disabled = ssh_dbg:cbuf_in(anything),
+ [] = ssh_dbg:cbuf_list(),
+ %% Start it and enter three values, first is duplicated;
+ ok = ssh_dbg:cbuf_start(3),
+ ok = ssh_dbg:cbuf_in(v1),
+ ok = ssh_dbg:cbuf_in(v1),
+ ok = ssh_dbg:cbuf_in(v2),
+ ok = ssh_dbg:cbuf_in(v3),
+ [{v3,_,1}, {v2,_,1}, {v1,_,2}] = ssh_dbg:cbuf_list(),
+ %% Check that a fourth value erase the first entered:
+ ok = ssh_dbg:cbuf_in(v4),
+ [{v4,_,1}, {v3,_,1}, {v2,_,1}] = ssh_dbg:cbuf_list(),
+ %% Check that entering a value that is in the tail but not in the head is treated as a new value:
+ ok = ssh_dbg:cbuf_in(v2),
+ [{v2,_,1}, {v4,_,1}, {v3,_,1}] = ssh_dbg:cbuf_list(),
+ %% Stop and check that the buffer is returned:
+ [{v2,_,1}, {v4,_,1}, {v3,_,1}] = ssh_dbg:cbuf_stop_clear(),
+ %% Stopping a stopped buffer returns empty:
+ [] = ssh_dbg:cbuf_stop_clear(),
+ %% Check that a value can't be entered in a stopped buffer:
+ disabled = ssh_dbg:cbuf_in(v2).
+
+%%--------------------------------------------------------------------
+cb_print(_Config) ->
+ ssh_dbg:cbuf_start(),
+ [begin
+ ssh_dbg:cbuf_in(V),
+ ct:log("Enter ~p",[V])
+ end || V <- lists:seq(1,10)],
+ ct:log("~s",[ssh_dbg:fmt_cbuf_items()]),
+ ssh_dbg:cbuf_stop_clear().
+
+%%--------------------------------------------------------------------
+cb_macros_print(_Config) ->
+ ssh_dbg:cbuf_start(),
+ [begin
+ V = {test,V0},
+ ?CIRC_BUF_IN(V),
+ ct:log("Enter ~p",[V])
+ end || V0 <- lists:seq(1,5)],
+ ct:log("~s",[ssh_dbg:fmt_cbuf_items()]),
+ ssh_dbg:cbuf_stop_clear().
+
+%%--------------------------------------------------------------------
%%--------------------------------------------------------------------
%%--------------------------------------------------------------------