[PATCH 1 of 1] test-suite: Added new test suite feature (experimental)

Martin Lund mgl@doredevelopment.dk
Sat May 15 15:20:00 GMT 2010


# HG changeset patch
# User Martin Lund <mgl@doredevelopment.dk>
# Date 1273934735 -7200
# Node ID 7e1196581995247e24c585653be9e65e8555d0ea
# Parent  48e107b35ba9c2b3f31667dd5042cc69bc472592
test-suite: Added new test suite feature (experimental)

This patch adds support for installing the gcc test suite. A helper
Makefile is provided for building and running the gcc tests.

The default configuration runs all gcc tests and requires automatic
ssh/scp login access to a networked target board. See README for
more details.

Note: Current feature is tested with the powerpc-unknown-linux-gnu
sample but it should work with others as well.

diff -r 48e107b35ba9 -r 7e1196581995 config/config.in
--- a/config/config.in	Fri Apr 30 22:25:45 2010 +0200
+++ b/config/config.in	Sat May 15 16:45:35 2010 +0200
@@ -9,3 +9,4 @@
 source "config/debug.in"
 source "config/companion_libs.in"
 source "config/companion_tools.in"
+source "config/test_suite.in"
diff -r 48e107b35ba9 -r 7e1196581995 config/test_suite.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/test_suite.in	Sat May 15 16:45:35 2010 +0200
@@ -0,0 +1,30 @@
+# Test suite config options
+
+if EXPERIMENTAL
+
+menu "Test suite"
+
+config TEST_SUITE
+    bool
+    default n
+
+config TEST_SUITE_GCC
+    bool
+    prompt "GCC test suite"
+    depends on EXPERIMENTAL
+    default n
+    select TEST_SUITE
+    help
+      Select this option to install the GCC test suite in $CT_PREFIX_DIR/test_suite.
+
+      The GCC test suite includes a collection of various toolchain tests for GCC -
+      it utilizes the DejaGnu test framework.
+
+      For some tests a network enabled target with ssh server is required.
+
+      A helper Makefile is provided for running the tests - please see the included 
+      README for information on how to run the test suite.
+
+endmenu
+
+endif
diff -r 48e107b35ba9 -r 7e1196581995 contrib/gcc-test-suite/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/gcc-test-suite/Makefile	Sat May 15 16:45:35 2010 +0200
@@ -0,0 +1,75 @@
+# Helper makefile which downloads (if required) and runs the GCC test suite (DejaGnu)
+#
+# Note: Before run please make sure to have your toolchain available in your path.
+#
+# Copyright 2010 DoréDevelopment
+# 
+# Author: Martin Lund <mgl@doredevelopment.dk>
+#
+# This program is free software; you can redistribute  it and/or modify it
+# under  the terms of  the GNU General  Public License as published by the
+# Free Software Foundation;  either version 2 of the  License, or (at your
+# option) any later version.
+#
+
+# Internal directory configuration
+TOPDIR=${shell pwd}
+TMPDIR=${TOPDIR}/tmp
+
+# Include default configuration
+include default.cfg
+
+# Add toolchain to path
+PATH:=${DG_TOOLCHAIN_DIR}:${PATH}
+
+# Select test set
+ifeq (${DG_TOOLNAME},gcc)
+	DG_TESTS=$(DG_C_TESTS)
+endif
+ifeq (${DG_TOOLNAME},g++)
+	DG_TESTS=$(DG_CPP_TESTS)
+endif
+
+# Check that we have 'runtest' installed
+RUNTEST=$(shell which runtest)
+ifeq "${RUNTEST}" ""
+        $(error "DejaGnu 'runtest' not found - please install (eg. apt-get install dejagnu)")
+endif
+
+# Targets 
+all: test
+
+gcc-testsuite-${DG_GCC_VERSION}.tar.gz:
+#	wget -nc ${DG_GCC_URL}
+    
+gcc-${DG_GCC_VERSION}: gcc-testsuite-${DG_GCC_VERSION}.tar.gz
+#	tar xzf gcc-testsuite-${DG_GCC_VERSION}.tar.gz
+
+config:
+	@mkdir -p ${TMPDIR}
+	@{ echo 'lappend boards_dir "."'; \
+	  echo "set target_alias ${DG_TARGET}"; } > ${TMPDIR}/site.exp
+	@{ echo -e "load_generic_config \"unix\""; \
+	echo -e "process_multilib_options \"\"" ; \
+	echo "set_board_info bmk,use_alarm 1" ; \
+	echo "set_board_info rsh_prog ssh" ; \
+	echo "set_board_info rcp_prog scp" ; \
+	echo "set_board_info hostname ${DG_TARGET_HOSTNAME}"; \
+	echo "set_board_info username ${DG_TARGET_USERNAME}"; } > ${TMPDIR}/board.exp
+
+test: gcc-${DG_GCC_VERSION} config
+	cd ${TMPDIR} && \
+	runtest	--tool ${DG_TOOLNAME} \
+		--srcdir ${DG_SRC_DIR} \
+		--all \
+		--target ${DG_TARGET} \
+		--target_board board \
+		${DG_TESTS} \
+		GXX_UNDER_TEST=${DG_TARGET}-g++ ; \
+	mv ${TMPDIR}/*.log ${TOPDIR} ; \
+	mv ${TMPDIR}/*.sum ${TOPDIR}
+
+clean:
+	rm -rf gcc-testsuite-${DG_GCC_VERSION}.tar.gz gcc-${DG_GCC_VERSION} ${TMPDIR} *.log *.sum 
+
+.PHONY: config test clean
diff -r 48e107b35ba9 -r 7e1196581995 contrib/gcc-test-suite/README
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/gcc-test-suite/README	Sat May 15 16:45:35 2010 +0200
@@ -0,0 +1,71 @@
+
+Helper Makefile for testing gcc toolchains using the gcc-testsuite
+==================================================================
+
+Requirements
+------------
+
+* DejaGnu 'runtest' v1.4.4+
+* Make v3.81+
+* wget
+
+
+Configuration
+-------------
+
+Edit default.cfg to reflect your toolchain and target configuration.
+
+Alternatively, override configuration variables on the command line.
+
+Available config variables:
+
+DG_GCC_VERSION
+DG_GCC_URL
+DG_TOOLNAME
+DG_TARGET
+DG_TARGET_HOSTNAME
+DG_TARGET_USERNAME
+DG_C_TESTS
+DG_CPP_TESTS
+DG_TOOLCHAIN_DIR
+DG_SRC_DIR
+
+
+Run examples
+------------
+
+The first two examples require a networked target with ssh access and automatic
+ssh login (see section below). Target SW should be compiled with the toolchain 
+to be tested.
+
+Run default gcc compile/execution tests:
+$ make DG_TOOLNAME=gcc DG_TARGET_HOSTNAME=192.168.17.93 DG_TARGET_USERNAME=root
+
+Run default g++ compile/execution tests:
+$ make DG_TOOLNAME=g++ DG_TARGET_HOSTNAME=192.168.17.93 DG_TARGET_USERNAME=root
+
+Run selected gcc compile only tests (no target required):
+$ make DG_TOOLNAME=gcc DG_C_TESTS="compile.exp noncompile.exp" 
+
+
+SSH automatic login configuration example
+-----------------------------------------
+
+On host do: 
+ssh-keygen -t rsa (then simply press enter thru all steps)
+scp ~/.ssh/id_rsa.pub <username>@<target IP>:~/
+
+On target do:
+cd ~
+mkdir .ssh
+cat id_rsa.pub >> .ssh/authorized_keys
+rm id_rsa.pub
+
+Now automatic ssh login should work - test by doing a simple ssh session to target.
+
+Note: The procedure might be slightly different for your particular target.
+
+
+Author
+------
+Martin Lund <mgl@doredevelopment.dk>
diff -r 48e107b35ba9 -r 7e1196581995 contrib/gcc-test-suite/default.cfg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/gcc-test-suite/default.cfg	Sat May 15 16:45:35 2010 +0200
@@ -0,0 +1,17 @@
+# Default test suite configuration
+
+# GCC configuration
+DG_GCC_VERSION = 4.3.2
+DG_GCC_URL = ftp://gcc.gnu.org/pub/gcc/releases/gcc-${DG_GCC_VERSION}/gcc-testsuite-${DG_GCC_VERSION}.tar.gz
+
+# Default DejaGnu configuration
+DG_TOOLNAME = gcc
+DG_TARGET_HOSTNAME = 127.0.0.1
+DG_TARGET_USERNAME = root
+DG_TARGET = powerpc-unknown-linux-gnu
+DG_SRC_DIR = ${TOPDIR}/gcc-${DG_GCC_VERSION}/gcc/testsuite
+DG_TOOLCHAIN_DIR = ${TOPDIR}/../../bin
+
+# Default tests
+DG_C_TESTS = 
+DG_CPP_TESTS = 
diff -r 48e107b35ba9 -r 7e1196581995 scripts/build/test_suite.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/test_suite.sh	Sat May 15 16:45:35 2010 +0200
@@ -0,0 +1,41 @@
+# Wrapper to build the test suite facilities
+#
+# Current assumption: test suites are independent of each other
+#                     - no order handling required.
+
+# List all test suite facilities, and parse their scripts
+CT_TEST_SUITE_FACILITY_LIST=
+for f in "${CT_LIB_DIR}/scripts/build/test_suite/"*.sh; do
+    _f="$(basename "${f}" .sh)"
+    __f="CT_TEST_SUITE_${_f}"
+    __f=`echo ${__f} | tr "[:lower:]" "[:upper:]"`
+    if [ "${!__f}" = "y" ]; then
+        CT_DoLog DEBUG "Enabling test suite '${_f}'"
+        . "${f}"
+        CT_TEST_SUITE_FACILITY_LIST="${CT_TEST_SUITE_FACILITY_LIST} ${_f}"
+    else
+        CT_DoLog DEBUG "Disabling test suite '${_f}'"
+    fi
+done
+
+# Download the test suite facilities
+do_test_suite_get() {
+    for f in ${CT_TEST_SUITE_FACILITY_LIST}; do
+        do_test_suite_${f}_get
+    done
+}
+
+# Extract and patch the test suite facilities
+do_test_suite_extract() {
+    for f in ${CT_TEST_SUITE_FACILITY_LIST}; do
+        do_test_suite_${f}_extract
+    done
+}
+
+# Build the test suite facilities
+do_test_suite() {
+    for f in ${CT_TEST_SUITE_FACILITY_LIST}; do
+        do_test_suite_${f}_build
+    done
+}
+
diff -r 48e107b35ba9 -r 7e1196581995 scripts/build/test_suite/gcc.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/test_suite/gcc.sh	Sat May 15 16:45:35 2010 +0200
@@ -0,0 +1,36 @@
+# This file adds the functions to build the GCC test suite
+# Copyright 2010 DoréDevelopment
+# Created by Martin Lund <mgl@doredevelopment.dk>
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_test_suite_gcc_get() { :; }
+do_test_suite_gcc_extract() { :; }
+do_test_suite_gcc_build() { :; }
+
+# Overide functions depending on configuration
+if [ "${CT_TEST_SUITE_GCC}" = "y" ]; then
+
+do_test_suite_gcc_build() {
+ 
+    CT_DoStep INFO "Installing GCC test suite"
+
+    CT_DoExecLog ALL mkdir -p "${CT_TEST_SUITE_DIR}/gcc-test-suite/gcc-${CT_CC_VERSION}/gcc"
+    CT_DoExecLog ALL cp "${CT_TOP_DIR}/contrib/gcc-test-suite/Makefile" \
+                        "${CT_TEST_SUITE_DIR}/gcc-test-suite"
+    CT_DoExecLog ALL cp "${CT_TOP_DIR}/contrib/gcc-test-suite/default.cfg" \
+                        "${CT_TEST_SUITE_DIR}/gcc-test-suite"
+    CT_DoExecLog ALL cp "${CT_TOP_DIR}/contrib/gcc-test-suite/README" \
+                        "${CT_TEST_SUITE_DIR}/gcc-test-suite"
+    CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/testsuite" \
+                           "${CT_TEST_SUITE_DIR}/gcc-test-suite/gcc-${CT_CC_VERSION}/gcc"
+    sed "s/DG_GCC_VERSION .*/DG_GCC_VERSION = ${CT_CC_VERSION}/g" \
+        ${CT_TEST_SUITE_DIR}/gcc-test-suite/default.cfg > \
+        ${CT_TEST_SUITE_DIR}/gcc-test-suite/default.cfg.tmp
+    sed "s/DG_TARGET .*/DG_TARGET = ${CT_TARGET}/g" \
+        ${CT_TEST_SUITE_DIR}/gcc-test-suite/default.cfg.tmp > \
+        ${CT_TEST_SUITE_DIR}/gcc-test-suite/default.cfg
+    CT_DoExecLog ALL rm -f "${CT_TEST_SUITE_DIR}/gcc-test-suite/default.cfg.tmp"
+    CT_EndStep
+}
+
+fi # CT_TEST_SUITE_GCC
diff -r 48e107b35ba9 -r 7e1196581995 scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Fri Apr 30 22:25:45 2010 +0200
+++ b/scripts/crosstool-NG.sh.in	Sat May 15 16:45:35 2010 +0200
@@ -125,6 +125,7 @@
 . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
 . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
 . "${CT_LIB_DIR}/scripts/build/debug.sh"
+. "${CT_LIB_DIR}/scripts/build/test_suite.sh"
 
 # Target tuple: CT_TARGET needs a little love:
 CT_DoBuildTargetTuple
@@ -159,6 +160,9 @@
     CT_COMPLIBS_DIR="${CT_BUILD_DIR}/static"
 fi
 
+# Compute test suite install directory
+CT_TEST_SUITE_DIR=${CT_INSTALL_DIR}/test-suite
+
 # Note: we'll always install the core compiler in its own directory, so as to
 # not mix the two builds: core and final.
 CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static"
@@ -519,6 +523,7 @@
         do_cc_get
         do_libc_get
         do_debug_get
+        do_test_suite_get
         CT_EndStep
     fi
 
@@ -549,6 +554,7 @@
         do_cc_extract
         do_libc_extract
         do_debug_extract
+        do_test_suite_extract
         CT_EndStep
     fi
 fi
@@ -597,5 +603,6 @@
 
 [ "${CT_LOG_FILE_COMPRESS}" = y ] && bzip2 -9 "${CT_LOG_FILE}"
 [ "${CT_INSTALL_DIR_RO}" = "y"  ] && chmod -R a-w "${CT_INSTALL_DIR}"
+[ "${CT_TEST_SUITE}" = "y" ] && chmod -R a+w "${CT_TEST_SUITE_DIR}"
 
 trap - EXIT
diff -r 48e107b35ba9 -r 7e1196581995 steps.mk
--- a/steps.mk	Fri Apr 30 22:25:45 2010 +0200
+++ b/steps.mk	Sat May 15 16:45:35 2010 +0200
@@ -39,6 +39,7 @@
             libelf_target       \
             binutils_target     \
             debug               \
+            test_suite          \
             finish              \
 
 # Make the list available to sub-processes (scripts/crosstool-NG.sh needs it)


More information about the crossgcc mailing list