Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,20 @@ jobs:
run: |
make REBAR=${{matrix.rebar}} check

# Keep this no more than 2 releases away from EQC-mini beam files. Currently
# they are on OTP 25 so we can use erlang up to version 27 technically.
#
eqc-mini-25:
name: eqc-mini-25
runs-on: ubuntu-latest
container:
image: erlang:25
steps:
- uses: actions/checkout@v6
- name: rebar3 make check-with-eqc
run: |
make REBAR=rebar3 check-with-eqc

eqc-mini-27:
name: eqc-mini-27
prop-tests:
name: proper-${{matrix.otp_version}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
otp_version: [27, 28]
container:
image: erlang:27
image: erlang:${{matrix.otp_version}}
steps:
- uses: actions/checkout@v6
- name: rebar3 make check-with-eqc
- name: rebar3 make check-with-proper
run: |
make REBAR=rebar3 check-with-eqc
make REBAR=rebar3 check-with-proper

lcov-coverage:
name: lcov-coverage
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ erln8.config
hexer.config
rebar.lock
TEST-*.xml
/eqc/
/bench/
coverage.info
coverage-jiffy.info
coverage-html/
.eqc-info
current_counterexample.eqc
*.gcda
*.gcno
.cache
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ clean:
rm -rf logs
rm -rf .eunit
rm -f test/*.beam
rm -rf eqc
rm -rf _build
rm -f c_src/*.gcno c_src/*.gcda c_src/ryu/*.gcno c_src/ryu/*.gcda
rm -f coverage.info coverage-jiffy.info
Expand All @@ -30,10 +29,8 @@ eunit:

check: build eunit

check-with-eqc: install_eqc build eunit

install_eqc:
./test/install_eqc_mini.sh
check-with-proper:
$(REBAR) as proper eunit

# macos:
# brew install lcov on macos
Expand All @@ -42,7 +39,7 @@ install_eqc:
#
coverage:
$(MAKE) clean
CFLAGS="--coverage -O0" CXXFLAGS="--coverage -O0" LDFLAGS="--coverage" $(MAKE) check-with-eqc
CFLAGS="--coverage -O0" CXXFLAGS="--coverage -O0" LDFLAGS="--coverage" $(MAKE) check-with-proper
@lcov --capture --directory c_src -o coverage.info --ignore-errors inconsistent,unsupported
@lcov --extract coverage.info '*/c_src/*' --exclude '*/ryu/*' -o coverage-jiffy.info --ignore-errors inconsistent,unsupported
@genhtml coverage-jiffy.info -o coverage-html --title "jiffy lcov report"
Expand All @@ -56,4 +53,4 @@ release:
erlc -o test/ $<


.PHONY: all clean distclean depends build etap eunit check coverage
.PHONY: all clean distclean depends build etap eunit check check-with-proper coverage
10 changes: 9 additions & 1 deletion c_src/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,16 @@ enc_ensure(Encoder* e, size_t req)
return 0;
}

// If we have_buffer we don't want to short-cut return unless that
// buffer size is big enough. If it isn't, release it and allocate a
// newer one of the right size. Otherwise we could return a small
// buffer then risk a memory overrwrite on a memcpy.
if(e->have_buffer) {
return 1;
if(req < (e->buffer.size - e->i)) {
return 1;
}
enif_release_binary(&e->buffer);
e->have_buffer = 0;
}
}

Expand Down
9 changes: 9 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@
{eunit_opts, [
verbose
]}.

% Use in CI only. It's totaly optional
%
{profiles, [
{proper, [
{deps, [{proper, "1.5.0"}]},
{erl_opts, [{d, 'WITH_PROPER'}]}
]}
]}.
29 changes: 2 additions & 27 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,6 @@
% See the LICENSE file for more information.
%

% Only run the EQC checks when EQC is present.
%
% We have a helper tests/install_eqc_mini.sh script to install it ./eqc, so we
% look for it there first, and add that to the code path. Users may have also
% installed it directly into their OTP distribution, which should be fine,
% code:which(eqc) should find that as well.
%
LocalEQC = filename:join([filename:dirname(SCRIPT), "eqc", "ebin"]),
case filelib:is_dir(LocalEQC) of
true -> code:add_patha(LocalEQC);
false -> ok
end,
HaveEQC = code:which(eqc) =/= non_existing,
ErlOpts = if not HaveEQC -> []; true ->
[{d, 'HAVE_EQC'}]
end,

Config1 = case lists:keyfind(erl_opts, 1, CONFIG) of
{erl_opts, Opts} ->
NewOpts = {erl_opts, Opts ++ ErlOpts},
lists:keyreplace(erl_opts, 1, CONFIG, NewOpts);
false ->
CONFIG ++ [{erl_opts, ErlOpts}]
end,

IsRebar2 = case lists:keyfind(rebar, 1, application:loaded_applications()) of
{rebar, _Desc, Vsn} ->
case string:split(Vsn, ".") of
Expand All @@ -39,9 +14,9 @@ end,

case IsRebar2 of
true ->
Config1;
CONFIG;
false ->
Config1 ++ [
CONFIG ++ [
{plugins, [{pc, "~> 1.15"}]},
case os:type() of
{win32, _} -> {artifacts, ["priv/jiffy.dll"]};
Expand Down
40 changes: 0 additions & 40 deletions test/install_eqc_mini.sh

This file was deleted.

Loading
Loading