From owner-svn-src-head@freebsd.org Tue Oct 6 16:58:50 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94C549D09FF; Tue, 6 Oct 2015 16:58:50 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 83A04954; Tue, 6 Oct 2015 16:58:50 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t96GwoMp056710; Tue, 6 Oct 2015 16:58:50 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t96GwmGj056703; Tue, 6 Oct 2015 16:58:48 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201510061658.t96GwmGj056703@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Tue, 6 Oct 2015 16:58:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288929 - in head: etc/mtree lib/libxo lib/libxo/tests usr.bin/xo usr.bin/xo/tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Oct 2015 16:58:50 -0000 Author: ngie Date: Tue Oct 6 16:58:47 2015 New Revision: 288929 URL: https://svnweb.freebsd.org/changeset/base/288929 Log: Integrate the tests from libxo into the FreeBSD test suite The functional_test.sh harness for each test subdir was inspired by the version in bin/sh/tests/functional_test.sh Some gymnastics were required to deal with implicit rules for .c / .o -> .out as the suffix transformation rules were incorrectly trying to create the test outputs from some of the source files Sponsored by: EMC / Isilon Storage Division Added: head/lib/libxo/tests/ head/lib/libxo/tests/Makefile (contents, props changed) head/lib/libxo/tests/functional_test.sh - copied, changed from r288904, head/bin/sh/tests/functional_test.sh head/usr.bin/xo/tests/ head/usr.bin/xo/tests/Makefile (contents, props changed) head/usr.bin/xo/tests/functional_test.sh - copied, changed from r288904, head/bin/sh/tests/functional_test.sh Modified: head/etc/mtree/BSD.tests.dist head/lib/libxo/Makefile head/usr.bin/xo/Makefile Modified: head/etc/mtree/BSD.tests.dist ============================================================================== --- head/etc/mtree/BSD.tests.dist Tue Oct 6 16:35:50 2015 (r288928) +++ head/etc/mtree/BSD.tests.dist Tue Oct 6 16:58:47 2015 (r288929) @@ -310,6 +310,8 @@ .. libutil .. + libxo + .. msun .. .. @@ -568,6 +570,8 @@ .. xargs .. + xo + .. yacc yacc .. Modified: head/lib/libxo/Makefile ============================================================================== --- head/lib/libxo/Makefile Tue Oct 6 16:35:50 2015 (r288928) +++ head/lib/libxo/Makefile Tue Oct 6 16:58:47 2015 (r288929) @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + LIBXOSRC= ${SRCTOP}/contrib/libxo .PATH: ${LIBXOSRC}/libxo @@ -102,4 +104,8 @@ MLINKS= xo_attr.3 xo_attr_h.3 \ xo_syslog.3 xo_set_logmask.3 \ xo_syslog.3 xo_vsyslog.3 +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include Added: head/lib/libxo/tests/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libxo/tests/Makefile Tue Oct 6 16:58:47 2015 (r288929) @@ -0,0 +1,253 @@ +# $FreeBSD$ + +.include + +LIBXOSRC= ${SRCTOP}/contrib/libxo + +# Override the default suffix transformation rules for .c/.o -> .out +.SUFFIXES: +.SUFFIXES: .c .err .o .out .sh + +.PATH: +.PATH.c: ${LIBXOSRC}/libxo ${LIBXOSRC}/tests/core +.PATH.err: ${LIBXOSRC}/tests/core/saved +.PATH.out: ${LIBXOSRC}/tests/core/saved + +.c.out .o.out: + +TESTSDIR= ${TESTSBASE}/lib/libxo + +ATF_TESTS_SH+= functional_test + +BINDIR= ${TESTSDIR} + +FILES+= test_01.E.err +FILES+= test_01.E.out +FILES+= test_01.H.err +FILES+= test_01.H.out +FILES+= test_01.HIPx.err +FILES+= test_01.HIPx.out +FILES+= test_01.HP.err +FILES+= test_01.HP.out +FILES+= test_01.J.err +FILES+= test_01.J.out +FILES+= test_01.JP.err +FILES+= test_01.JP.out +FILES+= test_01.T.err +FILES+= test_01.T.out +FILES+= test_01.X.err +FILES+= test_01.X.out +FILES+= test_01.XP.err +FILES+= test_01.XP.out +FILES+= test_01.err +FILES+= test_01.out +FILES+= test_02.E.err +FILES+= test_02.E.out +FILES+= test_02.H.err +FILES+= test_02.H.out +FILES+= test_02.HIPx.err +FILES+= test_02.HIPx.out +FILES+= test_02.HP.err +FILES+= test_02.HP.out +FILES+= test_02.J.err +FILES+= test_02.J.out +FILES+= test_02.JP.err +FILES+= test_02.JP.out +FILES+= test_02.T.err +FILES+= test_02.T.out +FILES+= test_02.X.err +FILES+= test_02.X.out +FILES+= test_02.XP.err +FILES+= test_02.XP.out +FILES+= test_02.err +FILES+= test_02.out +FILES+= test_03.E.err +FILES+= test_03.E.out +FILES+= test_03.H.err +FILES+= test_03.H.out +FILES+= test_03.HIPx.err +FILES+= test_03.HIPx.out +FILES+= test_03.HP.err +FILES+= test_03.HP.out +FILES+= test_03.J.err +FILES+= test_03.J.out +FILES+= test_03.JP.err +FILES+= test_03.JP.out +FILES+= test_03.T.err +FILES+= test_03.T.out +FILES+= test_03.X.err +FILES+= test_03.X.out +FILES+= test_03.XP.err +FILES+= test_03.XP.out +FILES+= test_03.err +FILES+= test_03.out +FILES+= test_04.E.err +FILES+= test_04.E.out +FILES+= test_04.H.err +FILES+= test_04.H.out +FILES+= test_04.HIPx.err +FILES+= test_04.HIPx.out +FILES+= test_04.HP.err +FILES+= test_04.HP.out +FILES+= test_04.J.err +FILES+= test_04.J.out +FILES+= test_04.JP.err +FILES+= test_04.JP.out +FILES+= test_04.T.err +FILES+= test_04.T.out +FILES+= test_04.X.err +FILES+= test_04.X.out +FILES+= test_04.XP.err +FILES+= test_04.XP.out +FILES+= test_05.E.err +FILES+= test_05.E.out +FILES+= test_05.H.err +FILES+= test_05.H.out +FILES+= test_05.HIPx.err +FILES+= test_05.HIPx.out +FILES+= test_05.HP.err +FILES+= test_05.HP.out +FILES+= test_05.J.err +FILES+= test_05.J.out +FILES+= test_05.JP.err +FILES+= test_05.JP.out +FILES+= test_05.T.err +FILES+= test_05.T.out +FILES+= test_05.X.err +FILES+= test_05.X.out +FILES+= test_05.XP.err +FILES+= test_05.XP.out +FILES+= test_06.E.err +FILES+= test_06.E.out +FILES+= test_06.H.err +FILES+= test_06.H.out +FILES+= test_06.HIPx.err +FILES+= test_06.HIPx.out +FILES+= test_06.HP.err +FILES+= test_06.HP.out +FILES+= test_06.J.err +FILES+= test_06.J.out +FILES+= test_06.JP.err +FILES+= test_06.JP.out +FILES+= test_06.T.err +FILES+= test_06.T.out +FILES+= test_06.X.err +FILES+= test_06.X.out +FILES+= test_06.XP.err +FILES+= test_06.XP.out +FILES+= test_07.E.err +FILES+= test_07.E.out +FILES+= test_07.H.err +FILES+= test_07.H.out +FILES+= test_07.HIPx.err +FILES+= test_07.HIPx.out +FILES+= test_07.HP.err +FILES+= test_07.HP.out +FILES+= test_07.J.err +FILES+= test_07.J.out +FILES+= test_07.JP.err +FILES+= test_07.JP.out +FILES+= test_07.T.err +FILES+= test_07.T.out +FILES+= test_07.X.err +FILES+= test_07.X.out +FILES+= test_07.XP.err +FILES+= test_07.XP.out +FILES+= test_08.E.err +FILES+= test_08.E.out +FILES+= test_08.H.err +FILES+= test_08.H.out +FILES+= test_08.HIPx.err +FILES+= test_08.HIPx.out +FILES+= test_08.HP.err +FILES+= test_08.HP.out +FILES+= test_08.J.err +FILES+= test_08.J.out +FILES+= test_08.JP.err +FILES+= test_08.JP.out +FILES+= test_08.T.err +FILES+= test_08.T.out +FILES+= test_08.X.err +FILES+= test_08.X.out +FILES+= test_08.XP.err +FILES+= test_08.XP.out +FILES+= test_09.E.err +FILES+= test_09.E.out +FILES+= test_09.H.err +FILES+= test_09.H.out +FILES+= test_09.HIPx.err +FILES+= test_09.HIPx.out +FILES+= test_09.HP.err +FILES+= test_09.HP.out +FILES+= test_09.J.err +FILES+= test_09.J.out +FILES+= test_09.JP.err +FILES+= test_09.JP.out +FILES+= test_09.T.err +FILES+= test_09.T.out +FILES+= test_09.X.err +FILES+= test_09.X.out +FILES+= test_09.XP.err +FILES+= test_09.XP.out +FILES+= test_10.E.err +FILES+= test_10.E.out +FILES+= test_10.H.err +FILES+= test_10.H.out +FILES+= test_10.HIPx.err +FILES+= test_10.HIPx.out +FILES+= test_10.HP.err +FILES+= test_10.HP.out +FILES+= test_10.J.err +FILES+= test_10.J.out +FILES+= test_10.JP.err +FILES+= test_10.JP.out +FILES+= test_10.T.err +FILES+= test_10.T.out +FILES+= test_10.X.err +FILES+= test_10.X.out +FILES+= test_10.XP.err +FILES+= test_10.XP.out +FILES+= test_10.err +FILES+= test_10.out +FILES+= test_11.E.err +FILES+= test_11.E.out +FILES+= test_11.H.err +FILES+= test_11.H.out +FILES+= test_11.HIPx.err +FILES+= test_11.HIPx.out +FILES+= test_11.HP.err +FILES+= test_11.HP.out +FILES+= test_11.J.err +FILES+= test_11.J.out +FILES+= test_11.JP.err +FILES+= test_11.JP.out +FILES+= test_11.T.err +FILES+= test_11.T.out +FILES+= test_11.X.err +FILES+= test_11.X.out +FILES+= test_11.XP.err +FILES+= test_11.XP.out + +# XXX: the `E` format testcases don't appear to match the expected format. +#FILES:= ${FILES:N*.E.*} + +PROGS+= test_01 +PROGS+= test_02 +PROGS+= test_03 +PROGS+= test_04 +PROGS+= test_05 +PROGS+= test_06 +PROGS+= test_07 +PROGS+= test_08 +PROGS+= test_09 +PROGS+= test_10 +PROGS+= test_11 + +CFLAGS+= -I${LIBXOSRC}/libxo + +DPADD= ${LIBXO} ${LIBUTIL} +LDADD= -lxo -lutil + +SUBDIR+= encoder + +.include Copied and modified: head/lib/libxo/tests/functional_test.sh (from r288904, head/bin/sh/tests/functional_test.sh) ============================================================================== --- head/bin/sh/tests/functional_test.sh Mon Oct 5 21:41:55 2015 (r288904, copy source) +++ head/lib/libxo/tests/functional_test.sh Tue Oct 6 16:58:47 2015 (r288929) @@ -1,5 +1,5 @@ # -# Copyright 2014 EMC Corp. +# Copyright 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -31,42 +31,46 @@ SRCDIR=$(atf_get_srcdir) check() { local tc=${1}; shift + local xo_fmt=${1}; shift - export SH=$(atf_config_get bin.sh.test_shell /bin/sh) + local err_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.err" + [ -s "${err_file}" ] && err_flag="-e file:${err_file}" + local out_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.out" + [ -s "${out_file}" ] && out_flag="-o file:${out_file}" + + if [ "$xo_fmt" = "E" ]; then + LIBXO_OPTIONS="warn,encoder=test" + else + LIBXO_OPTIONS=":W${xo_fmt}" + fi + + atf_check -s exit:0 -e file:${err_file} -o file:${out_file} \ + env LC_ALL=en_US.UTF-8 \ + LIBXO_OPTIONS="${LIBXO_OPTIONS}" TZ="EST" "${SRCDIR}/${tc}" \ - local err_file="${SRCDIR}/${tc}.stderr" - [ -f "${err_file}" ] && err_flag="-e file:${err_file}" - local out_file="${SRCDIR}/${tc}.stdout" - [ -f "${out_file}" ] && out_flag="-o file:${out_file}" - - atf_check -s exit:${tc##*.} ${err_flag} ${out_flag} ${SH} "${SRCDIR}/${tc}" } add_testcase() { local tc=${1} - local tc_escaped word + local tc_escaped - case "${tc%.*}" in - *-*) - local IFS="-" - for word in ${tc%.*}; do - tc_escaped="${tc_escaped:+${tc_escaped}_}${word}" - done - ;; - *) - tc_escaped=${tc%.*} - ;; - esac + oldIFS=$IFS + IFS='.' + set -- $tc + tc_script=${1} + [ $# -eq 3 ] && xo_fmt=${2} # Don't set xo_fmt to `out' + IFS=$oldIFS + tc_escaped="${tc_script}${xo_fmt:+__${xo_fmt}}" atf_test_case ${tc_escaped} - eval "${tc_escaped}_body() { check ${tc}; }" + eval "${tc_escaped}_body() { check ${tc_script} ${xo_fmt}; }" atf_add_test_case ${tc_escaped} } atf_init_test_cases() { - for path in $(find -Es "${SRCDIR}" -regex '.*\.[0-9]+$'); do + for path in $(find -Es "${SRCDIR}" -name '*.out'); do add_testcase ${path##*/} done } Modified: head/usr.bin/xo/Makefile ============================================================================== --- head/usr.bin/xo/Makefile Tue Oct 6 16:35:50 2015 (r288928) +++ head/usr.bin/xo/Makefile Tue Oct 6 16:58:47 2015 (r288929) @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + LIBXOSRC= ${SRCTOP}/contrib/libxo .PATH: ${LIBXOSRC}/xo @@ -12,4 +14,8 @@ CFLAGS+=-I${LIBXOSRC}/libxo LIBADD= xo util +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include Added: head/usr.bin/xo/tests/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/xo/tests/Makefile Tue Oct 6 16:58:47 2015 (r288929) @@ -0,0 +1,40 @@ +# $FreeBSD$ + +.include + +LIBXOSRC= ${SRCTOP}/contrib/libxo + +.PATH: ${LIBXOSRC}/tests/xo ${LIBXOSRC}/tests/xo/saved + +.c.out .o.out: + +TESTSDIR= ${TESTSBASE}/usr.bin/xo + +BINDIR= ${TESTSDIR} + +ATF_TESTS_SH+= functional_test + +FILES+= xo_01.H.err +FILES+= xo_01.H.out +FILES+= xo_01.HIPx.err +FILES+= xo_01.HIPx.out +FILES+= xo_01.HP.err +FILES+= xo_01.HP.out +FILES+= xo_01.J.err +FILES+= xo_01.J.out +FILES+= xo_01.JP.err +FILES+= xo_01.JP.out +FILES+= xo_01.T.err +FILES+= xo_01.T.out +FILES+= xo_01.X.err +FILES+= xo_01.X.out +FILES+= xo_01.XP.err +FILES+= xo_01.XP.out + +SCRIPTS+= xo_01 + +LIBADD+= xo + +.include + +.SUFFIXES: .sh Copied and modified: head/usr.bin/xo/tests/functional_test.sh (from r288904, head/bin/sh/tests/functional_test.sh) ============================================================================== --- head/bin/sh/tests/functional_test.sh Mon Oct 5 21:41:55 2015 (r288904, copy source) +++ head/usr.bin/xo/tests/functional_test.sh Tue Oct 6 16:58:47 2015 (r288929) @@ -1,5 +1,5 @@ # -# Copyright 2014 EMC Corp. +# Copyright 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -31,42 +31,42 @@ SRCDIR=$(atf_get_srcdir) check() { local tc=${1}; shift + local xo_fmt=${1}; shift - export SH=$(atf_config_get bin.sh.test_shell /bin/sh) + XO=$(atf_config_get usr.bin.xo.test_xo /usr/bin/xo) - local err_file="${SRCDIR}/${tc}.stderr" - [ -f "${err_file}" ] && err_flag="-e file:${err_file}" - local out_file="${SRCDIR}/${tc}.stdout" - [ -f "${out_file}" ] && out_flag="-o file:${out_file}" - - atf_check -s exit:${tc##*.} ${err_flag} ${out_flag} ${SH} "${SRCDIR}/${tc}" + local err_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.err" + [ -s "${err_file}" ] && err_flag="-e file:${err_file}" + local out_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.out" + [ -s "${out_file}" ] && out_flag="-o file:${out_file}" + + atf_check -s exit:0 -e file:${err_file} -o file:${out_file} \ + env LC_ALL=en_US.UTF-8 \ + LIBXO_OPTIONS=":W${xo_fmt}" TZ="EST" "${SRCDIR}/${tc}" \ + ${XO} } add_testcase() { local tc=${1} - local tc_escaped word + local tc_escaped - case "${tc%.*}" in - *-*) - local IFS="-" - for word in ${tc%.*}; do - tc_escaped="${tc_escaped:+${tc_escaped}_}${word}" - done - ;; - *) - tc_escaped=${tc%.*} - ;; - esac + oldIFS=$IFS + IFS='.' + set -- $tc + tc_script=${1} + [ $# -eq 3 ] && xo_fmt=${2} # Don't set xo_fmt to `out' + IFS=$oldIFS + tc_escaped="${tc_script}${xo_fmt:+__${xo_fmt}}" atf_test_case ${tc_escaped} - eval "${tc_escaped}_body() { check ${tc}; }" + eval "${tc_escaped}_body() { check ${tc_script} ${xo_fmt}; }" atf_add_test_case ${tc_escaped} } atf_init_test_cases() { - for path in $(find -Es "${SRCDIR}" -regex '.*\.[0-9]+$'); do + for path in $(find -Es "${SRCDIR}" -name '*.out'); do add_testcase ${path##*/} done }