Skip to content
Browse files

Use common test

  • Loading branch information...
1 parent 15a1492 commit 9d3be3588666536fca2fb7dac835b04ae177456f @msantos committed Mar 12, 2016
Showing with 33 additions and 32 deletions.
  1. +33 −32 test/{ewpcap_tests.erl → ewpcap_SUITE.erl}
View
65 test/ewpcap_tests.erl → test/ewpcap_SUITE.erl
@@ -1,4 +1,4 @@
-%% Copyright (c) 2012-2014, Michael Santos <michael.santos@gmail.com>
+%% Copyright (c) 2012-2016, Michael Santos <michael.santos@gmail.com>
%% All rights reserved.
%%
%% Redistribution and use in source and binary forms, with or without
@@ -28,25 +28,37 @@
%% LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
%% ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
%% POSSIBILITY OF SUCH DAMAGE.
--module(ewpcap_tests).
+-module(ewpcap_SUITE).
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
+-include_lib("common_test/include/ct.hrl").
-include("ewpcap.hrl").
-open_test() ->
- case ewpcap:getifaddrs() of
+-export([
+ all/0,
+ groups/0
+ ]).
+
+-export([
+ sniff/1,
+ getifaddrs/1,
+ no_tests/1
+ ]).
+
+
+all() ->
+ Priv = case ewpcap:getifaddrs() of
{ok, []} ->
- error_logger:info_report([
- {skipping, "beam does not have privileges to run test"}
- ]),
- ok;
+ nopriv;
{ok, _Iflist} ->
- open_test_1()
- end.
+ priv
+ end,
+ [{group, Priv}].
-open_test_1() ->
+groups() ->
+ [{priv, [], [sniff, getifaddrs]},
+ {nopriv, [], [no_tests]}].
+
+sniff(_Config) ->
{ok, Ifname} = ewpcap:dev(),
{ok, Socket} = ewpcap:open(Ifname, [{filter, "tcp and port 29"}|opt()]),
@@ -58,29 +70,18 @@ open_test_1() ->
ok.
-getifaddrs_test() ->
+getifaddrs(_Config) ->
case os:type() of
{unix, _} ->
- getifaddrs_test_1();
+ {ok, Iflist1} = ewpcap:getifaddrs(),
+ {ok, Iflist2} = inet:getifaddrs(),
+ ifcmp(Iflist1, Iflist2);
_ ->
- error_logger:info_report([
- {skipping,
- "results of ewpcap:getifaddrs/0 and inet:getifaddrs/0 may differ on this platorm"}
- ]),
- ok
+ {skip, "results of ewpcap:getifaddrs/0 and inet:getifaddrs/0 may differ on this platorm"}
end.
-getifaddrs_test_1() ->
- case ewpcap:getifaddrs() of
- {ok, []} ->
- error_logger:info_report([
- {skipping, "beam does not have privileges to run test"}
- ]),
- ok;
- {ok, Iflist1} ->
- {ok, Iflist2} = inet:getifaddrs(),
- ifcmp(Iflist1, Iflist2)
- end.
+no_tests(_Config) ->
+ {skip, "No tests"}.
ifcmp(Iflist1, Iflist2) ->
% Get the common interfaces

0 comments on commit 9d3be35

Please sign in to comment.
Something went wrong with that request. Please try again.