1 # Copyright 2011 Google Inc.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * 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 # * Neither the name of Google Inc. nor the names of its contributors
14 # may be used to endorse or promote products derived from this software
15 # without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 # Subcommand to strip the timestamps of a report.
32 # This is to make the reports deterministic and thus easily testable. The
33 # timestamps are replaced by the fixed string S.UUUs.
35 # This variable should be used as shown here:
37 # atf_check ... -x kyua report "| ${uilts_strip_timestamp}"
38 utils_strip_timestamp
='sed -e "s,[0-9][0-9]*.[0-9][0-9][0-9]s,S.UUUs,g"'
41 # Copies a helper binary from the source directory to the work directory.
43 # \param name The name of the binary to copy.
44 # \param destination The target location for the binary; can be either
45 # a directory name or a file name.
47 local name
="${1}"; shift
48 local destination
="${1}"; shift
50 ln -s "$(atf_get_srcdir)"/helpers
/"${name}" "${destination}"
54 # Creates a 'kyua' binary in the path that strips timestamps off the output.
56 # Call this on test cases that wish to replace timestamps in the *stdout* of
57 # Kyua with the S.UUUs deterministic string. This is usable for tests that
58 # validate the 'test' subcommand, but also by a few specific tests for the
59 # 'report' subcommand.
60 utils_install_timestamp_wrapper
() {
61 [ ! -x kyua
] ||
return
67 kyua "\${@}" >kyua.tmpout
69 cat kyua.tmpout | ${utils_strip_timestamp}
77 # Defines a test case with a default head.
79 local name
="${1}"; shift
81 atf_test_case
"${name}"
82 eval "${name}_head() {
83 atf_set require.progs kyua