From a94f9d5fc1fa278e962629bad4c75e24d2de63c3 Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Mon, 16 Jun 2014 20:15:04 +0900 Subject: [PATCH 1/8] add quickcheck-ci.com files --- .eqc_ci | 2 ++ EQC_CI_LICENCE.txt | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .eqc_ci create mode 100644 EQC_CI_LICENCE.txt diff --git a/.eqc_ci b/.eqc_ci new file mode 100644 index 0000000..a90a57a --- /dev/null +++ b/.eqc_ci @@ -0,0 +1,2 @@ +{build, "./rebar eunit"}. +{test_path, ".eunit"}. diff --git a/EQC_CI_LICENCE.txt b/EQC_CI_LICENCE.txt new file mode 100644 index 0000000..6d2a058 --- /dev/null +++ b/EQC_CI_LICENCE.txt @@ -0,0 +1,34 @@ +This file is an agreement between Quviq AB ("Quviq"), Sven Hultins +Gata 9, Gothenburg, Sweden, and the committers to the github +repository in which the file appears ("the owner"). By placing this +file in a github repository, the owner agrees to the terms below. + +The purpose of the agreement is to enable Quviq AB to provide a +continuous integration service to the owner, whereby the code in the +repository ("the source code") is tested using Quviq's test tools, and +the test results are made available on the web. The test results +include test output, generated test cases, and a copy of the source +code in the repository annotated with coverage information ("the test +results"). + +The owner agrees that Quviq may run the tests in the source code and +display the test results on the web, without obligation. + +The owner warrants that running the tests in the source code and +displaying the test results on the web violates no laws, licences or other +agreements. In the event of such a violation, the owner accepts full +responsibility. + +The owner warrants that the source code is not malicious, and will not +mount an attack on either Quviq's server or any other server--for +example by taking part in a denial of service attack, or by attempting +to send unsolicited emails. + +The owner warrants that the source code does not attempt to reverse +engineer Quviq's code. + +Quviq reserves the right to exclude repositories that break this +agreement from its continuous integration service. + +Any dispute arising from the use of Quviq's service will be resolved +under Swedish law. From f4f1b70b2d029c849db4c05cedf03f04b92cf478 Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Mon, 16 Jun 2014 20:17:57 +0900 Subject: [PATCH 2/8] use make --- .eqc_ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eqc_ci b/.eqc_ci index a90a57a..d6e2248 100644 --- a/.eqc_ci +++ b/.eqc_ci @@ -1,2 +1,2 @@ -{build, "./rebar eunit"}. +{build, "make test"}. {test_path, ".eunit"}. From 4262fb55ca8a5b7007f380bdfba04483407c7064 Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Mon, 16 Jun 2014 20:28:18 +0900 Subject: [PATCH 3/8] msgpack eqc test test --- test/msgpack_eqc.erl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/msgpack_eqc.erl diff --git a/test/msgpack_eqc.erl b/test/msgpack_eqc.erl new file mode 100644 index 0000000..a2ea834 --- /dev/null +++ b/test/msgpack_eqc.erl @@ -0,0 +1,41 @@ +%% +%% MessagePack for Erlang +%% +%% Copyright (C) 2009-2014 UENISHI Kota +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% + +-module(msgpack_eqc). + + +-ifdef(EQC). + +-include_lib("eqc/include/eqc.hrl"). +-include_lib("eunit/include/eunit.hrl"). + +eqc_test_() -> + {spawn, + [ + ?_assert(quickcheck(numtests(10, prop_msgpack()))) + ]}. + + +prop_msgpack() -> + ?FORALL(Int, int(), + begin + ?debugVal(Int), + Int =:= Int + end). + +-endif. From fce46aab56ffc0fc791fc858d592d7fdd17b4b6b Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Mon, 16 Jun 2014 22:08:35 +0900 Subject: [PATCH 4/8] add smalle eqc test smaller numtests --- .eqc_ci | 5 ++- rebar.config | 3 +- test/msgpack_eqc.erl | 86 +++++++++++++++++++++++++++++++++++++--- test/msgpack_tests.erl | 90 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 9 deletions(-) diff --git a/.eqc_ci b/.eqc_ci index d6e2248..279961e 100644 --- a/.eqc_ci +++ b/.eqc_ci @@ -1,2 +1,3 @@ -{build, "make test"}. -{test_path, ".eunit"}. +{build, "make deps test"}. +{test_path, "_build/test/lib/msgpack/ebin"}. +{test_path, "_build/test/lib/msgpack/test"}. diff --git a/rebar.config b/rebar.config index a59ebf4..11c6956 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,8 @@ {require_otp_vsn, "17|18"}. {erl_opts, [fail_on_warning, debug_info, warn_untyped_record]}. +%%, {parse_transform, eqc_cover}]}. + {xref_checks, [undefined_function_calls]}. {cover_enabled, true}. {cover_print_enabled, false}. @@ -11,7 +13,6 @@ "src/msgpack_ext.erl" ]}. - %% {port_sources, ["c_src/*.c"]}. %% {port_env, [ %% %% Make sure to set -fPIC when compiling leveldb diff --git a/test/msgpack_eqc.erl b/test/msgpack_eqc.erl index a2ea834..b5a56e6 100644 --- a/test/msgpack_eqc.erl +++ b/test/msgpack_eqc.erl @@ -19,23 +19,97 @@ -module(msgpack_eqc). +-ifdef(TEST). -ifdef(EQC). +-compile(export_all). -include_lib("eqc/include/eqc.hrl"). -include_lib("eunit/include/eunit.hrl"). +-define(NUMTESTS, 16). +-define(QC_OUT(P), + eqc:on_output(fun(Str, Args) -> + io:format(user, Str, Args) end, P)). +-define(_assertProp(S), + {timeout, ?NUMTESTS * 10, + ?_assert(quickcheck(numtests(?NUMTESTS, ?QC_OUT(S))))}). + eqc_test_() -> - {spawn, + {inparallel, [ - ?_assert(quickcheck(numtests(10, prop_msgpack()))) - ]}. + ?_assertProp(prop_msgpack()), + ?_assertProp(prop_msgpack([{format, jiffy}])), + ?_assertProp(prop_msgpack([{format, jsx}])) + ]}. +-ifndef(without_map). +%% eqc_17_0_test_() -> +%% ?_assertProp(prop_msgpack([{format, map}])). +-endif. prop_msgpack() -> - ?FORALL(Int, int(), + ?FORALL(Obj, msgpack_object(), + begin + {ok, Obj} =:= msgpack:unpack(msgpack:pack(Obj)) + end). + +prop_msgpack(Options) -> + ?FORALL(Obj, msgpack_object(), begin - ?debugVal(Int), - Int =:= Int + {ok, Obj} =:= msgpack:unpack(msgpack:pack(Obj, Options), Options) end). +msgpack_object() -> + oneof(container_types() ++ primitive_types()). + +container_types() -> + [ fix_array(), array16() ]. +%% TODO: add map + +primitive_types() -> + [null(), + positive_fixnum(), negative_fixnum(), + int8(), int16(), int32(), int64(), + uint8(), uint16(), uint32(), uint64(), + eqc_gen:real(), eqc_gen:bool(), + fix_raw(), raw16(), raw32() + ]. + %% fix_raw(), raw16(), raw32()]). + +positive_fixnum() -> choose(0, 127). +negative_fixnum() -> choose(-32, -1). + +int8() -> choose(-16#80, 16#7F). +int16() -> oneof([choose(-16#8000, -16#81), + choose(16#80, 16#7FFF)]). +int32() -> oneof([choose(-16#80000000, -16#8001), + choose(16#10000, 16#7FFFFFFF)]). +int64() -> oneof([choose(-16#8000000000000000, -16#80000001), + choose(16#100000000, 16#7FFFFFFFFFFFFFFF)]). + +uint8() -> choose(0, 16#FF). +uint16() -> choose(16#100, 16#FFFF). +uint32() -> choose(16#10000, 16#FFFFFFFF). +uint64() -> choose(16#100000000, 16#FFFFFFFFFFFFFFFF). + +null() -> null. + +fix_raw() -> + ?LET(Integer, choose(0, 31), + ?LET(Binary, binary(Integer), Binary)). + +raw16() -> + ?LET(Integer, uint16(), + ?LET(Binary, binary(Integer), Binary)). + +raw32() -> + ?LET(Binary, binary(65537), Binary). + +fix_array() -> + eqc_gen:resize(16, eqc_gen:list(oneof(primitive_types()))). + +array16() -> + eqc_gen:resize(128, eqc_gen:list(oneof(primitive_types()))). + +-endif. -endif. diff --git a/test/msgpack_tests.erl b/test/msgpack_tests.erl index 065d9d0..5160fdc 100644 --- a/test/msgpack_tests.erl +++ b/test/msgpack_tests.erl @@ -21,6 +21,11 @@ -import(msgpack, [pack/2, unpack/2, pack/1, unpack/1]). +-define(EQC, true). +-ifdef(EQC). +-include_lib("eqc/include/eqc.hrl"). +-endif. + -include_lib("eunit/include/eunit.hrl"). -include("msgpack.hrl"). @@ -487,3 +492,88 @@ benchmark_p0_test_() -> multirunner("t2b/b2t", fun erlang:term_to_binary/1, fun erlang:binary_to_term/1))}]. + + +-ifdef(EQC). +-define(NUMTESTS, 1024). +-define(QC_OUT(P), + eqc:on_output(fun(Str, Args) -> + io:format(user, Str, Args) end, P)). +-define(_assertProp(S), + {timeout, ?NUMTESTS * 10, + ?_assert(quickcheck(numtests(?NUMTESTS, ?QC_OUT(S))))}). + +eqc_test_() -> + {inparallel, + [ + ?_assertProp(prop_msgpack()), + ?_assertProp(prop_msgpack([{format, jiffy}])), + ?_assertProp(prop_msgpack([{format, jsx}])) + ]}. + + +prop_msgpack() -> + ?FORALL(Obj, msgpack_object(), + begin + {ok, Obj} =:= msgpack:unpack(msgpack:pack(Obj)) + end). + +prop_msgpack(Options) -> + ?FORALL(Obj, msgpack_object(), + begin + {ok, Obj} =:= msgpack:unpack(msgpack:pack(Obj, Options), Options) + end). + +msgpack_object() -> + oneof(container_types() ++ primitive_types()). + +container_types() -> + [ fix_array(), array16() ]. +%% TODO: add map + +primitive_types() -> + [null(), + positive_fixnum(), negative_fixnum(), + int8(), int16(), int32(), int64(), + uint8(), uint16(), uint32(), uint64(), + eqc_gen:real(), eqc_gen:bool(), + fix_raw(), raw16(), raw32() + ]. + %% fix_raw(), raw16(), raw32()]). + +positive_fixnum() -> choose(0, 127). +negative_fixnum() -> choose(-32, -1). + +int8() -> choose(-16#80, 16#7F). +int16() -> oneof([choose(-16#8000, -16#81), + choose(16#80, 16#7FFF)]). +int32() -> oneof([choose(-16#80000000, -16#8001), + choose(16#10000, 16#7FFFFFFF)]). +int64() -> oneof([choose(-16#8000000000000000, -16#80000001), + choose(16#100000000, 16#7FFFFFFFFFFFFFFF)]). + +uint8() -> choose(0, 16#FF). +uint16() -> choose(16#100, 16#FFFF). +uint32() -> choose(16#10000, 16#FFFFFFFF). +uint64() -> choose(16#100000000, 16#FFFFFFFFFFFFFFFF). + +null() -> null. + +fix_raw() -> + ?LET(Integer, choose(0, 31), + ?LET(Binary, binary(Integer), Binary)). + +raw16() -> + ?LET(Integer, uint16(), + ?LET(Binary, binary(Integer), Binary)). + +raw32() -> + ?LET(Binary, binary(65537), Binary). + +fix_array() -> + eqc_gen:resize(16, eqc_gen:list(oneof(primitive_types()))). + +array16() -> + eqc_gen:resize(128, eqc_gen:list(oneof(primitive_types()))). + +-endif. From 707af7db455f4bce588277d760b4149749b7c44e Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Wed, 9 Dec 2015 19:05:10 +0900 Subject: [PATCH 5/8] Introduce rebar3 eqc plugin --- .eqc_ci | 3 ++- {test => eqc}/msgpack_eqc.erl | 5 ----- rebar.config | 4 ++++ test/msgpack_tests.erl | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) rename {test => eqc}/msgpack_eqc.erl (96%) diff --git a/.eqc_ci b/.eqc_ci index 279961e..10d2702 100644 --- a/.eqc_ci +++ b/.eqc_ci @@ -1,3 +1,4 @@ -{build, "make deps test"}. +{build, "./rebar3 compile eqc"}. {test_path, "_build/test/lib/msgpack/ebin"}. {test_path, "_build/test/lib/msgpack/test"}. +{test_path, "_build/test/lib/msgpack/eqc"}. diff --git a/test/msgpack_eqc.erl b/eqc/msgpack_eqc.erl similarity index 96% rename from test/msgpack_eqc.erl rename to eqc/msgpack_eqc.erl index b5a56e6..f82099c 100644 --- a/test/msgpack_eqc.erl +++ b/eqc/msgpack_eqc.erl @@ -42,11 +42,6 @@ eqc_test_() -> ?_assertProp(prop_msgpack([{format, jsx}])) ]}. --ifndef(without_map). -%% eqc_17_0_test_() -> -%% ?_assertProp(prop_msgpack([{format, map}])). --endif. - prop_msgpack() -> ?FORALL(Obj, msgpack_object(), begin diff --git a/rebar.config b/rebar.config index 11c6956..cb62335 100644 --- a/rebar.config +++ b/rebar.config @@ -13,6 +13,10 @@ "src/msgpack_ext.erl" ]}. +{plugins, [ + {rebar3_eqc, ".*", {git, "https://github.com/kellymclaughlin/rebar3-eqc-plugin.git", {tag, "0.0.8"}}} +]}. + %% {port_sources, ["c_src/*.c"]}. %% {port_env, [ %% %% Make sure to set -fPIC when compiling leveldb diff --git a/test/msgpack_tests.erl b/test/msgpack_tests.erl index 5160fdc..d963e0b 100644 --- a/test/msgpack_tests.erl +++ b/test/msgpack_tests.erl @@ -21,7 +21,6 @@ -import(msgpack, [pack/2, unpack/2, pack/1, unpack/1]). --define(EQC, true). -ifdef(EQC). -include_lib("eqc/include/eqc.hrl"). -endif. From 5c112ac41efcd780ac5b4fa232b249334266842d Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Fri, 11 Dec 2015 11:07:34 +0900 Subject: [PATCH 6/8] Fix quickcheck-ci.com test --- .eqc_ci | 5 ++--- .gitignore | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.eqc_ci b/.eqc_ci index 10d2702..f8e94ad 100644 --- a/.eqc_ci +++ b/.eqc_ci @@ -1,4 +1,3 @@ {build, "./rebar3 compile eqc"}. -{test_path, "_build/test/lib/msgpack/ebin"}. -{test_path, "_build/test/lib/msgpack/test"}. -{test_path, "_build/test/lib/msgpack/eqc"}. +{test_path, "./_build/eqc/lib/msgpack/ebin"}. +{test_path, "./_build/eqc/lib/msgpack"}. diff --git a/.gitignore b/.gitignore index dee7d67..75b64f6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ ebin/*.app deps *.so _build +.rebar3 From 266bb3b1acdd4483c5a4acab74c44f9eefa4909c Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Fri, 11 Dec 2015 11:40:00 +0900 Subject: [PATCH 7/8] Remove duplicated tests --- test/msgpack_tests.erl | 89 ------------------------------------------ 1 file changed, 89 deletions(-) diff --git a/test/msgpack_tests.erl b/test/msgpack_tests.erl index d963e0b..065d9d0 100644 --- a/test/msgpack_tests.erl +++ b/test/msgpack_tests.erl @@ -21,10 +21,6 @@ -import(msgpack, [pack/2, unpack/2, pack/1, unpack/1]). --ifdef(EQC). --include_lib("eqc/include/eqc.hrl"). --endif. - -include_lib("eunit/include/eunit.hrl"). -include("msgpack.hrl"). @@ -491,88 +487,3 @@ benchmark_p0_test_() -> multirunner("t2b/b2t", fun erlang:term_to_binary/1, fun erlang:binary_to_term/1))}]. - - --ifdef(EQC). --define(NUMTESTS, 1024). --define(QC_OUT(P), - eqc:on_output(fun(Str, Args) -> - io:format(user, Str, Args) end, P)). --define(_assertProp(S), - {timeout, ?NUMTESTS * 10, - ?_assert(quickcheck(numtests(?NUMTESTS, ?QC_OUT(S))))}). - -eqc_test_() -> - {inparallel, - [ - ?_assertProp(prop_msgpack()), - ?_assertProp(prop_msgpack([{format, jiffy}])), - ?_assertProp(prop_msgpack([{format, jsx}])) - ]}. - - -prop_msgpack() -> - ?FORALL(Obj, msgpack_object(), - begin - {ok, Obj} =:= msgpack:unpack(msgpack:pack(Obj)) - end). - -prop_msgpack(Options) -> - ?FORALL(Obj, msgpack_object(), - begin - {ok, Obj} =:= msgpack:unpack(msgpack:pack(Obj, Options), Options) - end). - -msgpack_object() -> - oneof(container_types() ++ primitive_types()). - -container_types() -> - [ fix_array(), array16() ]. -%% TODO: add map - -primitive_types() -> - [null(), - positive_fixnum(), negative_fixnum(), - int8(), int16(), int32(), int64(), - uint8(), uint16(), uint32(), uint64(), - eqc_gen:real(), eqc_gen:bool(), - fix_raw(), raw16(), raw32() - ]. - %% fix_raw(), raw16(), raw32()]). - -positive_fixnum() -> choose(0, 127). -negative_fixnum() -> choose(-32, -1). - -int8() -> choose(-16#80, 16#7F). -int16() -> oneof([choose(-16#8000, -16#81), - choose(16#80, 16#7FFF)]). -int32() -> oneof([choose(-16#80000000, -16#8001), - choose(16#10000, 16#7FFFFFFF)]). -int64() -> oneof([choose(-16#8000000000000000, -16#80000001), - choose(16#100000000, 16#7FFFFFFFFFFFFFFF)]). - -uint8() -> choose(0, 16#FF). -uint16() -> choose(16#100, 16#FFFF). -uint32() -> choose(16#10000, 16#FFFFFFFF). -uint64() -> choose(16#100000000, 16#FFFFFFFFFFFFFFFF). - -null() -> null. - -fix_raw() -> - ?LET(Integer, choose(0, 31), - ?LET(Binary, binary(Integer), Binary)). - -raw16() -> - ?LET(Integer, uint16(), - ?LET(Binary, binary(Integer), Binary)). - -raw32() -> - ?LET(Binary, binary(65537), Binary). - -fix_array() -> - eqc_gen:resize(16, eqc_gen:list(oneof(primitive_types()))). - -array16() -> - eqc_gen:resize(128, eqc_gen:list(oneof(primitive_types()))). - --endif. From d157f4991b54a03e81439054b6517b28820f52b0 Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Fri, 11 Dec 2015 11:45:41 +0900 Subject: [PATCH 8/8] Test to override install step https://github.com/travis-ci/travis-build/blob/64294c8d2e0b228e449f9baa47eeb2c6333d893b/lib/travis/build/script/erlang.rb#L22-L29 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 055f73a..ec91c36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: erlang sudo: false +install: echo rebar3 script: make check-all notifications: email: false