Add coverage for the C code
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f9eb027..f889e3a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -20,9 +20,10 @@
with:
otp-version: ${{ matrix.otp }}
- run: make rebar3
- - run: make
+ - run: make deps
- run: make test
- run: make dialyzer
- run: make codecov
+ - run: make gcov
- run: pip install --user codecov
- run: /home/runner/.local/bin/codecov
diff --git a/Makefile b/Makefile
index 18c74d0..8138f3f 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@
./rebar3 get-deps
test-compile: rebar3 test-deps
- ./rebar3 compile
+ ./rebar3 as test compile
test: test-compile
./rebar3 as test ct
@@ -23,6 +23,9 @@
codecov: _build/test/cover/ct.coverdata
./rebar3 as test codecov analyze
+gcov: test-compile
+ gcov -o c_src fast_pbkdf2
+
rebar3:
wget https://github.com/erlang/rebar3/releases/download/3.13.2/rebar3 &&\
chmod u+x rebar3
diff --git a/rebar.config b/rebar.config
index f98cd40..d66aa05 100644
--- a/rebar.config
+++ b/rebar.config
@@ -10,6 +10,13 @@
]},
{plugins, [
{rebar3_codecov, {git, "https://github.com/esl/rebar3_codecov.git", {ref, "6bd31cc"}}}
+ ]},
+ {port_env,
+ [
+ {"CFLAGS", "$CFLAGS -std=c99 -O3 -g -Wall -Wextra -fPIC --coverage"},
+ {"LDFLAGS", "$LDFLAGS --coverage"},
+ {"LDLIBS", "$LDLIBS -lcrypto"},
+ {"DRV_LINK_TEMPLATE", "$DRV_LINK_TEMPLATE $LDLIBS"}
]}
]}
]
diff --git a/test/pbkdf2_SUITE.erl b/test/pbkdf2_SUITE.erl
index 61fb712..1521711 100644
--- a/test/pbkdf2_SUITE.erl
+++ b/test/pbkdf2_SUITE.erl
@@ -179,7 +179,7 @@
test_vector_sha256_5(_Config) ->
{P,S,It,DkLen,Result} = {<<"passwordPASSWORDpassword">>,<<"saltSALTsaltSALTsaltSALTsaltSALTsalt">>,4096,40,
- base16:decode(<<"348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c4e2a1fb8dd53e1c635518c7dac47e9">>)},
+ base16:decode(<<"348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c4e2a1fb8dd53e1c635518c7dac47e9">>)},
?assertEqual(Result, fast_pbkdf2:pbkdf2(sha256, P, S, It, DkLen)).
test_vector_sha256_6(_Config) ->