scc

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

commit bea6fce5f7aa228c91283ad94cc8b5544313cb07
parent 29cdba27742a2f8d7280ffaf7b9dc8ddd60e15ac
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 28 Aug 2019 10:44:58 +0100

[tests/size] Add tests for size

Diffstat:
Atests/size/execute/0001-z80.sh | 16++++++++++++++++
Atests/size/execute/0002-z80-t.sh | 18++++++++++++++++++
Atests/size/execute/Makefile | 15+++++++++++++++
Atests/size/execute/chktest.sh | 12++++++++++++
Atests/size/execute/master.s | 31+++++++++++++++++++++++++++++++
5 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/tests/size/execute/0001-z80.sh b/tests/size/execute/0001-z80.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e +trap 'rm -f $tmp1 $tmp2' EXIT HUP INT QUIT TERM + +tmp1=`mktemp` +tmp2=`mktemp` + +size z80.out >$tmp1 + +cat > $tmp2 <<EOF +text data bss dec hex filename +5 3 3 11 b z80.out +EOF + +diff $tmp1 $tmp2 diff --git a/tests/size/execute/0002-z80-t.sh b/tests/size/execute/0002-z80-t.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e +trap 'rm -f $tmp1 $tmp2' EXIT HUP INT QUIT TERM + +tmp1=`mktemp` +tmp2=`mktemp` + +size -t z80.out z80.out>$tmp1 + +cat > $tmp2 <<EOF +text data bss dec hex filename +5 3 3 11 b z80.out +5 3 3 11 b z80.out +10 6 6 22 16 (TOTALS) +EOF + +diff $tmp1 $tmp2 diff --git a/tests/size/execute/Makefile b/tests/size/execute/Makefile @@ -0,0 +1,15 @@ +.POSIX: +ROOT=../../.. + +OUT = z80.out + +all: tests + +tests: $(OUT) + @PATH=$(ROOT)/bin:$$PATH:. chktest.sh + +z80.out: master.s + z80-unknown-coff-as -o $@ master.s + +clean: + rm -f *.a *.out test.log diff --git a/tests/size/execute/chktest.sh b/tests/size/execute/chktest.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +trap "rm -f a.out; exit" 0 2 3 15 +ulimit -c 0 +rm -f test.log + +for i in *-*.sh +do + printf "Test: %s\n\n" $i >> test.log + ./$i >> test.log 2>&1 && printf '[PASS]\t' || printf '[FAIL]\t' + echo "$i" +done diff --git a/tests/size/execute/master.s b/tests/size/execute/master.s @@ -0,0 +1,31 @@ + .globl text1,averylongtext,text5 + .extern text6 + .text + .equ text2,4 +text1: .byte 0 +averylongtext: + .byte 0 +text3: .byte 0 + .comm text4,10 + .comm text5,18 + .short text6 + + .globl data1,averylongdata,data5 + .data + .equ data2,5 +data1: .byte 3 +averylongdata: + .byte 0 +data3: .byte 0 + .comm data4,10 + .comm data5,18 + + .globl bss1,averylongbss,bss5 + .bss + .equ bss2,5 +bss1: .byte 0 +averylongbss: + .byte 0 +bss3: .byte 0 + .comm bss4,10 + .comm bss5,18