add solutions
[staff/goc4/2018bti7061.git] / asm-project / test.sh
CommitLineData
4aac7573
CG
1#!/bin/sh
2# This is an example shell script showing how your code will
3# be graded. It compiles _both_ Assembly programs, but only
4# tests ONE of them. The real grading script will test BOTH.
5# You should extend this script to test the decoder as well.
6# (Testing is part of the job of writing code.)
7# Note that if you pass this script, you will receive at
8# least 50% of the points for the Assembler homework!
9
10# Assemble and link encoder
11nasm -f elf64 -g -F dwarf base32enc.asm -o b32e.o || { echo "Assembly code base32enc.asm failed to compile"; exit 1; }
12ld -o b32e b32e.o || { echo "Object failed to link"; exit 1; }
13# Assemble and link decoder
14nasm -f elf64 -g -F dwarf base32dec.asm -o b32d.o || { echo "Assembly code base32dec.asm failed to compile"; exit 1; }
15ld -o b32d b32d.o || { echo "Object failed to link"; exit 1; }
16
17# run tests
18total=0
19for n in A AA AB bc D13 FOO foxy lalalalalal4242
20do
21 points=1
22 timeout -s SIGKILL 1s echo -n $n | ./b32e > $n.out || { echo "Your 'b32' command failed to run: $?" ; points=0 ; }
23 echo -n $n | base32 > $n.want || { echo "System 'base32' failed to run"; exit 1; }
24 diff -w $n.want $n.out > $n.delta || { echo "Encode failed on $n" ; points=0; }
25 if test $points = 1
26 then
27 echo "Test $n passed"
28 total=`expr $total + $points`
29 fi
30done
31# Output grade
32echo "Final grade: $total/8"
33exit 0