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 XO=$(atf_config_get usr.bin.xo.test_xo /usr/bin/xo) 364436b51dSEnji Cooper 374436b51dSEnji Cooper local err_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.err" 384436b51dSEnji Cooper [ -s "${err_file}" ] && err_flag="-e file:${err_file}" 394436b51dSEnji Cooper local out_file="${SRCDIR}/${tc}${xo_fmt:+.${xo_fmt}}.out" 404436b51dSEnji Cooper [ -s "${out_file}" ] && out_flag="-o file:${out_file}" 414436b51dSEnji Cooper 424436b51dSEnji Cooper atf_check -s exit:0 -e file:${err_file} -o file:${out_file} \ 434436b51dSEnji Cooper env LC_ALL=en_US.UTF-8 \ 44*13464e4aSEnji Cooper TZ="EST" "${SRCDIR}/${tc}" \ 45*13464e4aSEnji Cooper "${XO} --libxo:W${xo_fmt}" 464436b51dSEnji Cooper} 474436b51dSEnji Cooper 484436b51dSEnji Cooperadd_testcase() 494436b51dSEnji Cooper{ 504436b51dSEnji Cooper local tc=${1} 514436b51dSEnji Cooper local tc_escaped 524436b51dSEnji Cooper 534436b51dSEnji Cooper oldIFS=$IFS 544436b51dSEnji Cooper IFS='.' 554436b51dSEnji Cooper set -- $tc 564436b51dSEnji Cooper tc_script=${1} 574436b51dSEnji Cooper [ $# -eq 3 ] && xo_fmt=${2} # Don't set xo_fmt to `out' 584436b51dSEnji Cooper IFS=$oldIFS 594436b51dSEnji Cooper tc_escaped="${tc_script}${xo_fmt:+__${xo_fmt}}" 604436b51dSEnji Cooper 614436b51dSEnji Cooper atf_test_case ${tc_escaped} 624436b51dSEnji Cooper eval "${tc_escaped}_body() { check ${tc_script} ${xo_fmt}; }" 634436b51dSEnji Cooper atf_add_test_case ${tc_escaped} 644436b51dSEnji Cooper} 654436b51dSEnji Cooper 664436b51dSEnji Cooperatf_init_test_cases() 674436b51dSEnji Cooper{ 684436b51dSEnji Cooper for path in $(find -Es "${SRCDIR}" -name '*.out'); do 694436b51dSEnji Cooper add_testcase ${path##*/} 704436b51dSEnji Cooper done 714436b51dSEnji Cooper} 72