瀏覽代碼

test: gcc version test scripts

Test if gcc version is correctly detected with a large collection
of gcc version strings. To be used each time the gcc version
detection is changed.
Andrei Pelinescu-Onciul 16 年之前
父節點
當前提交
7ac811b4fd
共有 2 個文件被更改,包括 43 次插入0 次删除
  1. 17 0
      test/gcc_version.sh
  2. 26 0
      test/gcc_version_test.sh

+ 17 - 0
test/gcc_version.sh

@@ -0,0 +1,17 @@
+#!/bin/sh
+
+#
+# wrapper arroung gcc, that intercepts --version and reports instead
+# $GCC_VERSION
+#
+
+if [ -n "$GCC_VERSION" ]; then
+	for o in $@; do
+		if [ "$o" = "--version" ] ; then
+			echo $GCC_VERSION
+			exit 0
+		fi
+	done
+fi
+
+gcc $@

+ 26 - 0
test/gcc_version_test.sh

@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# test make cfg with all the gcc versions in gcc_versions.txt
+# should be run from the main sip-router directory
+# Depends on: test/gcc_version.sh and test/gcc_versions.txt
+
+if [ ! -e test/gcc_version.sh -o ! -r test/gcc_versions.txt -o ! -r Makefile ]
+then
+	echo "ERROR: wrong path, this test must be run from the main"\
+		" sip-router directory"
+	exit 1
+fi
+
+while read v ; do
+	GCC_VERSION=$v make CC=test/gcc_version.sh cfg-defs >/dev/null
+	if [ $? -ne 0 -o ! -r config.mak ]; then
+		echo "ERROR: make cfg failed for version \"$v\""
+		exit 1
+	fi
+	COMPILER=`egrep -o -- "-DCOMPILER='\"[^\"' ]+ [2-9]\.[0-9]{1,2}(\.[0-9]{1,2})?\"'" config.mak`
+	if [ $? -ne 0 -o -z "$COMPILER" ]; then
+		echo "ERROR: bad ver: \"$v\" => `egrep -o -- "-DCOMPILER='[^']*'" config.mak`"
+		exit 1
+	fi
+	echo "ok: \"$v\" => $COMPILER"
+done < test/gcc_versions.txt