shithub: scc

Download patch

ref: 27b4662757e3d9a500b69a96057cef8fdeacca99
parent: 83c240a88a73f442b884cfa7bd7293d7f0f00a80
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Aug 22 14:36:42 EDT 2018

[tests/libc] Add libc test framework

diff: cannot open b/tests/libc/execute//null: file does not exist: 'b/tests/libc/execute//null' diff: cannot open b/tests/libc//null: file does not exist: 'b/tests/libc//null'
--- /dev/null
+++ b/tests/libc/execute/0001-abort.c
@@ -1,0 +1,18 @@
+
+#include <signal.h>
+#include <stdlib.h>
+
+void
+handler(int dummy)
+{
+	exit(EXIT_SUCCESS);
+}
+
+int
+main(void)
+{
+	signal(SIGABRT, handler);
+	abort();
+
+	return 1;
+}
--- /dev/null
+++ b/tests/libc/execute/Makefile
@@ -1,0 +1,12 @@
+.POSIX:
+
+ROOT=../../../rootdir
+
+all: tests
+
+tests:
+	@CFLAGS='' SCCPREFIX=$(ROOT) ./chktest.sh libc-tests.lst
+
+clean:
+	rm -f *.o *core a.out test.log
+
--- /dev/null
+++ b/tests/libc/execute/cc.sh
@@ -1,0 +1,37 @@
+#!/bin/sh
+
+set -e
+
+for i
+do
+	case "$i" in
+	-r)
+		root=$2
+		shift 2
+		;;
+	-a)
+		abi=$2
+		shift 2
+		;;
+	-s)
+		sys=$2
+		shift 2
+		;;
+	-*)
+		echo usage: cc.sh [-t target] file
+		exit 1
+		;;
+	esac
+done
+
+sys=${sys:-linux}
+abi=${abi:-amd64-sysv}
+root=${root:-$SCCPREFIX}
+inc=$root/include/scc
+arch_inc=$root/include/scc/bits/$abi
+lib=$root/lib/scc/${abi}-${sys}
+obj=${1%.c}.o
+
+c99 -nostdinc -I$inc -I$arch_inc -c $1
+echo ld -L$lib $lib/crt.o $obj -lc >&2
+ld -L$lib $lib/crt.o $obj -lc
--- /dev/null
+++ b/tests/libc/execute/chktest.sh
@@ -1,0 +1,22 @@
+#!/bin/sh
+
+file=${1?' empty input file'}
+
+ttyflags=`stty -g`
+trap "stty $ttyflags;tabs -8;rm -f a.out" 0 1 2 3 15
+stty tabs
+tabs 40
+ulimit -c 0
+rm -f test.log
+
+cat $file |
+while read i state
+do
+	echo $i >>test.log
+	printf "%s\t" $i
+	printf "%s" $state
+	rm -f a.out
+
+	(./cc.sh $CFLAGS $i && ./a.out) 2>test.log &&
+	echo "[OK]" || echo "[FAILED]"
+done
--- /dev/null
+++ b/tests/libc/execute/libc-tests.lst
@@ -1,0 +1,1 @@
+0001-abort.c [TODO]