Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests. Cosmetic changes.

  • Loading branch information...
commit 8b613a6eb71770552eb50042ff9bce6e45c2f52c 1 parent 492a845
@ates authored
View
5 .gitignore
@@ -1,2 +1,3 @@
-*.[oa]
-*.beam
+ebin
+.test
+*.swp
View
5 Makefile
@@ -1,4 +1,3 @@
-
REBAR=$(shell which rebar || echo ./rebar)
all: compile
@@ -15,3 +14,7 @@ compile: $(REBAR)
clean: $(REBAR)
@$(REBAR) clean
+test:
+ @$(REBAR) xref eunit
+
+.PHONY: test
View
13 ebin/pkt.app
@@ -1,13 +0,0 @@
-{application, pkt,
- [
- {description, "Network packet parsing library"},
- {vsn, "0.03"},
- {modules, [
- pkt
- ]},
- {applications, [
- kernel,
- stdlib
- ]},
- {env, []}
- ]}.
View
3  rebar.config
@@ -0,0 +1,3 @@
+{xref_checks, [undefined_function_calls]}.
+
+{eunit_opts, [verbose, {report, {eunit_surefire, [{dir, "."}]}}]}.
View
5 src/pkt.app.src
@@ -0,0 +1,5 @@
+{application, pkt, [
+ {description, "Network packet parsing library"},
+ {vsn, "0.03"},
+ {applications, [kernel, stdlib]}
+]}.
View
3  src/pkt.erl
@@ -60,14 +60,13 @@
proto/1,
tcp/1,
udp/1,
+ sctp/1,
dlt/1
]).
-
decapsulate_dlt(Dlt, Data) ->
decapsulate({link_type(Dlt), Data}, []).
-
decapsulate({DLT, Data}) when is_integer(DLT) ->
decapsulate({link_type(DLT), Data}, []);
decapsulate({DLT, Data}) when is_atom(DLT) ->
View
11 test/pkt_tests.erl
@@ -0,0 +1,11 @@
+-module(pkt_tests).
+
+-include("pkt.hrl").
+-include("pkt_tests.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
+sctp_test() ->
+ {SCTP, []} = pkt:sctp(?SCTP_PACKET),
+ Chunk = erlang:hd(SCTP#sctp.chunks),
+ ?assertEqual(length(SCTP#sctp.chunks), 1),
+ ?assertEqual(Chunk#sctp_chunk.payload#sctp_chunk_data.tsn, 2860946939).
View
16 test/pkt_tests.hrl
@@ -0,0 +1,16 @@
+-define(SCTP_PACKET,
+ <<0,80,128,69,233,183,59,195,103,102,136,252,0,3,1,65,170,134,149,251,0,0,0,
+ 0,0,0,0,0,72,84,84,80,47,49,46,49,32,50,48,48,32,79,75,13,10,68,97,116,101,
+ 58,32,84,104,117,44,32,49,50,32,74,97,110,32,50,48,48,54,32,48,50,58,53,56,
+ 58,48,48,32,71,77,84,13,10,83,101,114,118,101,114,58,32,65,112,97,99,104,
+ 101,47,50,46,48,46,53,52,32,40,85,110,105,120,41,32,68,65,86,47,50,32,80,
+ 72,80,47,52,46,52,46,49,13,10,76,97,115,116,45,77,111,100,105,102,105,101,
+ 100,58,32,84,104,117,44,32,48,53,32,74,97,110,32,50,48,48,54,32,48,50,58,
+ 48,53,58,48,55,32,71,77,84,13,10,69,84,97,103,58,32,34,52,50,48,51,51,98,
+ 45,52,97,55,102,45,102,54,50,102,49,97,99,48,34,13,10,65,99,99,101,112,116,
+ 45,82,97,110,103,101,115,58,32,98,121,116,101,115,13,10,67,111,110,116,101,
+ 110,116,45,76,101,110,103,116,104,58,32,49,57,48,55,49,13,10,75,101,101,
+ 112,45,65,108,105,118,101,58,32,116,105,109,101,111,117,116,61,49,53,44,32,
+ 109,97,120,61,49,48,48,13,10,67,111,110,110,101,99,116,105,111,110,58,32,
+ 75,101,101,112,45,65,108,105,118,101,13,10,67,111,110,116,101,110,116,45,
+ 84,121,112,101,58,32,105,109,97,103,101,47,103,105,102,13,10,13,10,0,0,0>>).
Please sign in to comment.
Something went wrong with that request. Please try again.