зеркало из https://github.com/mozilla/gecko-dev.git
Bug 499016 - Provide testing support for lirasm. r=graydon.
This commit is contained in:
Родитель
1b5bd7988c
Коммит
87fe4ff394
|
@ -68,3 +68,7 @@ CFLAGS += -F/System/Library/PrivateFrameworks
|
|||
CXXFLAGS += -F/System/Library/PrivateFrameworks
|
||||
LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
|
||||
endif
|
||||
|
||||
check::
|
||||
$(srcdir)/testlirc.sh
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ assemble_call(string const &op,
|
|||
// Select return type from opcode.
|
||||
// FIXME: callh needs special treatment currently
|
||||
// missing from here.
|
||||
if (opcode == LIR_call || opcode == LIR_calli)
|
||||
if (opcode == LIR_call)
|
||||
ci->_argtypes |= ARGSIZE_LO;
|
||||
else
|
||||
ci->_argtypes |= ARGSIZE_F;
|
||||
|
@ -546,10 +546,8 @@ assemble(istream &in,
|
|||
break;
|
||||
|
||||
case LIR_call:
|
||||
case LIR_calli:
|
||||
case LIR_callh:
|
||||
case LIR_fcall:
|
||||
case LIR_fcalli:
|
||||
ins = assemble_call(op, opcode, toks, lir,
|
||||
labels, callinfos, line);
|
||||
break;
|
||||
|
@ -671,10 +669,18 @@ main(int argc, char **argv)
|
|||
has_flag(args, "--sse");
|
||||
#endif
|
||||
bool execute = has_flag(args, "--execute");
|
||||
bool verbose = has_flag(args, "-v");
|
||||
|
||||
#if defined NANOJIT_IA32
|
||||
if (verbose && !execute) {
|
||||
cerr << "usage: " << prog << " [--sse | --execute [-v]] <filename>" << endl;
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (args.empty()) {
|
||||
#if defined NANOJIT_IA32
|
||||
cerr << "usage: " << prog << " [--sse] [--execute] <filename>" << endl;
|
||||
cerr << "usage: " << prog << " [--sse | --execute [-v]] <filename>" << endl;
|
||||
#else
|
||||
cerr << "usage: " << prog << " <filename>" << endl;
|
||||
#endif
|
||||
|
@ -706,7 +712,8 @@ main(int argc, char **argv)
|
|||
|
||||
LirWriter *w = expr_filter;
|
||||
#ifdef DEBUG
|
||||
w = verb;
|
||||
if (verbose)
|
||||
w = verb;
|
||||
#endif
|
||||
|
||||
ifstream in(args[0].c_str());
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
TESTS_DIR=`dirname "$0"`/tests
|
||||
|
||||
for infile in "$TESTS_DIR"/*.in
|
||||
do
|
||||
outfile=`echo $infile | sed 's/\.in/\.out/'`
|
||||
if [ ! -e "$outfile" ]
|
||||
then
|
||||
echo "$0: error: no out file $outfile"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ./lirasm --execute $infile > testoutput.txt && cmp -s testoutput.txt $outfile
|
||||
then
|
||||
echo "$0: output correct for $infile"
|
||||
else
|
||||
echo "$0: incorrect output for $infile"
|
||||
echo "$0: === actual output ==="
|
||||
cat testoutput.txt
|
||||
echo "$0: === expected output ==="
|
||||
cat $outfile
|
||||
fi
|
||||
done
|
||||
rm testoutput.txt
|
|
@ -0,0 +1,4 @@
|
|||
two = int 2
|
||||
three = int 3
|
||||
res = add two three
|
||||
ret res
|
|
@ -0,0 +1 @@
|
|||
Output is: 5
|
|
@ -0,0 +1,5 @@
|
|||
two = int 7
|
||||
three = int 3
|
||||
targ = add two three
|
||||
res = sub targ three
|
||||
ret res
|
|
@ -0,0 +1 @@
|
|||
Output is: 7
|
|
@ -0,0 +1,11 @@
|
|||
ptr = alloc 8
|
||||
a = int 65
|
||||
sti a ptr 0
|
||||
b = int 66
|
||||
sti b ptr 1
|
||||
c = int 67
|
||||
sti c ptr 2
|
||||
zero = int 0
|
||||
sti zero ptr 3
|
||||
ss = call puts cdedl ptr
|
||||
ret ss
|
|
@ -0,0 +1,2 @@
|
|||
ABC
|
||||
Output is: 4
|
|
@ -0,0 +1,5 @@
|
|||
pi = quad 3.14
|
||||
half = quad 0.5
|
||||
halfpi = fmul pi half
|
||||
res = fcall sin cdedl halfpi
|
||||
fret res
|
|
@ -0,0 +1 @@
|
|||
Output is: 1
|
|
@ -0,0 +1,4 @@
|
|||
pi = quad 3.14
|
||||
two = quad 2.0
|
||||
TwoPi = fmul pi two
|
||||
fret two
|
|
@ -0,0 +1 @@
|
|||
Output is: 2
|
|
@ -0,0 +1,9 @@
|
|||
ptr= alloc 8
|
||||
five = int 5
|
||||
sti five ptr 0
|
||||
three= int 3
|
||||
sti three ptr 4
|
||||
v= ld ptr 0
|
||||
u= ld ptr 4
|
||||
res= add u v
|
||||
ret res
|
|
@ -0,0 +1 @@
|
|||
Output is: 8
|
Загрузка…
Ссылка в новой задаче