scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 7269bad586839a83c2365821df22c6181934ba72
parent 47f7f09b8f01ed0cd8d25d509299ae6066cb7ffa
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 12 Mar 2018 16:07:10 +0100

[tests] Add basic execute test for nm

Diffstat:
Mtests/Makefile | 6++++--
Mtests/ar/Makefile | 4+++-
Mtests/ar/execute/chktest.sh | 2+-
Atests/nm/Makefile | 9+++++++++
Atests/nm/execute/0001-z80.sh | 27+++++++++++++++++++++++++++
Atests/nm/execute/Makefile | 12++++++++++++
Atests/nm/execute/chktest.sh | 16++++++++++++++++
Atests/nm/execute/master.s | 23+++++++++++++++++++++++
8 files changed, 95 insertions(+), 4 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile @@ -1,7 +1,9 @@ .POSIX: -include ../config.mk -DIRS=scc ar +PROJECTDIR = .. +include $(PROJECTDIR)/rules.mk + +DIRS=ar nm all clean: $(FORALL) diff --git a/tests/ar/Makefile b/tests/ar/Makefile @@ -1,5 +1,7 @@ .POSIX: -include ../../config.mk + +PROJECTDIR = ../.. +include $(PROJECTDIR)/rules.mk DIRS=error execute diff --git a/tests/ar/execute/chktest.sh b/tests/ar/execute/chktest.sh @@ -4,7 +4,7 @@ ttyflags=`stty -g` trap "stty $ttyflags;tabs -8;rm -rf file*" 0 2 3 15 stty tabs tabs 40 -ulimit -c 40 +ulimit -c 0 rm -f test.log rm -rf file* diff --git a/tests/nm/Makefile b/tests/nm/Makefile @@ -0,0 +1,9 @@ +.POSIX: + +PROJECTDIR = ../.. +include $(PROJECTDIR)/rules.mk + +DIRS=execute + +all clean: + $(FORALL) diff --git a/tests/nm/execute/0001-z80.sh b/tests/nm/execute/0001-z80.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +tmp1=`mktemp` +tmp2=`mktemp` +trap "rm -f a.out $tmp1 $tmp2" 0 2 3 + +z80-unknown-coff-as master.s +nm > $tmp1 + +cat <<! > $tmp2 +0000000000000000 b .bss +0000000000000000 d .data +0000000000000000 t .text +0000000000000001 B averylongbss  +0000000000000001 D averylongdata +0000000000000001 T averylongtext +0000000000000000 B bss1 +0000000000000002 b bss3 +0000000000000000 D data1 +0000000000000002 d data3 +0000000000000000 T text1 +0000000000000002 t text3 +! + +cmp $tmp1 $tmp2 diff --git a/tests/nm/execute/Makefile b/tests/nm/execute/Makefile @@ -0,0 +1,12 @@ +.POSIX: + +PROJECTDIR=$$PWD/../../.. +ROOTDIR=$(PROJECTDIR)/rootdir + +all: tests + +tests: master.s + @PATH=$(ROOTDIR)/bin:$$PATH ./chktest.sh + +clean: + rm -f f.s a.out test.log diff --git a/tests/nm/execute/chktest.sh b/tests/nm/execute/chktest.sh @@ -0,0 +1,16 @@ +#!/bin//sh + +ttyflags=`stty -g` +trap "stty $ttyflags;tabs -8; rm -f a.out" 0 2 3 15 +stty tabs +tabs 40 +ulimit -c 0 +rm -f test.log + + +for i in *-*.sh +do + printf "Test: %s\n\n" $i >> test.log + printf "%s\t" $i + ./$i >> test.log 2>&1 && echo [OK] || echo [FAIL] +done diff --git a/tests/nm/execute/master.s b/tests/nm/execute/master.s @@ -0,0 +1,23 @@ + .globl text1,averylongtext + .text + .equ text2,4 +text1: .byte 0 +averylongtext: + .byte 0 +text3: .byte 0 + + .globl data1,averylongdata + .data + .equ data2,5 +data1: .byte 3 +averylongdata: + .byte 0 +data3: .byte 0 + + .globl bss1,averylongbss + .bss + .equ bss2,5 +bss1: .byte 0 +averylongbss: + .byte 0 +bss3: .byte 0