1# $NetBSD: t_audio.awk,v 1.2 2020/03/25 13:07:04 isaki Exp $ 2# 3# Copyright (C) 2019 Tetsuya Isaki. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 19# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 21# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26 27BEGIN { 28 n = 0 29 print "#" 30 print "# This file is regenerated by t_audio.awk" 31 print "#" 32 print "" 33 print "# Call real test program, and then dispatch the result for atf." 34 print "h_audio() {" 35 print " local testname=$1" 36 print " local outfile=/tmp/t_audio_$testname.$$" 37 print " $(atf_get_srcdir)/audiotest -ARe $testname > $outfile" 38 print " local retval=$?" 39 print " # Discard rump outputs..." 40 print " outmsg=`cat $outfile | grep -v '^\\['`" 41 print " rm -f $outfile" 42 print " if [ \"$retval\" = \"0\" ]; then" 43 print " atf_pass" 44 print " elif [ \"$retval\" = \"1\" ]; then" 45 print " atf_fail \"$outmsg\"" 46 print " elif [ \"$retval\" = \"2\" ]; then" 47 print " atf_skip \"$outmsg\"" 48 print " else" 49 print " atf_fail \"unknown error $retval\"" 50 print " fi" 51 print "}" 52 print "" 53} 54# Gather only tab-indented ENT(). I.e., 55# ^\tENT(testname) ... Enable in audiotest and add it to atf 56# ^//\tENT(testname) ... Disable in audiotest and also don't add to atf 57# ^/**/\tENT(testname) ... Enable in audiotest but don't add to atf 58match($0, /^\tENT\([^\)]*\)/) { 59 name = substr($0, RSTART + 5, RLENGTH - 6) 60 tests[n] = name 61 n++; 62 63 print "atf_test_case " name 64 print name "_head() { }" 65 print name "_body() {" 66 print "\th_audio " name 67 print "}" 68 print "" 69} 70END { 71 print "atf_init_test_cases() {" 72 for (i = 0; i < length(tests); i++) { 73 print "\tatf_add_test_case " tests[i] 74 } 75 print "}" 76} 77