]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/atf/atf-run/share/atf-run.hooks
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / atf / atf-run / share / atf-run.hooks
1 #
2 # Automated Testing Framework (atf)
3 #
4 # Copyright (c) 2007 The NetBSD Foundation, Inc.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 #    notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 #    notice, this list of conditions and the following disclaimer in the
14 #    documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #
29
30 atf_tps_writer_info()
31 {
32     class=${1}; shift
33     echo "info: ${class}, $*"
34 }
35
36 info_start_hook()
37 {
38     default_info_start_hook "${@}"
39 }
40
41 default_info_start_hook()
42 {
43     atf_tps_writer_info "atf.version" $(atf-version | head -n 1)
44
45     atf_tps_writer_info "tests.root" $(pwd)
46
47     atf_tps_writer_info "time.start" $(date)
48
49     atf_tps_writer_info "uname.sysname" $(uname -s)
50     atf_tps_writer_info "uname.nodename" $(uname -n)
51     atf_tps_writer_info "uname.release" $(uname -r)
52     atf_tps_writer_info "uname.version" $(uname -v)
53     atf_tps_writer_info "uname.machine" $(uname -m)
54
55     # Add all the environment variables to the report.  We have to be
56     # careful with those that span over multiple lines; otherwise their
57     # values could be printed as multiple different variables (one per
58     # line), which is incorrect.
59     oldifs="${IFS}"
60     IFS='
61 '
62     set -- $(env)
63     val=${1}; shift
64     while [ ${#} -gt 0 ]; do
65         if echo "${1}" | grep '^[a-zA-Z0-0_][a-zA-Z0-9_]*=' >/dev/null; then
66             atf_tps_writer_info "env" "${val}"
67             val="${1}"
68         else
69             val="${val} ${1}"
70         fi
71         shift
72     done
73     atf_tps_writer_info "env" "${val}"
74     IFS="${oldifs}"
75 }
76
77 info_end_hook()
78 {
79     default_info_end_hook "${@}"
80 }
81
82 default_info_end_hook()
83 {
84     atf_tps_writer_info "time.end" $(date)
85 }
86
87 sitehooks=$(atf-config -t atf_confdir)/atf-run.hooks
88 userhooks=${HOME}/.atf/atf-run.hooks
89 [ -f ${sitehooks} ] && . ${sitehooks}
90 [ -f ${userhooks} ] && . ${userhooks}
91
92 eval ${1}
93
94 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4