summaryrefslogtreecommitdiff
path: root/archived/less_old_sim8086/misc/test_listing
blob: 472c0d26f76835fc3cba1d5b1fb348672b8def01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

NoColor=
if [ "$1" = "--no-color" ]
then
	NoColor=1
	shift
fi

ThisDir="$(dirname "$(readlink -f "$0")")"

for File in $@
do
	File="$(readlink -f "$File")"
	[ "$File" ] || exit 1

	(
		cd "$ThisDir"

		SourceFile="$File"
		SourceFile="${File%.asm}.asm"
		[ -r "$SourceFile" ] || exit 1

		ErrorFile="../build/error"
		TestSource="../build/first"
		OutFile="../build/$(basename "${SourceFile%.asm}")"
		nasm -o "$OutFile" "$SourceFile" 2> "$ErrorFile"
		../build/sim8086 "$OutFile" > "$TestSource".asm 2>> "$ErrorFile"
		nasm -o "${TestSource}" "$TestSource".asm 2>> "$ErrorFile"

		RelPath="$(realpath --relative-to=. "$SourceFile")"
		if diff -q "$TestSource" "$OutFile" > /dev/null 2>> "$ErrorFile"
		then
			if [ "$NoColor" ]
			then
				printf ' PASSED: '\''%s'\''\n' "$RelPath"
			else
				printf '\033[32m PASSED: '\''%s'\''\033[0m\n' "$RelPath"
			fi
		else
			if [ "$NoColor" ]
			then
				printf ' FAILED: '\''%s'\''\n' "$RelPath"
			else
				printf '\033[31m FAILED: '\''%s'\''\033[0m\n' "$RelPath"
			fi
			cat "$ErrorFile" | sed 's/.*/    &/'
		fi
	)
done