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