Skip to content

Commit

Permalink
Merge pull request #39 from mseri/opam-fix
Browse files Browse the repository at this point in the history
Merge Libraries and rearrange tests
  • Loading branch information
mseri committed Sep 29, 2020
2 parents 531cd2c + 7419436 commit 3d27098
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 86 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
- OCAML_VERSION=4.08.1
- OCAML_VERSION=4.09.1
- OCAML_VERSION=4.10.1
- OCAML_VERSION=4.11.0
- OCAML_VERSION=4.11.1

os:
- linux
Expand All @@ -32,9 +32,8 @@ before_install:
- eval $(opam env)

script:
- opam pin -n imagelib.dev .
- opam pin -n imagelib-unix.dev .
- opam install -t .
- opam pin -t imagelib.dev .
- make test

notifications:
email:
Expand Down
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## current
## ocaml-imagelib_20200929

- Port to dune 2.0
10 changes: 8 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
VERSION := 20180522
VERSION := 20200829

.PHONY: all
all: bin

.PHONY: bin
bin:
@dune build
@dune build -p imagelib

install: bin
@dune install
Expand All @@ -20,6 +20,12 @@ clean:
distclean: clean
@find . -name "*~" -exec rm {} \;

.PHONY: test slowtest
test:
@dune runtest -p imagelib

slowtest:
@dune build @slowtests -p imagelib --no-buffer
#.PHONY: release
#release: distclean
# git push origin
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ List of dependencies:

Additional packages:
- ImageMagick (convert) for handling some formats.
- Crowbar, Alcotest (for the test suite)
- Crowbar, Alcotest, afl-persistent (for the test suite)

Installation
------------
Expand All @@ -46,14 +46,14 @@ Fuzzing

This section is primarily of use for developers of the library.

To exectute `crowbar` tests, it is enough to run `make slowtest`.

The `aflrunner.exe` target can be used to fuzz test the image parsers with [AFL](http://lcamtuf.coredump.cx/afl).
- It will only be built if the `afl-persistent` OPAM package is installed.
- The parser is selected using the filename extension.
The parser is selected using the filename extension.

Here is an example, requiring at least one valid BMP file in a folder called `sample-bmps/`:
```shell
imagelib $ opam install -y afl-persistent
imagelib $ dune build
imagelib $ dune build tests/aflrunner.exe
imagelib $ afl-fuzz \
-i sample-bmps/ \
-o bmp-results/ \
Expand Down
9 changes: 3 additions & 6 deletions app/dune
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
(executable
(name imagetool)
(public_name imagetool)
(package imagelib-unix)
(modules :standard)
(libraries imagelib imagelib-unix)
)
(name imagetool)
(public_name imagetool)
(libraries imagelib imagelib.unix))
7 changes: 5 additions & 2 deletions dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
; Add project-wide flags here.

(env
(dev (flags :standard))
(release (flags :standard)))
(dev
(flags :standard))
(release
(flags :standard)))
40 changes: 0 additions & 40 deletions imagelib-unix.opam

This file was deleted.

10 changes: 9 additions & 1 deletion imagelib.opam
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ doc: "https://rlepigre.github.io/ocaml-imagelib"

depends: [
"ocaml" { >= "4.07.0" }
"base-unix"
"dune" { >= "2.3.0" }
"decompress" { >= "1.2.0" }
"stdlib-shims"
"alcotest" { with-test }
]

depopts: [
"crowbar" { with-test }
"afl-persistent" { with-test }
]

build: [ [ "dune" "build" "-p" name "-j" jobs "@runtest" {with-test} ] ]
build: [
[ "dune" "build" "-p" name "-j" jobs "@runtest" {with-test} ]
]
2 changes: 0 additions & 2 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
(name imagelib)
(public_name imagelib)
(synopsis "Image library")
(modules :standard)
(flags (:standard -safe-string))
(wrapped false)
(libraries stdlib-shims bigarray checkseum.ocaml decompress.zl))
44 changes: 24 additions & 20 deletions tests/dune
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
(executable
; this is only built if AFL
; is installed:
(optional)
(name aflrunner)
(public_name aflrunner)
(package imagelib-unix)
(modules aflrunner)
(libraries imagelib imagelib-unix afl-persistent)
)
; this is only built if AFL
; is installed:
(optional)
(name aflrunner)
(public_name aflrunner)
(modules aflrunner)
(libraries imagelib imagelib.unix afl-persistent))

(test
(name tests)
(modules tests)
(package imagelib-unix)
(libraries imagelib imagelib-unix alcotest)
)
(executable
; this is only built if crowbar
; is installed:
(optional)
(name testwithcrowbar)
(public_name testwithcrowbar)
(modules testwithcrowbar)
(libraries imagelib imagelib.unix alcotest crowbar))

(test
(name testwithcrowbar)
(modules testwithcrowbar)
(package imagelib-unix)
(libraries imagelib imagelib-unix alcotest crowbar)
)
(name tests)
(modules tests)
(libraries imagelib imagelib.unix alcotest))

(rule
(alias slowtests)
(targets testwithcrowbar)
(action
(run %{exe:testwithcrowbar.exe})))
1 change: 1 addition & 0 deletions tests/tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module ImageLib_PNG_tests = struct

let self_test_1 () =
let img = Image.create_rgb 3 3 in
Image.fill_rgb img 0 0 0;
let enc = ImageLib.PNG.bytes_of_png img in
let dec = ImageLib.PNG.parsefile
(ImageUtil.chunk_reader_of_string (Bytes.to_string enc)) in
Expand Down
4 changes: 1 addition & 3 deletions unix/dune
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
(library
(name imagelib_unix)
(public_name imagelib-unix)
(public_name imagelib.unix)
(synopsis "Image library with unix bindings")
(modules :standard)
(flags (:standard -safe-string))
(wrapped false)
(libraries imagelib))

0 comments on commit 3d27098

Please sign in to comment.