Skip to content

Commit 15e5a2b

Browse files
committed
Test a list of ring_names for read-only ets_rings
1 parent f3a8d9b commit 15e5a2b

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

test/epocxy/ets_ring_buffer_ro_SUITE.erl

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,50 @@ end_per_testcase (_Test_Case, Config) -> Config.
6767
%%% Unit tests for ets_ring_buffer_ro core
6868
%%%------------------------------------------------------------------------------
6969

70-
%% Validate any atom can be used as a ring_name and info/1 will report properly.
70+
gen_ring_names() ->
71+
?LET(Ring_Names, list(atom()), Ring_Names).
72+
73+
%% Validate any atom can be used as a ring_name and list will report properly.
7174
-spec proper_check_create(config()) -> ok.
7275
proper_check_create(_Config) ->
7376
{ok, Sup_Pid} = epocxy_sup:start_link(),
7477
Fsm_Pid = whereis(epocxy_ets_fsm),
7578

7679
ct:log("Test using an atom as a ring name"),
77-
Test_Ring_Name = ?FORALL(Ring_Name, ?SUCHTHAT(Ring_Name, atom(), Ring_Name =/= ''),
78-
check_create_test(Ring_Name, Sup_Pid, Fsm_Pid)),
80+
Test_Ring_Name = ?FORALL(Names, gen_ring_names(),
81+
case [N || N <- Names, N =/= ''] of
82+
[] -> true;
83+
Ring_Names -> check_create_test(Ring_Names, Sup_Pid, Fsm_Pid)
84+
end),
7985
true = proper:quickcheck(Test_Ring_Name, ?PQ_NUM(5)),
8086
ct:comment("Successfully tested atoms as ring_names"),
8187

8288
%% Terminate the ets fsm server, then the epocxy supervisor.
8389
cleanup(Sup_Pid, Fsm_Pid),
8490
ok.
8591

86-
check_create_test(Ring_Name, Sup_Pid, Fsm_Pid) ->
92+
check_create_test(Ring_Names, Sup_Pid, Fsm_Pid) ->
8793
%% No rings exist yet...
8894
[] = ?TM:list(),
8995
[] = ?TM:list(missing_ring),
9096

91-
ct:comment("Testing ring_name: ~p", [Ring_Name]),
92-
ct:log("Testing ring_name: ~p", [Ring_Name]),
93-
true = ?TM:create(Ring_Name),
94-
0 = ?TM:ring_size(Ring_Name),
95-
true = ?TM:delete(Ring_Name),
97+
ct:comment ("Testing ring_names ~p", [Ring_Names]),
98+
ct:log ("Testing ring_names ~p", [Ring_Names]),
99+
Num_Rings = length(Ring_Names),
100+
Exp_Counts = lists:duplicate(Num_Rings, 0),
101+
Exp_Counts = [check_one_ring(R) || R <- Ring_Names],
102+
103+
ct:comment("Deleting all rings"),
104+
Exp_Deletes = lists:duplicate(Num_Rings, true),
105+
Exp_Deletes = [?TM:delete(R) || R <- Ring_Names],
106+
[] = ?TM:list(),
96107

97108
true.
98109

110+
check_one_ring(Ring_Name) ->
111+
true = ?TM:create (Ring_Name),
112+
0 = ?TM:ring_size (Ring_Name).
113+
99114
cleanup(Pid, Fsm_Pid) ->
100115
supervisor:terminate_child(Pid, Fsm_Pid),
101116
unlink(Pid),

0 commit comments

Comments
 (0)