scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 49ea14f17cb76c7112691a4ed951315f3d105c63
parent 15accc917305a32e269f8f3063108e9115d44d3d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 13 Aug 2015 19:59:58 +0200

Add first test program

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

Diffstat:
cc1/tests/chktest.sh | 25+++++++++++++++++++++++++
cc1/tests/test001.c | 23+++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/cc1/tests/chktest.sh b/cc1/tests/chktest.sh @@ -0,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 diff --git a/cc1/tests/test001.c b/cc1/tests/test001.c @@ -0,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; +}