14436b51dSEnji Cooper# 24436b51dSEnji Cooper# Copyright 2015 EMC Corp. 34436b51dSEnji Cooper# All rights reserved. 44436b51dSEnji Cooper# 54436b51dSEnji Cooper# Redistribution and use in source and binary forms, with or without 64436b51dSEnji Cooper# modification, are permitted provided that the following conditions are 74436b51dSEnji Cooper# met: 84436b51dSEnji Cooper# 94436b51dSEnji Cooper# * Redistributions of source code must retain the above copyright 104436b51dSEnji Cooper# notice, this list of conditions and the following disclaimer. 114436b51dSEnji Cooper# * Redistributions in binary form must reproduce the above copyright 124436b51dSEnji Cooper# notice, this list of conditions and the following disclaimer in the 134436b51dSEnji Cooper# documentation and/or other materials provided with the distribution. 144436b51dSEnji Cooper# 154436b51dSEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 164436b51dSEnji Cooper# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 174436b51dSEnji Cooper# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 184436b51dSEnji Cooper# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 194436b51dSEnji Cooper# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 204436b51dSEnji Cooper# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 214436b51dSEnji Cooper# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 224436b51dSEnji Cooper# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 234436b51dSEnji Cooper# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 244436b51dSEnji Cooper# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 254436b51dSEnji Cooper# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 264436b51dSEnji Cooper# 274436b51dSEnji Cooper 284436b51dSEnji CooperSRCDIR=$(atf_get_srcdir) 294436b51dSEnji Cooper 304436b51dSEnji Coopercheck() 314436b51dSEnji Cooper{ 324436b51dSEnji Cooper local tc=${1}; shift 334436b51dSEnji Cooper local xo_fmt=${1}; shift 344436b51dSEnji Cooper 354436b51dSEnji Cooper local err_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.err" 364436b51dSEnji Cooper [ -s "${err_file}" ] && err_flag="-e file:${err_file}" 374436b51dSEnji Cooper local out_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.out" 384436b51dSEnji Cooper [ -s "${out_file}" ] && out_flag="-o file:${out_file}" 394436b51dSEnji Cooper 404436b51dSEnji Cooper if [ "$xo_fmt" = "E" ]; then 41*20a21f67SPhil Shafer libxo_options=" warn,encoder=test" 424436b51dSEnji Cooper else 43*20a21f67SPhil Shafer libxo_options=":W${xo_fmt}" 444436b51dSEnji Cooper fi 454436b51dSEnji Cooper 464436b51dSEnji Cooper atf_check -s exit:0 -e file:${err_file} -o file:${out_file} \ 474436b51dSEnji Cooper env LC_ALL=en_US.UTF-8 \ 48*20a21f67SPhil Shafer TZ="EST" "${SRCDIR}/${tc}" --libxo${libxo_options}\ 494436b51dSEnji Cooper 504436b51dSEnji Cooper} 514436b51dSEnji Cooper 524436b51dSEnji Cooperadd_testcase() 534436b51dSEnji Cooper{ 544436b51dSEnji Cooper local tc=${1} 554436b51dSEnji Cooper local tc_escaped 564436b51dSEnji Cooper 574436b51dSEnji Cooper oldIFS=$IFS 584436b51dSEnji Cooper IFS='.' 594436b51dSEnji Cooper set -- $tc 604436b51dSEnji Cooper tc_script=${1} 614436b51dSEnji Cooper [ $# -eq 3 ] && xo_fmt=${2} # Don't set xo_fmt to `out' 624436b51dSEnji Cooper IFS=$oldIFS 634436b51dSEnji Cooper tc_escaped="${tc_script}${xo_fmt:+__${xo_fmt}}" 644436b51dSEnji Cooper 654436b51dSEnji Cooper atf_test_case ${tc_escaped} 664436b51dSEnji Cooper eval "${tc_escaped}_body() { check ${tc_script} ${xo_fmt}; }" 674436b51dSEnji Cooper atf_add_test_case ${tc_escaped} 684436b51dSEnji Cooper} 694436b51dSEnji Cooper 704436b51dSEnji Cooperatf_init_test_cases() 714436b51dSEnji Cooper{ 724436b51dSEnji Cooper for path in $(find -Es "${SRCDIR}" -name '*.out'); do 734436b51dSEnji Cooper add_testcase ${path##*/} 744436b51dSEnji Cooper done 754436b51dSEnji Cooper} 76