From d1c9718da765aa3195a46d9e6daf372aa80a5b1b Mon Sep 17 00:00:00 2001 From: Nicolas Ojeda Bar Date: Sat, 23 Dec 2017 02:41:30 +0100 Subject: [PATCH 1/7] Switch to jbuilder --- .gitignore | 10 +--- META | 25 -------- Makefile | 116 ++++---------------------------------- VERSION | 1 + jbuild | 25 ++++++++ sha.install | 31 ++++++++++ sha.opam | 8 +-- sha1.c => sha1c.c | 0 sha256.c => sha256c.c | 0 sha512.c => sha512c.c | 0 sha.test.ml => shatest.ml | 6 +- 11 files changed, 76 insertions(+), 146 deletions(-) delete mode 100644 META create mode 100644 VERSION create mode 100644 jbuild create mode 100644 sha.install rename sha1.c => sha1c.c (100%) rename sha256.c => sha256c.c (100%) rename sha512.c => sha512c.c (100%) rename sha.test.ml => shatest.ml (97%) diff --git a/.gitignore b/.gitignore index 492d7ff..655e32b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,2 @@ -*.a -*.o -*.so -*.cmi -*.cmx -*.cmxa -*.cmo -*.cma +_build +.merlin diff --git a/META b/META deleted file mode 100644 index 0cc9015..0000000 --- a/META +++ /dev/null @@ -1,25 +0,0 @@ -description="SHA-1 and SHA-2 family implementations" -version="1.11" -archive(byte)="sha.cma" -archive(native)="sha.cmxa" - -package "sha1" ( - description="SHA-1 Implementation" - version="1.11" - archive(byte)="sha1.cma" - archive(native)="sha1.cmxa" -) - -package "sha256" ( - description="SHA-256 Implementation" - version="1.11" - archive(byte)="sha256.cma" - archive(native)="sha256.cmxa" -) - -package "sha512" ( - description="SHA-512 Implementation" - version="1.11" - archive(byte)="sha512.cma" - archive(native)="sha512.cmxa" -) diff --git a/Makefile b/Makefile index 1a67ec5..13b6762 100644 --- a/Makefile +++ b/Makefile @@ -1,111 +1,17 @@ -CFLAGS = -Wall -O3 -funroll-loops -fPIC -DPIC -OCAMLC = ocamlc -OCAMLOPT = ocamlopt -OCAMLMKLIB = ocamlmklib +all: + jbuilder build @install -# on unix architecture we just use the default value -EXE= -OBJ=o -A=a -SO=so +test: + jbuilder runtest -# on windows architecture redefine some values -ifeq "$(shell ocamlc -config | fgrep 'os_type:')" "os_type: Win32" - EXE=.exe - SO=dll -ifeq "$(shell ocamlc -config | fgrep 'ccomp_type:')" "ccomp_type: msvc" - OBJ=obj - A=lib -endif -endif - -OCAMLOPTFLAGS = - -OCAML_TEST_INC = -I `ocamlfind query oUnit` -OCAML_TEST_LIB = `ocamlfind query oUnit`/oUnit.cmxa - -PROGRAMS_BINS = sha1sum sha256sum sha512sum -PROGRAMS = $(addsuffix $(EXE), $(PROGRAMS_BINS)) - -allshabytes = $(foreach n, 1 256 512, sha$(n).lib.$(OBJ) sha$(n)_stubs.$(OBJ) sha$(n).cmo) -allshaopts = $(foreach n, 1 256 512, sha$(n).lib.$(OBJ) sha$(n)_stubs.$(OBJ) sha$(n).cmx) - -all: sha1.cmi sha1.cma sha1.cmxa sha256.cma sha256.cmxa sha512.cma sha512.cmxa sha.cma sha.cmxa - -bins: $(PROGRAMS) - -sha1sum$(EXE): sha1.cmxa sha256.cmxa sha512.cmxa shasum.cmx - $(OCAMLOPT) $(OCAMLOPTFLAGS) -o $@ -cclib -L. $+ - -sha256sum$(EXE): sha1sum$(EXE) - cp $< $@ - -sha512sum$(EXE): sha1sum$(EXE) - cp $< $@ - -sha.cma: $(allshabytes) - $(OCAMLMKLIB) -o sha $(allshabytes) - -sha.cmxa: $(allshaopts) - $(OCAMLMKLIB) -o sha $(allshaopts) - -sha1.cma: sha1.cmi sha1.lib.$(OBJ) sha1_stubs.$(OBJ) sha1.cmo - $(OCAMLMKLIB) -o sha1 sha1.lib.$(OBJ) sha1_stubs.$(OBJ) sha1.cmo - -sha1.cmxa: sha1.cmi sha1.lib.$(OBJ) sha1_stubs.$(OBJ) sha1.cmx - $(OCAMLMKLIB) -o sha1 sha1.lib.$(OBJ) sha1_stubs.$(OBJ) sha1.cmx - -sha256.cma: sha256.cmi sha256.lib.$(OBJ) sha256_stubs.$(OBJ) sha256.cmo - $(OCAMLMKLIB) -o sha256 sha256.lib.$(OBJ) sha256_stubs.$(OBJ) sha256.cmo - -sha256.cmxa: sha256.cmi sha256.lib.$(OBJ) sha256_stubs.$(OBJ) sha256.cmx - $(OCAMLMKLIB) -o sha256 sha256.lib.$(OBJ) sha256_stubs.$(OBJ) sha256.cmx - -sha512.cma: sha512.cmi sha512.lib.$(OBJ) sha512_stubs.$(OBJ) sha512.cmo - $(OCAMLMKLIB) -o sha512 sha512.lib.$(OBJ) sha512_stubs.$(OBJ) sha512.cmo - -sha512.cmxa: sha512.cmi sha512.lib.$(OBJ) sha512_stubs.$(OBJ) sha512.cmx - $(OCAMLMKLIB) -o sha512 sha512.lib.$(OBJ) sha512_stubs.$(OBJ) sha512.cmx - -tests: sha.test - ./sha.test - -sha.test: sha1.cmxa sha256.cmxa sha512.cmxa sha.test.cmx - -%.test: - $(OCAMLOPT) -o $@ $(OCAML_BFLAGS) unix.cmxa $(OCAML_TEST_INC) $(OCAML_TEST_LIB) $+ - -%.test.cmo: %.test.ml - $(OCAMLC) -c -o $@ $(OCAML_BFLAGS) -custom $(OCAML_TEST_INC) $< - -%.test.cmx: %.test.ml - $(OCAMLOPT) -c -o $@ $(OCAML_BFLAGS) $(OCAML_TEST_INC) $< - -%.cmo: %.ml - $(OCAMLC) -c -o $@ $< - -%.cmi: %.mli - $(OCAMLC) -c -o $@ $< - -%.cmx: %.ml - $(OCAMLOPT) $(OCAMLOPTFLAGS) -c -o $@ $< - -%.$(OBJ): %.c - $(OCAMLC) -ccopt "$(CFLAGS)" -c -o $@ $< - -%.lib.$(OBJ): %.$(OBJ) - mv $< $@ - -.PHONY: clean install uninstall doc doc: - [ -d html ] && rm -f html/* || mkdir html - ocamldoc -html -d html *.mli + jbuilder build @doc -clean: - rm -f *.$(OBJ) *.$(A) *.$(SO) *.cmo *.cmi *.cma *.cmx *.cmxa sha.test $(PROGRAMS) - -install: sha1.cma sha1.cmxa sha256.cma sha256.cmxa sha512.cma sha512.cmxa sha.cma sha.cmxa META - ocamlfind install sha META *.cmx sha1.cmi sha1.cma sha1.cmxa sha256.cmi sha256.cma sha256.cmxa sha512.cmi sha512.cma sha512.cmxa sha.cma sha.cmxa *.$(A) *.$(SO) +install: + jbuilder install uninstall: - ocamlfind remove sha + jbuilder uninstall + +clean: + jbuilder clean diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..c044b1a --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.10 diff --git a/jbuild b/jbuild new file mode 100644 index 0000000..46fa79d --- /dev/null +++ b/jbuild @@ -0,0 +1,25 @@ +(jbuild_version 1) + +(library + ((name sha) + (public_name sha) + (synopsis "SHA-1 and SHA-2 family implementations") + (wrapped false) + (modules (sha1 sha256 sha512)) + (c_flags (-Wall -O3 -funroll-loops)) ; Needs adapting for Windows + (c_names (sha1c sha1_stubs sha256c sha256_stubs sha512c sha512_stubs)))) + +(executable + ((name shasum) + (modules (shasum)) + (libraries (sha)))) + +(executable + ((name shatest) + (modules (shatest)) + (libraries (sha ounit)))) + +(alias + ((name runtest) + (deps (shatest.exe)) + (action (run ${<})))) diff --git a/sha.install b/sha.install new file mode 100644 index 0000000..354f11f --- /dev/null +++ b/sha.install @@ -0,0 +1,31 @@ +lib: [ + "_build/install/default/lib/sha/META" {"META"} + "_build/install/default/lib/sha/opam" {"opam"} + "_build/install/default/lib/sha/sha1.cmi" + "_build/install/default/lib/sha/sha1.cmx" + "_build/install/default/lib/sha/sha1.cmt" + "_build/install/default/lib/sha/sha1.cmti" + "_build/install/default/lib/sha/sha1.mli" + "_build/install/default/lib/sha/sha256.cmi" + "_build/install/default/lib/sha/sha256.cmx" + "_build/install/default/lib/sha/sha256.cmt" + "_build/install/default/lib/sha/sha256.cmti" + "_build/install/default/lib/sha/sha256.mli" + "_build/install/default/lib/sha/sha512.cmi" + "_build/install/default/lib/sha/sha512.cmx" + "_build/install/default/lib/sha/sha512.cmt" + "_build/install/default/lib/sha/sha512.cmti" + "_build/install/default/lib/sha/sha512.mli" + "_build/install/default/lib/sha/sha.cma" + "_build/install/default/lib/sha/libsha_stubs.a" + "_build/install/default/lib/sha/sha.cmxa" + "_build/install/default/lib/sha/sha.a" + "_build/install/default/lib/sha/sha.cmxs" +] +doc: [ + "_build/install/default/doc/sha/README" + "_build/install/default/doc/sha/CHANGES.md" +] +stublibs: [ + "_build/install/default/lib/stublibs/dllsha_stubs.so" +] diff --git a/sha.opam b/sha.opam index e77bbbb..a48b360 100644 --- a/sha.opam +++ b/sha.opam @@ -10,10 +10,8 @@ bug-reports: "https://github.com/djs55/ocaml-sha/issues" dev-repo: "https://github.com/djs55/ocaml-sha.git" license: "ISC" -build: make -install: [make "install"] -remove: [["ocamlfind" "remove" "sha"]] +build: [["jbuilder" "build" "-p" name "-j" jobs]] -depends: ["ocamlfind"] +depends: ["jbuilder" {build & >= "1.0+beta13"}] -available: [ ocaml-version >= "4.02.0" ] \ No newline at end of file +available: [ ocaml-version >= "4.02.0" ] diff --git a/sha1.c b/sha1c.c similarity index 100% rename from sha1.c rename to sha1c.c diff --git a/sha256.c b/sha256c.c similarity index 100% rename from sha256.c rename to sha256c.c diff --git a/sha512.c b/sha512c.c similarity index 100% rename from sha512.c rename to sha512c.c diff --git a/sha.test.ml b/shatest.ml similarity index 97% rename from sha.test.ml rename to shatest.ml index 07737b4..e3f83ce 100644 --- a/sha.test.ml +++ b/shatest.ml @@ -56,14 +56,14 @@ let ex_files_sha512 = "da82cac10002a838aceedc7910b76735ec87b2dce08755680910b8ff287c0f48a1910989f8e3a94f9cb5a391e66d811d190bc3568135514229051c06c6e93f6e") ] let ex_channels_sha1 = - [ ("sha.test.ml", "e13052afa4916d56994378f847f157596f9638a2") ] + [ ("shatest.ml", "e13052afa4916d56994378f847f157596f9638a2") ] let ex_channels_sha256 = - [ ("sha.test.ml", + [ ("shatest.ml", "51598a80bbec8fdcb32c3d180c3e806bf09eb0f5b5bb6f51031a78f46c83caef") ] let ex_channels_sha512 = - [ ("sha.test.ml", + [ ("shatest.ml", "2f8e603774643ce152620e1dd94601393e78d33a3e6f67b86df2ef87eb4ad0cde72b481208eaa0249bbcf64072f2fb03b06abd006c5213c7546936ae9e9a1dc1") ] let stringfct_sha1 s = Sha1.to_hex (Sha1.string s) From bfd80d6cbcde8d5593b5cbb15e74e0dd2e3b9165 Mon Sep 17 00:00:00 2001 From: Nicolas Ojeda Bar Date: Sat, 23 Dec 2017 09:16:28 +0100 Subject: [PATCH 2/7] Fix compiler warning about missing #include --- sha1_stubs.c | 1 + sha256_stubs.c | 1 + sha512_stubs.c | 1 + 3 files changed, 3 insertions(+) diff --git a/sha1_stubs.c b/sha1_stubs.c index 4efb3c7..e393186 100644 --- a/sha1_stubs.c +++ b/sha1_stubs.c @@ -25,6 +25,7 @@ typedef SSIZE_T ssize_t; #include #endif #include +#include #include "sha1.h" static inline int sha1_file(char *filename, sha1_digest *digest) diff --git a/sha256_stubs.c b/sha256_stubs.c index 3b362ec..d1d6c1c 100644 --- a/sha256_stubs.c +++ b/sha256_stubs.c @@ -25,6 +25,7 @@ typedef SSIZE_T ssize_t; #include #endif #include +#include #include "sha256.h" static inline int sha256_file(char *filename, sha256_digest *digest) diff --git a/sha512_stubs.c b/sha512_stubs.c index d03f504..b468be9 100644 --- a/sha512_stubs.c +++ b/sha512_stubs.c @@ -25,6 +25,7 @@ typedef SSIZE_T ssize_t; #include #endif #include +#include #include "sha512.h" static inline int sha512_file(char *filename, sha512_digest *digest) From 9efee6dc98090ad3aa52f0f5b783bb3b4087bb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Tue, 2 Jan 2018 16:33:49 +0100 Subject: [PATCH 3/7] Compile with --dev, fix warnings --- Makefile | 2 +- sha.install | 1 + sha1.ml | 5 ----- sha256.ml | 2 -- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 13b6762..0a13355 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: - jbuilder build @install + jbuilder build --dev @install test: jbuilder runtest diff --git a/sha.install b/sha.install index 354f11f..c47082e 100644 --- a/sha.install +++ b/sha.install @@ -24,6 +24,7 @@ lib: [ ] doc: [ "_build/install/default/doc/sha/README" + "_build/install/default/doc/sha/LICENSE.md" "_build/install/default/doc/sha/CHANGES.md" ] stublibs: [ diff --git a/sha1.ml b/sha1.ml index 3a3e915..8d7c4b6 100644 --- a/sha1.ml +++ b/sha1.ml @@ -54,11 +54,6 @@ let substring s ofs len = unsafe_update_substring ctx s ofs len; finalize ctx -let buffer buf = - let ctx = init () in - update_buffer ctx buf; - finalize ctx - let channel chan len = let ctx = init () and buf = Bytes.create blksize in diff --git a/sha256.ml b/sha256.ml index d609a17..c3d668f 100644 --- a/sha256.ml +++ b/sha256.ml @@ -39,8 +39,6 @@ let update_substring ctx s ofs len = let update_string ctx s = unsafe_update_substring ctx s 0 (String.length s) -external update_bigarray: ctx -> (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> unit = "stub_sha256_update_bigarray" - let string s = let ctx = init () in unsafe_update_substring ctx s 0 (String.length s); From 81bddb30896318643b6cdb9df8ef94710871abba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Tue, 2 Jan 2018 16:34:33 +0100 Subject: [PATCH 4/7] Fix jbuilder test --- Makefile | 2 ++ jbuild | 15 --------------- test/jbuild | 18 ++++++++++++++++++ shasum.ml => test/shasum.ml | 0 shatest.ml => test/shatest.ml | 6 +++--- 5 files changed, 23 insertions(+), 18 deletions(-) create mode 100755 test/jbuild rename shasum.ml => test/shasum.ml (100%) rename shatest.ml => test/shatest.ml (94%) diff --git a/Makefile b/Makefile index 0a13355..db395c0 100644 --- a/Makefile +++ b/Makefile @@ -15,3 +15,5 @@ uninstall: clean: jbuilder clean + +.PHONY: all test doc install uninstall clean diff --git a/jbuild b/jbuild index 46fa79d..12711af 100644 --- a/jbuild +++ b/jbuild @@ -8,18 +8,3 @@ (modules (sha1 sha256 sha512)) (c_flags (-Wall -O3 -funroll-loops)) ; Needs adapting for Windows (c_names (sha1c sha1_stubs sha256c sha256_stubs sha512c sha512_stubs)))) - -(executable - ((name shasum) - (modules (shasum)) - (libraries (sha)))) - -(executable - ((name shatest) - (modules (shatest)) - (libraries (sha ounit)))) - -(alias - ((name runtest) - (deps (shatest.exe)) - (action (run ${<})))) diff --git a/test/jbuild b/test/jbuild new file mode 100755 index 0000000..c54e809 --- /dev/null +++ b/test/jbuild @@ -0,0 +1,18 @@ +(jbuild_version 1) + +(executable + ((name shasum) + (modules (shasum)) + (libraries (sha)))) + +(executable + ((name shatest) + (modules (shatest)) + (libraries (sha ounit)))) + +(rule (copy ../README README)) + +(alias + ((name runtest) + (deps (shatest.exe README)) + (action (run ${<})))) diff --git a/shasum.ml b/test/shasum.ml similarity index 100% rename from shasum.ml rename to test/shasum.ml diff --git a/shatest.ml b/test/shatest.ml similarity index 94% rename from shatest.ml rename to test/shatest.ml index e3f83ce..4915bdb 100644 --- a/shatest.ml +++ b/test/shatest.ml @@ -45,15 +45,15 @@ let ex_strings_sha512 = [ let ex_files_sha1 = [ ("README", - "ebd97ba45cd1668d242d98522dc0004bb70df4a8") ] + "3dd0bb5bd5614a8e2dd9b03806dc4edd5ec10905") ] let ex_files_sha256 = [ ("README", - "7f8213da9acc755d57f3650827176dcdf2f101ea486d5fa357e705d728480878") ] + "faad0b6f78c304d861a6f0f46306f8921c5f385b8a47267a59afad3e783b2ebf") ] let ex_files_sha512 = [ ("README", - "da82cac10002a838aceedc7910b76735ec87b2dce08755680910b8ff287c0f48a1910989f8e3a94f9cb5a391e66d811d190bc3568135514229051c06c6e93f6e") ] + "6dab66983e0b37a5eeb83900434ea8fe70fc1319653cbb2483c297563663de58f9d5c94e452463d8decf9039ad94b2c924e7af36841589a565979cc06ed94624") ] let ex_channels_sha1 = [ ("shatest.ml", "e13052afa4916d56994378f847f157596f9638a2") ] From fd99b4da8eeeb73146a1cdadef84fafd34adf856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Tue, 2 Jan 2018 17:17:53 +0100 Subject: [PATCH 5/7] Robustify tests --- test/jbuild | 4 +--- test/sample.txt | 1 + test/shatest.ml | 39 +++++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 test/sample.txt diff --git a/test/jbuild b/test/jbuild index c54e809..50e1caa 100755 --- a/test/jbuild +++ b/test/jbuild @@ -10,9 +10,7 @@ (modules (shatest)) (libraries (sha ounit)))) -(rule (copy ../README README)) - (alias ((name runtest) - (deps (shatest.exe README)) + (deps (shatest.exe sample.txt)) (action (run ${<})))) diff --git a/test/sample.txt b/test/sample.txt new file mode 100644 index 0000000..ff3bb63 --- /dev/null +++ b/test/sample.txt @@ -0,0 +1 @@ +The quick brown fox jumps over the lazy dog \ No newline at end of file diff --git a/test/shatest.ml b/test/shatest.ml index 4915bdb..c4926a9 100644 --- a/test/shatest.ml +++ b/test/shatest.ml @@ -18,53 +18,56 @@ open OUnit +let cog = "The quick brown fox jumps over the lazy cog" +let dog = "The quick brown fox jumps over the lazy dog" + let ex_strings_sha1 = [ ("", "da39a3ee5e6b4b0d3255bfef95601890afd80709"); - ("The quick brown fox jumps over the lazy cog", + (cog, "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3"); - ("The quick brown fox jumps over the lazy dog", + (dog, "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"); ] let ex_strings_sha256 = [ ("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); - ("The quick brown fox jumps over the lazy cog", + (cog, "e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be"); - ("The quick brown fox jumps over the lazy dog", + (dog, "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"); ] let ex_strings_sha512 = [ ("", "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); - ("The quick brown fox jumps over the lazy cog", + (cog, "3eeee1d0e11733ef152a6c29503b3ae20c4f1f3cda4cb26f1bc1a41f91c7fe4ab3bd86494049e201c4bd5155f31ecb7a3c8606843c4cc8dfcab7da11c8ae5045"); - ("The quick brown fox jumps over the lazy dog", + (dog, "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6"); ] let ex_files_sha1 = - [ ("README", - "3dd0bb5bd5614a8e2dd9b03806dc4edd5ec10905") ] + [ ("sample.txt", + "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12") ] let ex_files_sha256 = - [ ("README", - "faad0b6f78c304d861a6f0f46306f8921c5f385b8a47267a59afad3e783b2ebf") ] + [ ("sample.txt", + "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592") ] let ex_files_sha512 = - [ ("README", - "6dab66983e0b37a5eeb83900434ea8fe70fc1319653cbb2483c297563663de58f9d5c94e452463d8decf9039ad94b2c924e7af36841589a565979cc06ed94624") ] + [ ("sample.txt", + "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6") ] let ex_channels_sha1 = - [ ("shatest.ml", "e13052afa4916d56994378f847f157596f9638a2") ] + [ ("sample.txt", "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12") ] let ex_channels_sha256 = - [ ("shatest.ml", - "51598a80bbec8fdcb32c3d180c3e806bf09eb0f5b5bb6f51031a78f46c83caef") ] + [ ("sample.txt", + "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592") ] let ex_channels_sha512 = - [ ("shatest.ml", - "2f8e603774643ce152620e1dd94601393e78d33a3e6f67b86df2ef87eb4ad0cde72b481208eaa0249bbcf64072f2fb03b06abd006c5213c7546936ae9e9a1dc1") ] + [ ("sample.txt", + "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6") ] let stringfct_sha1 s = Sha1.to_hex (Sha1.string s) let stringfct_sha256 s = Sha256.to_hex (Sha256.string s) @@ -87,7 +90,7 @@ let test_file filefct arr _ = let test_channel channelfct arr _ = List.iter (fun (c,r) -> let chan = open_in_bin c in - let digest = channelfct chan 20 in + let digest = channelfct chan (String.length dog) in close_in chan; assert_equal r digest) arr From 6a9702e80f6f15c058f4cee62862c30c54a6223c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Tue, 2 Jan 2018 17:55:43 +0100 Subject: [PATCH 6/7] Add tests to opam, do not track .install, remove VERSION --- .gitignore | 1 + VERSION | 1 - sha.install | 32 -------------------------------- sha.opam | 7 ++++++- 4 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 VERSION delete mode 100644 sha.install diff --git a/.gitignore b/.gitignore index 655e32b..3fce479 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ _build .merlin +*.install diff --git a/VERSION b/VERSION deleted file mode 100644 index c044b1a..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.10 diff --git a/sha.install b/sha.install deleted file mode 100644 index c47082e..0000000 --- a/sha.install +++ /dev/null @@ -1,32 +0,0 @@ -lib: [ - "_build/install/default/lib/sha/META" {"META"} - "_build/install/default/lib/sha/opam" {"opam"} - "_build/install/default/lib/sha/sha1.cmi" - "_build/install/default/lib/sha/sha1.cmx" - "_build/install/default/lib/sha/sha1.cmt" - "_build/install/default/lib/sha/sha1.cmti" - "_build/install/default/lib/sha/sha1.mli" - "_build/install/default/lib/sha/sha256.cmi" - "_build/install/default/lib/sha/sha256.cmx" - "_build/install/default/lib/sha/sha256.cmt" - "_build/install/default/lib/sha/sha256.cmti" - "_build/install/default/lib/sha/sha256.mli" - "_build/install/default/lib/sha/sha512.cmi" - "_build/install/default/lib/sha/sha512.cmx" - "_build/install/default/lib/sha/sha512.cmt" - "_build/install/default/lib/sha/sha512.cmti" - "_build/install/default/lib/sha/sha512.mli" - "_build/install/default/lib/sha/sha.cma" - "_build/install/default/lib/sha/libsha_stubs.a" - "_build/install/default/lib/sha/sha.cmxa" - "_build/install/default/lib/sha/sha.a" - "_build/install/default/lib/sha/sha.cmxs" -] -doc: [ - "_build/install/default/doc/sha/README" - "_build/install/default/doc/sha/LICENSE.md" - "_build/install/default/doc/sha/CHANGES.md" -] -stublibs: [ - "_build/install/default/lib/stublibs/dllsha_stubs.so" -] diff --git a/sha.opam b/sha.opam index a48b360..551693f 100644 --- a/sha.opam +++ b/sha.opam @@ -12,6 +12,11 @@ license: "ISC" build: [["jbuilder" "build" "-p" name "-j" jobs]] -depends: ["jbuilder" {build & >= "1.0+beta13"}] +build-test: [["jbuilder" "runtest" "-p" name]] + +depends: [ + "jbuilder" {build & >= "1.0+beta13"} + "ounit" {test} +] available: [ ocaml-version >= "4.02.0" ] From aac6fdc7bfb774681bf45a0dd65c87049c4f647a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Tue, 2 Jan 2018 18:05:58 +0100 Subject: [PATCH 7/7] Typo --- test/jbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jbuild b/test/jbuild index 50e1caa..7ba4059 100755 --- a/test/jbuild +++ b/test/jbuild @@ -8,7 +8,7 @@ (executable ((name shatest) (modules (shatest)) - (libraries (sha ounit)))) + (libraries (sha oUnit)))) (alias ((name runtest)