11581ec9aSEric van Gyzen#!/usr/libexec/atf-sh 21581ec9aSEric van Gyzen# 31581ec9aSEric van Gyzen# SPDX-License-Identifier: BSD-2-Clause 41581ec9aSEric van Gyzen# 51581ec9aSEric van Gyzen# Copyright (c) 2022 Eric van Gyzen 61581ec9aSEric van Gyzen# 71581ec9aSEric van Gyzen# Redistribution and use in source and binary forms, with or without 81581ec9aSEric van Gyzen# modification, are permitted provided that the following conditions 91581ec9aSEric van Gyzen# are met: 101581ec9aSEric van Gyzen# 1. Redistributions of source code must retain the above copyright 111581ec9aSEric van Gyzen# notice, this list of conditions and the following disclaimer. 121581ec9aSEric van Gyzen# 2. Redistributions in binary form must reproduce the above copyright 131581ec9aSEric van Gyzen# notice, this list of conditions and the following disclaimer in the 141581ec9aSEric van Gyzen# documentation and/or other materials provided with the distribution. 151581ec9aSEric van Gyzen# 161581ec9aSEric van Gyzen# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 171581ec9aSEric van Gyzen# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181581ec9aSEric van Gyzen# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191581ec9aSEric van Gyzen# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 201581ec9aSEric van Gyzen# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211581ec9aSEric van Gyzen# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221581ec9aSEric van Gyzen# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231581ec9aSEric van Gyzen# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241581ec9aSEric van Gyzen# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251581ec9aSEric van Gyzen# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261581ec9aSEric van Gyzen# SUCH DAMAGE. 271581ec9aSEric van Gyzen 281581ec9aSEric van Gyzenatf_test_case contrib_file_tests cleanup 291581ec9aSEric van Gyzencontrib_file_tests_body() { 301581ec9aSEric van Gyzen srcdir="$(atf_get_srcdir)" 311581ec9aSEric van Gyzen 321581ec9aSEric van Gyzen for testfile in "${srcdir}"/*.testfile; do 331581ec9aSEric van Gyzen test_name="${testfile%.testfile}" 341581ec9aSEric van Gyzen result_file="${test_name}.result" 351581ec9aSEric van Gyzen magic_file="${test_name}.magic" 361581ec9aSEric van Gyzen file_args= 371581ec9aSEric van Gyzen if [ -e "${magic_file}" ]; then 381581ec9aSEric van Gyzen file_args="${file_args} --magic-file ${magic_file}" 391581ec9aSEric van Gyzen fi 401581ec9aSEric van Gyzen # The result files were created in UTC. 411581ec9aSEric van Gyzen TZ=Z atf_check -o save:actual_output file ${file_args} \ 421581ec9aSEric van Gyzen --brief "$testfile" 43*0d3a8756SJose Luis Duran atf_check cmp actual_output "$result_file" 441581ec9aSEric van Gyzen done 451581ec9aSEric van Gyzen} 461581ec9aSEric van Gyzen 471581ec9aSEric van Gyzencontrib_file_tests_cleanup() { 481581ec9aSEric van Gyzen rm -f actual_output trimmed_output 491581ec9aSEric van Gyzen} 501581ec9aSEric van Gyzen 511581ec9aSEric van Gyzenatf_init_test_cases() { 521581ec9aSEric van Gyzen atf_add_test_case contrib_file_tests 531581ec9aSEric van Gyzen} 54