ref: b9c46d54a5af0105df3edf2b858459b71c2283bf
parent: 5d34077110dc3c09b256f68ea3fe017dd0451273
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Mar 12 12:07:10 EDT 2018
[tests] Add basic execute test for nm
--- 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)
--- a/tests/ar/Makefile
+++ b/tests/ar/Makefile
@@ -1,5 +1,7 @@
.POSIX:
-include ../../config.mk
+
+PROJECTDIR = ../..
+include $(PROJECTDIR)/rules.mk
DIRS=error execute
--- a/tests/ar/execute/chktest.sh
+++ b/tests/ar/execute/chktest.sh
@@ -4,7 +4,7 @@
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*
--- /dev/null
+++ b/tests/nm/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../..
+include $(PROJECTDIR)/rules.mk
+
+DIRS=execute
+
+all clean:
+ $(FORALL)
--- /dev/null
+++ b/tests/nm/execute/0001-z80.sh
@@ -1,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
--- /dev/null
+++ b/tests/nm/execute/Makefile
@@ -1,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
--- /dev/null
+++ b/tests/nm/execute/chktest.sh
@@ -1,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
--- /dev/null
+++ b/tests/nm/execute/master.s
@@ -1,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