This commit is contained in:
swrup 2025-11-11 02:08:31 +01:00
parent aa2ff7b2f0
commit 1998c94766
5 changed files with 139 additions and 0 deletions

View file

@ -0,0 +1,73 @@
WORDSIZE:=$(shell echo 'print_int Sys.word_size' | ocaml -stdin)
STDLIBDIR:=$(shell ocamlc -where)
ifeq ($(wildcard $(STDLIBDIR)/big_int.cmi),)
HAS_NUM=false
NUMS_CMA=
NUMS_CMXA=
else
HAS_NUM=true
NUMS_CMA=nums.cma
NUMS_CMXA=nums.cmxa
endif
test:: zq.exe
@echo "Testing zq (native)..."
@if ./zq.exe | cmp -s zq.output$(WORDSIZE) - ; then echo "zq: passed"; else echo "zq: FAILED"; exit 2; fi
test:: zq.byt
@echo "Testing zq (bytecode)..."
@if ocamlrun -I .. ./zq.byt | cmp -s zq.output$(WORDSIZE) - ; then echo "zq: passed"; else echo "zq: FAILED"; exit 2; fi
ifeq ($(HAS_NUM),true)
test:: bi.exe
@echo "Testing bi..."
@if ./bi.exe; then echo "bi: passed"; else echo "bi: FAILED"; exit 2; fi
endif
test:: pi.exe
@echo "Testing pi..."
@if ./pi.exe 500 | cmp -s pi.output - ; then echo "pi: passed"; else echo "pi: FAILED"; exit 2; fi
test:: tofloat.exe
@echo "Testing tofloat..."
@./tofloat.exe
test:: ofstring.exe
@echo "Testing ofstring..."
@./ofstring.exe
test:: chi2.exe
@echo "Testing random number generation..."
@if ./chi2.exe; then echo "chi2: passed"; else echo "chi2: FAILED"; exit 2; fi
bench:: timings.exe
./timings.exe
bench:: pi.exe
@echo "Benchmarking pi"; time ./pi.exe 10000 > /dev/null
test:: tst_extract.exe
@echo "Testing extract..."
@if ./tst_extract.exe; then echo "tst_extract: passed"; else echo "tst_extract: FAILED"; exit 2; fi
test:: intern.exe
@echo "Testing unmarshaling..."
@if ./intern.exe extern.data32 | cmp -s intern.output32$(WORDSIZE) -; then echo "intern 32: passed"; else echo "intern 32: failed"; exit 2; fi
@if ./intern.exe extern.data64 | cmp -s intern.output64$(WORDSIZE) -; then echo "intern 64: passed"; else echo "intern 64: failed"; exit 2; fi
extern.data$(WORDSIZE): extern.exe
./extern.exe extern.data$(WORDSIZE)
tofloat.exe: tofloat.ml setround.o ../zarith.cmxa
ocamlopt -I .. -ccopt "-L.." zarith.cmxa -o tofloat.exe \
setround.o tofloat.ml
%.exe: %.ml ../zarith.cmxa
ocamlopt -I .. -ccopt "-L.." zarith.cmxa $(NUMS_CMXA) -o $*.exe $*.ml
%.byt: %.ml ../zarith.cma
ocamlc -I .. -ccopt "-L.." zarith.cma $(NUMS_CMA) -o $*.byt $*.ml
%.o: %.c
ocamlc -c $*.c
clean:
rm -f *.cm[iox] *.o *.exe *.byt

View file

@ -0,0 +1,7 @@
S common
S src-c
S src-ocaml
B _build/**
PKG ocamlbuild alcotest

View file

@ -0,0 +1,3 @@
bin: [
"_boot/dune"
]

View file

@ -0,0 +1,48 @@
<!DOCTYPE html>
<!--
Copyright (c) 2015 The logs programmers. All rights reserved.
Distributed under the ISC license, see license at the end of the file.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<script type="text/javascript" defer="defer" src="test_browser.js"></script>
<style type="text/css">
h1 { font-size: 2.5rem; font-weight: 300; text-transform: uppercase; }
body { background-color: black;
color: #A0A0A0;
font-size: 1rem;
line-height: 1.3125rem;
font-family: monospace;
font-weight: 300;
margin: 4em; }
div { font-size: 0.8rem; margin-top:1.3125rem; }
p { margin:0rem; padding:0rem; white-space: pre; }
</style>
<title>Logs test</title>
</head>
<body>
<noscript>Sorry, you need to enable JavaScript to see this page.</noscript>
<h1>Logs test</h1>
See the browser console.
</body>
</html>
<!--
Copyright (c) 2015 The logs programmers
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->

View file

@ -0,0 +1,8 @@
S lib
S lib_test
PKG cstruct
B _build
B _build/lib
B _build/lib_test