1240116Smarcel# Copyright (c) 2007 The NetBSD Foundation, Inc. 2240116Smarcel# All rights reserved. 3240116Smarcel# 4240116Smarcel# Redistribution and use in source and binary forms, with or without 5240116Smarcel# modification, are permitted provided that the following conditions 6240116Smarcel# are met: 7240116Smarcel# 1. Redistributions of source code must retain the above copyright 8240116Smarcel# notice, this list of conditions and the following disclaimer. 9240116Smarcel# 2. Redistributions in binary form must reproduce the above copyright 10240116Smarcel# notice, this list of conditions and the following disclaimer in the 11240116Smarcel# documentation and/or other materials provided with the distribution. 12240116Smarcel# 13240116Smarcel# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 14240116Smarcel# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 15240116Smarcel# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16240116Smarcel# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17240116Smarcel# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 18240116Smarcel# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19240116Smarcel# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 20240116Smarcel# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21240116Smarcel# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22240116Smarcel# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23240116Smarcel# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 24240116Smarcel# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25240116Smarcel 26275988Sngieatf_test_case runtime_warnings 27275988Sngieruntime_warnings_head() 28240116Smarcel{ 29240116Smarcel # The fact that this test case is in this test program is an abuse. 30240116Smarcel atf_set "descr" "Tests that the test case prints a warning because" \ 31275988Sngie "it is being run outside of a runtime engine" 32240116Smarcel} 33275988Sngieruntime_warnings_body() 34240116Smarcel{ 35240116Smarcel unset __RUNNING_INSIDE_ATF_RUN 36240116Smarcel srcdir="$(atf_get_srcdir)" 37240116Smarcel for h in $(get_helpers); do 38275988Sngie atf_check -s eq:0 -o match:"passed" -e match:"WARNING.*kyua" \ 39240116Smarcel "${h}" -s "${srcdir}" result_pass 40240116Smarcel done 41240116Smarcel} 42240116Smarcel 43240116Smarcelatf_test_case result_on_stdout 44240116Smarcelresult_on_stdout_head() 45240116Smarcel{ 46240116Smarcel atf_set "descr" "Tests that the test case result is printed on stdout" \ 47240116Smarcel "by default" 48240116Smarcel} 49240116Smarcelresult_on_stdout_body() 50240116Smarcel{ 51240116Smarcel srcdir="$(atf_get_srcdir)" 52240116Smarcel for h in $(get_helpers); do 53240116Smarcel atf_check -s eq:0 -o match:"passed" -o match:"msg" \ 54240116Smarcel -e ignore "${h}" -s "${srcdir}" result_pass 55240116Smarcel atf_check -s eq:1 -o match:"failed: Failure reason" -o match:"msg" \ 56240116Smarcel -e ignore "${h}" -s "${srcdir}" result_fail 57240116Smarcel atf_check -s eq:0 -o match:"skipped: Skipped reason" -o match:"msg" \ 58240116Smarcel -e ignore "${h}" -s "${srcdir}" result_skip 59240116Smarcel done 60240116Smarcel} 61240116Smarcel 62240116Smarcelatf_test_case result_to_file 63240116Smarcelresult_to_file_head() 64240116Smarcel{ 65240116Smarcel atf_set "descr" "Tests that the test case result is sent to a file if -r" \ 66240116Smarcel "is used" 67240116Smarcel} 68240116Smarcelresult_to_file_body() 69240116Smarcel{ 70240116Smarcel srcdir="$(atf_get_srcdir)" 71240116Smarcel for h in $(get_helpers); do 72240116Smarcel atf_check -s eq:0 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \ 73240116Smarcel -r resfile result_pass 74240116Smarcel atf_check -o inline:"passed\n" cat resfile 75240116Smarcel 76240116Smarcel atf_check -s eq:1 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \ 77240116Smarcel -r resfile result_fail 78240116Smarcel atf_check -o inline:"failed: Failure reason\n" cat resfile 79240116Smarcel 80240116Smarcel atf_check -s eq:0 -o inline:"msg\n" -e ignore "${h}" -s "${srcdir}" \ 81240116Smarcel -r resfile result_skip 82240116Smarcel atf_check -o inline:"skipped: Skipped reason\n" cat resfile 83240116Smarcel done 84240116Smarcel} 85240116Smarcel 86240116Smarcelatf_test_case result_to_file_fail 87240116Smarcelresult_to_file_fail_head() 88240116Smarcel{ 89240116Smarcel atf_set "descr" "Tests controlled failure if the test program fails to" \ 90240116Smarcel "create the results file" 91240116Smarcel atf_set "require.user" "unprivileged" 92240116Smarcel} 93240116Smarcelresult_to_file_fail_body() 94240116Smarcel{ 95240116Smarcel mkdir dir 96240116Smarcel chmod 444 dir 97240116Smarcel 98240116Smarcel srcdir="$(atf_get_srcdir)" 99240116Smarcel 100240116Smarcel for h in $(get_helpers c_helpers cpp_helpers); do 101240116Smarcel atf_check -s signal -o ignore \ 102240116Smarcel -e match:"FATAL ERROR: Cannot create.*'dir/resfile'" \ 103240116Smarcel "${h}" -s "${srcdir}" -r dir/resfile result_pass 104240116Smarcel done 105240116Smarcel 106240116Smarcel for h in $(get_helpers sh_helpers); do 107240116Smarcel atf_check -s exit -o ignore \ 108240116Smarcel -e match:"ERROR: Cannot create.*'dir/resfile'" \ 109240116Smarcel "${h}" -s "${srcdir}" -r dir/resfile result_pass 110240116Smarcel done 111240116Smarcel} 112240116Smarcel 113240116Smarcelatf_test_case result_exception 114240116Smarcelresult_exception_head() 115240116Smarcel{ 116240116Smarcel atf_set "descr" "Tests that an unhandled exception is correctly captured" 117240116Smarcel} 118240116Smarcelresult_exception_body() 119240116Smarcel{ 120240116Smarcel for h in $(get_helpers cpp_helpers); do 121275988Sngie atf_check -s signal -o not-match:'failed: .*This is unhandled' \ 122275988Sngie -e ignore "${h}" -s "${srcdir}" result_exception 123240116Smarcel done 124240116Smarcel} 125240116Smarcel 126240116Smarcelatf_init_test_cases() 127240116Smarcel{ 128275988Sngie atf_add_test_case runtime_warnings 129240116Smarcel atf_add_test_case result_on_stdout 130240116Smarcel atf_add_test_case result_to_file 131240116Smarcel atf_add_test_case result_to_file_fail 132240116Smarcel atf_add_test_case result_exception 133240116Smarcel} 134240116Smarcel 135240116Smarcel# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4 136