11cb0ef41Sopenharmony_ci#! /bin/sh 21cb0ef41Sopenharmony_ci# test-driver - basic testsuite driver script. 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciscriptversion=2018-03-07.03; # UTC 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci# Copyright (C) 2011-2021 Free Software Foundation, Inc. 71cb0ef41Sopenharmony_ci# 81cb0ef41Sopenharmony_ci# This program is free software; you can redistribute it and/or modify 91cb0ef41Sopenharmony_ci# it under the terms of the GNU General Public License as published by 101cb0ef41Sopenharmony_ci# the Free Software Foundation; either version 2, or (at your option) 111cb0ef41Sopenharmony_ci# any later version. 121cb0ef41Sopenharmony_ci# 131cb0ef41Sopenharmony_ci# This program is distributed in the hope that it will be useful, 141cb0ef41Sopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 151cb0ef41Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 161cb0ef41Sopenharmony_ci# GNU General Public License for more details. 171cb0ef41Sopenharmony_ci# 181cb0ef41Sopenharmony_ci# You should have received a copy of the GNU General Public License 191cb0ef41Sopenharmony_ci# along with this program. If not, see <https://www.gnu.org/licenses/>. 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci# As a special exception to the GNU General Public License, if you 221cb0ef41Sopenharmony_ci# distribute this file as part of a program that contains a 231cb0ef41Sopenharmony_ci# configuration script generated by Autoconf, you may include it under 241cb0ef41Sopenharmony_ci# the same distribution terms that you use for the rest of that program. 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci# This file is maintained in Automake, please report 271cb0ef41Sopenharmony_ci# bugs to <bug-automake@gnu.org> or send patches to 281cb0ef41Sopenharmony_ci# <automake-patches@gnu.org>. 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci# Make unconditional expansion of undefined variables an error. This 311cb0ef41Sopenharmony_ci# helps a lot in preventing typo-related bugs. 321cb0ef41Sopenharmony_ciset -u 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciusage_error () 351cb0ef41Sopenharmony_ci{ 361cb0ef41Sopenharmony_ci echo "$0: $*" >&2 371cb0ef41Sopenharmony_ci print_usage >&2 381cb0ef41Sopenharmony_ci exit 2 391cb0ef41Sopenharmony_ci} 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ciprint_usage () 421cb0ef41Sopenharmony_ci{ 431cb0ef41Sopenharmony_ci cat <<END 441cb0ef41Sopenharmony_ciUsage: 451cb0ef41Sopenharmony_ci test-driver --test-name NAME --log-file PATH --trs-file PATH 461cb0ef41Sopenharmony_ci [--expect-failure {yes|no}] [--color-tests {yes|no}] 471cb0ef41Sopenharmony_ci [--enable-hard-errors {yes|no}] [--] 481cb0ef41Sopenharmony_ci TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS] 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ciThe '--test-name', '--log-file' and '--trs-file' options are mandatory. 511cb0ef41Sopenharmony_ciSee the GNU Automake documentation for information. 521cb0ef41Sopenharmony_ciEND 531cb0ef41Sopenharmony_ci} 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_citest_name= # Used for reporting. 561cb0ef41Sopenharmony_cilog_file= # Where to save the output of the test script. 571cb0ef41Sopenharmony_citrs_file= # Where to save the metadata of the test run. 581cb0ef41Sopenharmony_ciexpect_failure=no 591cb0ef41Sopenharmony_cicolor_tests=no 601cb0ef41Sopenharmony_cienable_hard_errors=yes 611cb0ef41Sopenharmony_ciwhile test $# -gt 0; do 621cb0ef41Sopenharmony_ci case $1 in 631cb0ef41Sopenharmony_ci --help) print_usage; exit $?;; 641cb0ef41Sopenharmony_ci --version) echo "test-driver $scriptversion"; exit $?;; 651cb0ef41Sopenharmony_ci --test-name) test_name=$2; shift;; 661cb0ef41Sopenharmony_ci --log-file) log_file=$2; shift;; 671cb0ef41Sopenharmony_ci --trs-file) trs_file=$2; shift;; 681cb0ef41Sopenharmony_ci --color-tests) color_tests=$2; shift;; 691cb0ef41Sopenharmony_ci --expect-failure) expect_failure=$2; shift;; 701cb0ef41Sopenharmony_ci --enable-hard-errors) enable_hard_errors=$2; shift;; 711cb0ef41Sopenharmony_ci --) shift; break;; 721cb0ef41Sopenharmony_ci -*) usage_error "invalid option: '$1'";; 731cb0ef41Sopenharmony_ci *) break;; 741cb0ef41Sopenharmony_ci esac 751cb0ef41Sopenharmony_ci shift 761cb0ef41Sopenharmony_cidone 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_cimissing_opts= 791cb0ef41Sopenharmony_citest x"$test_name" = x && missing_opts="$missing_opts --test-name" 801cb0ef41Sopenharmony_citest x"$log_file" = x && missing_opts="$missing_opts --log-file" 811cb0ef41Sopenharmony_citest x"$trs_file" = x && missing_opts="$missing_opts --trs-file" 821cb0ef41Sopenharmony_ciif test x"$missing_opts" != x; then 831cb0ef41Sopenharmony_ci usage_error "the following mandatory options are missing:$missing_opts" 841cb0ef41Sopenharmony_cifi 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ciif test $# -eq 0; then 871cb0ef41Sopenharmony_ci usage_error "missing argument" 881cb0ef41Sopenharmony_cifi 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_ciif test $color_tests = yes; then 911cb0ef41Sopenharmony_ci # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'. 921cb0ef41Sopenharmony_ci red='[0;31m' # Red. 931cb0ef41Sopenharmony_ci grn='[0;32m' # Green. 941cb0ef41Sopenharmony_ci lgn='[1;32m' # Light green. 951cb0ef41Sopenharmony_ci blu='[1;34m' # Blue. 961cb0ef41Sopenharmony_ci mgn='[0;35m' # Magenta. 971cb0ef41Sopenharmony_ci std='[m' # No color. 981cb0ef41Sopenharmony_cielse 991cb0ef41Sopenharmony_ci red= grn= lgn= blu= mgn= std= 1001cb0ef41Sopenharmony_cifi 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_cido_exit='rm -f $log_file $trs_file; (exit $st); exit $st' 1031cb0ef41Sopenharmony_citrap "st=129; $do_exit" 1 1041cb0ef41Sopenharmony_citrap "st=130; $do_exit" 2 1051cb0ef41Sopenharmony_citrap "st=141; $do_exit" 13 1061cb0ef41Sopenharmony_citrap "st=143; $do_exit" 15 1071cb0ef41Sopenharmony_ci 1081cb0ef41Sopenharmony_ci# Test script is run here. We create the file first, then append to it, 1091cb0ef41Sopenharmony_ci# to ameliorate tests themselves also writing to the log file. Our tests 1101cb0ef41Sopenharmony_ci# don't, but others can (automake bug#35762). 1111cb0ef41Sopenharmony_ci: >"$log_file" 1121cb0ef41Sopenharmony_ci"$@" >>"$log_file" 2>&1 1131cb0ef41Sopenharmony_ciestatus=$? 1141cb0ef41Sopenharmony_ci 1151cb0ef41Sopenharmony_ciif test $enable_hard_errors = no && test $estatus -eq 99; then 1161cb0ef41Sopenharmony_ci tweaked_estatus=1 1171cb0ef41Sopenharmony_cielse 1181cb0ef41Sopenharmony_ci tweaked_estatus=$estatus 1191cb0ef41Sopenharmony_cifi 1201cb0ef41Sopenharmony_ci 1211cb0ef41Sopenharmony_cicase $tweaked_estatus:$expect_failure in 1221cb0ef41Sopenharmony_ci 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 1231cb0ef41Sopenharmony_ci 0:*) col=$grn res=PASS recheck=no gcopy=no;; 1241cb0ef41Sopenharmony_ci 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 1251cb0ef41Sopenharmony_ci 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; 1261cb0ef41Sopenharmony_ci *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; 1271cb0ef41Sopenharmony_ci *:*) col=$red res=FAIL recheck=yes gcopy=yes;; 1281cb0ef41Sopenharmony_ciesac 1291cb0ef41Sopenharmony_ci 1301cb0ef41Sopenharmony_ci# Report the test outcome and exit status in the logs, so that one can 1311cb0ef41Sopenharmony_ci# know whether the test passed or failed simply by looking at the '.log' 1321cb0ef41Sopenharmony_ci# file, without the need of also peaking into the corresponding '.trs' 1331cb0ef41Sopenharmony_ci# file (automake bug#11814). 1341cb0ef41Sopenharmony_ciecho "$res $test_name (exit status: $estatus)" >>"$log_file" 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ci# Report outcome to console. 1371cb0ef41Sopenharmony_ciecho "${col}${res}${std}: $test_name" 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ci# Register the test result, and other relevant metadata. 1401cb0ef41Sopenharmony_ciecho ":test-result: $res" > $trs_file 1411cb0ef41Sopenharmony_ciecho ":global-test-result: $res" >> $trs_file 1421cb0ef41Sopenharmony_ciecho ":recheck: $recheck" >> $trs_file 1431cb0ef41Sopenharmony_ciecho ":copy-in-global-log: $gcopy" >> $trs_file 1441cb0ef41Sopenharmony_ci 1451cb0ef41Sopenharmony_ci# Local Variables: 1461cb0ef41Sopenharmony_ci# mode: shell-script 1471cb0ef41Sopenharmony_ci# sh-indentation: 2 1481cb0ef41Sopenharmony_ci# eval: (add-hook 'before-save-hook 'time-stamp) 1491cb0ef41Sopenharmony_ci# time-stamp-start: "scriptversion=" 1501cb0ef41Sopenharmony_ci# time-stamp-format: "%:y-%02m-%02d.%02H" 1511cb0ef41Sopenharmony_ci# time-stamp-time-zone: "UTC0" 1521cb0ef41Sopenharmony_ci# time-stamp-end: "; # UTC" 1531cb0ef41Sopenharmony_ci# End: 154