shithub: scc

Download patch

ref: 49ea14f17cb76c7112691a4ed951315f3d105c63
parent: 15accc917305a32e269f8f3063108e9115d44d3d
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Aug 13 15:59:58 EDT 2015

Add first test program

The first program of any compiler must be a Hello world!!!

--- /dev/null
+++ b/cc1/tests/chktest.sh
@@ -1,0 +1,25 @@
+#!/bin/sh
+
+out=/tmp/out
+chk=/tmp/chk
+
+#trap "rm -f $out $chk" EXIT INT QUIT
+
+for i in *.c
+do
+	rm -f $out $chk
+	awk '
+	/^name:/                  {printf "Running %s ", $2}
+	/^output:$/               {copyon=1}
+	/^\*/                     {copyon=0}
+	copyon==1 && !/^output:$/ {print $0 >> "'$chk'"}
+	' $i
+
+	../cc1 $i > $out 2>&1
+  	if cmp $out $chk >/dev/null 2>&1
+  	then
+   		echo [OK]
+  	else
+  		echo [FAILED]
+ 	fi
+done
--- /dev/null
+++ b/cc1/tests/test001.c
@@ -1,0 +1,23 @@
+/*
+name: TEST001
+description: Basic hello world test
+output:
+F3	P
+X1	F3	printf
+F1
+X2	F1	main
+G2	F1	main	{
+-
+	X1	"68656C6C6F20776F726C640A	aP	pP	cI
+	yI	#I0
+}
+*/
+
+int printf(char *fmt);
+
+int
+main(void)
+{
+	printf("hello world\n");
+	return 0;
+}