Permalink
Browse files

Clean up after having run CoDel test cases.

Otherwise, we run out of ETS tables pretty quickly!
  • Loading branch information...
1 parent 61704eb commit 76ebd3734c6d9b2d588794dbaa65fd494105822d @jlouis committed Dec 26, 2012
Showing with 14 additions and 5 deletions.
  1. +8 −3 eqc_test/sv_codel_eqc.erl
  2. +3 −1 src/sv_codel.erl
  3. +3 −1 src/sv_queue_ets.erl
View
@@ -44,15 +44,18 @@ xprop_termination() ->
?FORALL(M, g_model(),
begin
_R = eval(M),
+ cleanup(M),
true
end).
%% Various observations on a CoDel queue
prop_observations() ->
?FORALL(M, g_model(),
begin
- #model { t = T, st = ST} = eval(M),
- case sv_codel:dequeue(T+1, ST) of
+ #model { t = T, st = ST} = Res = eval(M),
+ R = sv_codel:dequeue(T+1, ST),
+ cleanup(Res),
+ case R of
{empty, _Dropped, EmptyState} ->
verify_empty(EmptyState);
{drop, [_Pkt], _CoDelState} ->
@@ -67,7 +70,6 @@ prop_observations() ->
verify_dropped(CoDelState) ->
%% We dropped packets, our state must be dropping
- PL = sv_codel:qstate(CoDelState),
classify(true, dropped, true).
verify_empty(EmptyState) ->
@@ -87,6 +89,9 @@ verify_empty(EmptyState) ->
%% Operations
%% ----------------------------------------------
+cleanup(#model { st = ST }) ->
+ sv_codel:delete(ST).
+
new(Target, Interval) ->
#model { t = 0, st = sv_codel:init(Target, Interval) }.
View
@@ -13,7 +13,7 @@
%% Public API
-export([new/0, in/3, out/2, len/1]).
--export([init/2, enqueue/3, dequeue/2]).
+-export([init/2, enqueue/3, dequeue/2, delete/1]).
%% Scrutiny
-export([qstate/1]).
@@ -98,6 +98,8 @@ out(Ts, CoDelState) ->
init(Target, Interval) when Target > Interval -> exit(misconfiguration);
init(Target, Interval) -> #state{ target = Target, interval = Interval }.
+delete(#state { queue = Q }) -> ?Q:delete(Q).
+
%% @doc Enqueue a packet
%% <p>Enqueue packet `Pkt' at time `TS' into the queue.</p>
%% @end
View
@@ -22,13 +22,15 @@
%%% @end
-module(sv_queue_ets).
--export([new/0]).
+-export([new/0, delete/1]).
-export([out/2, len/1, in/3]).
new() ->
ets:new(queue, [protected, ordered_set]).
+delete(Q) -> ets:delete(Q).
+
out(_Ts, QName) ->
case ets:first(QName) of
'$end_of_table' -> {empty, [], QName};

0 comments on commit 76ebd37

Please sign in to comment.