Commit 06b9f572 authored by Akim Demaille's avatar Akim Demaille
Browse files

2006-04-21 Akim Demaille <akim@lrde.epita.fr>

	* tests/defs.in, tests/fact.lir, tests/fact.out, tests/trace.test,
	* tests/Makefile.am: New. 
	* Makefile.am, configure.ac: Adjust.
	Automake 1.9.6.
	* src/Main.hs (fdFrom, setHandle): New, to refactor...
	(EvalM): this.
parent f306206f
2006-04-21 Akim Demaille <akim@lrde.epita.fr>
* tests/defs.in, tests/fact.lir, tests/fact.out, tests/trace.test,
* tests/Makefile.am: New.
* Makefile.am, configure.ac: Adjust.
Automake 1.9.6.
* src/Main.hs (fdFrom, setHandle): New, to refactor...
(EvalM): this.
2006-04-21 Akim Demaille <akim@lrde.epita.fr>
* src/Trace.hs (trace): Remove.
......
# Copyright (C) 2003, 2005 Robert Anisko
# Copyright (C) 2003, 2005, 2006 Robert Anisko
#
# This file is part of HAVM. This program is free software; you can
# redistribute it and/or modify it under the terms of the GNU General
......@@ -17,7 +17,7 @@
ACLOCAL_AMFLAGS = -I build-aux
SUBDIRS = src doc debian
SUBDIRS = src tests doc debian
install-epita:
$(MAKE) static
......
# Copyright (C) 2003, 2004, 2005 Robert Anisko
# Copyright (C) 2003, 2004, 2005, 2006 Robert Anisko
#
# This file is part of HAVM. This program is free software; you can
# redistribute it and/or modify it under the terms of the GNU General
......@@ -20,7 +20,7 @@ m4_pattern_forbid([^HAVM_])
AC_PREREQ([2.59])
AC_INIT([HAVM], [0.23a], [tiger-patches@lrde.epita.fr])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.9 dist-bzip2])
AM_INIT_AUTOMAKE([1.9.6 dist-bzip2])
HAVM_PROG([ghc], [6.4], [GHC], [Glasgow Haskell Compiler])
AM_MISSING_PROG([HAPPY], [happy])
......@@ -29,6 +29,7 @@ AC_CONFIG_FILES([
Makefile
src/Config.hs
src/Makefile
tests/Makefile tests/defs
debian/Makefile
doc/Makefile])
AC_OUTPUT
......@@ -82,32 +82,32 @@ profileM =
lift $ hPutStrLn h $ reportTime prof
Nothing -> return ()
-- Extract the FD corresponding to the option s in the fm, defaulting to -1.
fdFrom :: Map String OptVal -> String -> Int
fdFrom fm s =
case findWithDefault (IVal (-1)) s fm of
IVal x -> x
_ -> error $ "fdFrom: bad value for `" ++ s ++ "' option"
-- Store the file descriptor for s in fm using storeHandle
setHandle :: (Handle -> Mnd ()) -> Map String OptVal -> String -> Mnd ()
setHandle storeHandle fm s =
setHandle_ (fdFrom fm s)
where
-- If the fd is valid, apply storeHandle to it.
setHandle_ fd =
if fd >= 0
then do ph <- lift (fdToHandle $ Fd (fromIntegral fd))
storeHandle ph
else return ()
evalM :: Map String OptVal -> [Stm Ann] -> Mnd ()
evalM fm stms =
let pfd = case findWithDefault (IVal (-1)) "profile" fm of
IVal x -> x
_ -> error "evalM: bad value for `profile' option"
dfd = case findWithDefault (IVal (-1)) "display" fm of
IVal x -> x
_ -> error "evalM: bad value for `display' option"
tfd = case findWithDefault (IVal (-1)) "trace" fm of
IVal x -> x
_ -> error "evalM: bad value for `trace' option"
in
do optset "low" $ findWithDefault (BVal False) "low" fm
if pfd >= 0
then do ph <- lift (fdToHandle $ Fd (fromIntegral pfd))
setProfileHandle ph
else return ()
if dfd >= 0
then do ph <- lift (fdToHandle $ Fd (fromIntegral dfd))
setDisplayHandle ph
else return ()
if tfd >= 0
then do ph <- lift (fdToHandle $ Fd (fromIntegral tfd))
setTraceHandle ph
else return ()
warn ["toto"]
setHandle setProfileHandle fm "profile"
setHandle setDisplayHandle fm "display"
setHandle setTraceHandle fm "trace"
trace ["plaining"]
stms <- plainStms stms
trace ["unparsing"]
......
## ------- ##
## Tests. ##
## ------- ##
XFAIL_TESTS =
TESTS = \
trace.test
EXTRA_DIST = fact.lir $(TESTS)
# Each test case depends on defs.
check_SCRIPTS = defs
distclean-local:
-rm -rf testSubDir
# -*- shell-script -*-
# @configure_input@
#
# Copyright (C) 2006 LRDE
#
# This file is part of HAVM.
#
# HAVM is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# HAVM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with autoconf; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# Be Bourne compatible.
# (Snippet copied from configure's initialization in Autoconf 2.57.)
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
# Ensure we are running from the right directory.
test -f ./defs || {
echo "defs: not found in current directory" 1>&2
exit 1
}
# If srcdir is not set, then we are not running from `make check', be verbose.
if test -z "$srcdir"; then
VERBOSE=x
# compute $srcdir.
srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
test $srcdir = $0 && srcdir=.
fi
# Ensure $srcdir is set correctly.
test -f $srcdir/defs.in || {
echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
exit 1
}
me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
# See how redirections should work. User can set VERBOSE to see all
# output.
test -z "$VERBOSE" && {
exec > /dev/null 2>&1
}
# Make sure we override the user shell.
SHELL='@SHELL@'
export SHELL
test -z "$HAVM" && HAVM=`cd ../src && pwd`/havm
echo $PATH
# Some shells forget to export modified environment variables.
# (See note about `export' in the Autoconf manual.)
export PATH
# Always use an absolute srcdir. Otherwise symlinks made in subdirs
# of the test dir just won't work.
case "$srcdir" in
[\\/]* | ?:[\\/]*)
;;
*)
srcdir=`CDPATH=: && cd "$srcdir" && pwd`
;;
esac
chmod -R a+rwx testSubDir > /dev/null 2>&1
rm -rf testSubDir > /dev/null 2>&1
mkdir testSubDir
cd ./testSubDir
echo "=== Running test $0"
# HAVM_run status [options...]
# ----------------------------
# Run havm with OPTIONS, and fail if does not exit with STATUS.
HAVM_run ()
{
expected_exitcode=$1
shift
exitcode=0
which $HAVM
$HAVM ${1+"$@"} 2>stderr >stdout || exitcode=$?
cat stderr
cat stdout
test $exitcode = $expected_exitcode || exit 1
}
# HAVM_fail [options...]
# ----------------------
# Run havm with OPTIONS, and fail if does not exit with failure.
HAVM_fail ()
{
HAVM_run 1 ${1+"$@"}
}
# HAVM_pass [options...]
# ----------------------
# Run havm with OPTIONS, and fail if does not exit with failure.
HAVM_pass ()
{
set -xv
HAVM_run 0 ${1+"$@"}
}
# Turn on shell traces when VERBOSE is set.
if test -n "$VERBOSE"; then
set -x
else
:
fi
pwd
/* == Low Level Intermediate representation. == */
# Routine: fact
label l0
# Prologue
move
temp t2
temp fp
move
temp fp
temp sp
move
temp sp
binop sub
temp sp
const 4
move
mem
temp fp
temp i0
move
temp t0
temp i1
# Body
seq
label l5
cjump eq
temp t0
const 0
name l1
name l2
label l2
move
temp t4
call
name l0
mem
temp fp
binop sub
temp t0
const 1
call end
move
temp t1
binop mul
temp t0
temp t4
label l3
move
temp rv
temp t1
jump
name l6
label l1
move
temp t1
const 1
jump
name l3
label l6
seq end
# Epilogue
move
temp sp
temp fp
move
temp fp
temp t2
label end
label l4
"\n"
# Routine: _main
label main
# Prologue
# Body
seq
label l7
move
temp t5
call
name l0
temp fp
const 10
call end
sxp
call
name print_int
temp t5
call end
sxp
call
name print
name l4
call end
label l8
seq end
# Epilogue
label end
#! /bin/sh
# Copyright (C) 2006 LRDE
#
# This file is part of HAVM.
#
# HAVM is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# HAVM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Texinfo; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
. ./defs || exit 1
set -e
HAVM_pass --trace $srcdir/fact.lir
cmp stdout $srcdir/fact.out
test -s stderr
HAVM_pass --trace=3 $srcdir/fact.lir 3>stdtrc
cmp stdout $srcdir/fact.out
test ! -s stderr
test -s stdtrc
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment