ref: a032cacd156cbd3605b5c8f4c4c1149d56711eaa
parent: 57b7d9443f8a5ea6e19a7080f5ed310b86c3db74
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Aug 28 06:44:58 EDT 2019
[tests/size] Add tests for size
--- /dev/null
+++ b/tests/size/execute/0001-z80.sh
@@ -1,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
--- /dev/null
+++ b/tests/size/execute/0002-z80-t.sh
@@ -1,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
--- /dev/null
+++ b/tests/size/execute/Makefile
@@ -1,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
--- /dev/null
+++ b/tests/size/execute/chktest.sh
@@ -1,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
--- /dev/null
+++ b/tests/size/execute/master.s
@@ -1,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