3 # Copyright (c) 2017 Enji Cooper <ngie@FreeBSD.org>
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
14 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
15 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
18 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 # POSSIBILITY OF SUCH DAMAGE.
32 # This TAP test program mimics the structure and contents of its
33 # ATF-based counterpart. It attempts to represent various test cases
34 # in different separate functions and just calls them all from main.
42 local result=$1; shift
45 result_string="$result $test_num"
47 result_string="$result_string - $@"
50 : $(( test_num += 1 ))
53 # Auxiliary function to compare two files for equality.
55 if cmp -s "${1}" "${2}"; then
58 result "not ok" "${1} and ${2} differ, but they should be equal"
64 cp "$(dirname "${0}")/file1" .
65 if cp file1 file2; then
67 verify_copy file1 file2
69 result "not ok" "cp failed"
70 result "not ok" "# SKIP"
77 if cp -f file1 file3; then
79 verify_copy file1 file3
81 result "not ok" "cp -f failed"
82 result "not ok" "# SKIP"
86 # If you have read the cp_test.sh counterpart in the atf/ directory, you
87 # may think that the sequencing of tests below and the exposed behavior
88 # to the user is very similar. But you'd be wrong.
90 # There are two major differences with this and the ATF version. First off,
91 # the TAP test doesn't isolate simple_test from force_test, whereas the ATF
92 # version does. Secondly, the test script accepts arbitrary command line