2 # Automated Testing Framework (atf)
4 # Copyright (c) 2007 The NetBSD Foundation, Inc.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
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.
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.
32 ATF_CONFDIR
="$(pwd)"; export ATF_CONFDIR
35 Content-Type: application/X-atf-atffile; version="1"
37 prop: test-suite = atf
41 echo "tp: ${f}" >>Atffile
47 cp $
(atf_get_srcdir
)/misc_helpers helper
49 TESTCASE
=${1}; export TESTCASE
54 # TODO: This really, really, really must use real test programs.
56 #! $(atf-config -t atf_shell)
57 while [ \${#} -gt 0 ]; do
60 echo 'Content-Type: application/X-atf-tp; version="1"'
64 while [ ${cnt} -le ${2} ]; do
65 echo "echo 'ident: tc${cnt}'" >>${1}
66 [ ${cnt} -lt ${2} ] && echo "echo" >>${1}
73 resfile=\$(echo \${1} | cut -d r -f 2-)
76 testcase=\$(echo \${1} | cut -d : -f 1)
86 #! /usr/bin/env atf-sh
92 mount -t tmpfs tmpfs \${1} || atf_fail "Mount failed"
95 mdmfs -s 16m md \${1} || atf_fail "Mount failed"
98 mount -F tmpfs tmpfs \$(pwd)/\${1} || atf_fail "Mount failed"
101 atf_fail "create_mount_helper called for an unsupported platform."
108 atf_set "require.user" "root"
116 atf_init_test_cases()
118 atf_add_test_case main
123 atf_test_case no_warnings
126 atf_set
"descr" "Tests that atf-run suppresses warnings about not running" \
132 atf_check
-s eq
:0 -o ignore
-e not-match
:'WARNING.*atf-run' atf-run helper
138 atf_set
"descr" "Tests that the config files are read in the correct" \
148 echo "First: read system-wide common.conf."
149 cat >etc
/common.conf
<<EOF
150 Content-Type: application/X-atf-config; version="1"
158 -o match
:'1st: sw common' \
159 -o match
:'2nd: sw common' \
160 -o match
:'3rd: sw common' \
161 -o match
:'4th: sw common' \
163 "ATF_CONFDIR=$(pwd)/etc HOME=$(pwd) atf-run helper"
165 echo "Second: read system-wide <test-suite>.conf."
166 cat >etc
/atf.conf
<<EOF
167 Content-Type: application/X-atf-config; version="1"
172 -o match
:'1st: sw atf' \
173 -o match
:'2nd: sw common' \
174 -o match
:'3rd: sw common' \
175 -o match
:'4th: sw common' \
177 "ATF_CONFDIR=$(pwd)/etc HOME=$(pwd) atf-run helper"
179 echo "Third: read user-specific common.conf."
180 cat >.
atf
/common.conf
<<EOF
181 Content-Type: application/X-atf-config; version="1"
186 -o match
:'1st: sw atf' \
187 -o match
:'2nd: us common' \
188 -o match
:'3rd: sw common' \
189 -o match
:'4th: sw common' \
191 "ATF_CONFDIR=$(pwd)/etc HOME=$(pwd) atf-run helper"
193 echo "Fourth: read user-specific <test-suite>.conf."
194 cat >.
atf
/atf.conf
<<EOF
195 Content-Type: application/X-atf-config; version="1"
200 -o match
:'1st: sw atf' \
201 -o match
:'2nd: us common' \
202 -o match
:'3rd: us atf' \
203 -o match
:'4th: sw common' \
205 "ATF_CONFDIR=$(pwd)/etc HOME=$(pwd) atf-run helper"
211 atf_set
"descr" "Tests that the -v flag works and that it properly" \
212 "overrides the values in configuration files"
216 create_helper testvar
218 echo "Checking that 'testvar' is not defined."
219 atf_check
-s eq
:1 -o ignore
-e ignore
-x \
220 "ATF_CONFDIR=$(pwd)/etc atf-run helper"
222 echo "Checking that defining 'testvar' trough '-v' works."
223 atf_check
-s eq
:0 -o match
:'testvar: a value' -e ignore
-x \
224 "ATF_CONFDIR=$(pwd)/etc atf-run -v testvar='a value' helper"
226 echo "Checking that defining 'testvar' trough the configuration" \
229 cat >etc
/common.conf
<<EOF
230 Content-Type: application/X-atf-config; version="1"
232 testvar = "value in conf file"
234 atf_check
-s eq
:0 -o match
:'testvar: value in conf file' -e ignore
-x \
235 "ATF_CONFDIR=$(pwd)/etc atf-run helper"
237 echo "Checking that defining 'testvar' trough -v overrides the" \
238 "configuration file."
239 atf_check
-s eq
:0 -o match
:'testvar: a value' -e ignore
-x \
240 "ATF_CONFDIR=$(pwd)/etc atf-run -v testvar='a value' helper"
243 atf_test_case atffile
246 atf_set
"descr" "Tests that the variables defined by the Atffile" \
247 "are recognized and that they take the lowest priority"
251 create_helper testvar
253 echo "Checking that 'testvar' is not defined."
254 atf_check
-s eq
:1 -o ignore
-e ignore
-x \
255 "ATF_CONFDIR=$(pwd)/etc atf-run helper"
257 echo "Checking that defining 'testvar' trough the Atffile works."
258 echo 'conf: testvar = "a value"' >>Atffile
259 atf_check
-s eq
:0 -o match
:'testvar: a value' -e ignore
-x \
260 "ATF_CONFDIR=$(pwd)/etc atf-run helper"
262 echo "Checking that defining 'testvar' trough the configuration" \
263 "file overrides the one in the Atffile."
265 cat >etc
/common.conf
<<EOF
266 Content-Type: application/X-atf-config; version="1"
268 testvar = "value in conf file"
270 atf_check
-s eq
:0 -o match
:'testvar: value in conf file' -e ignore
-x \
271 "ATF_CONFDIR=$(pwd)/etc atf-run helper"
274 echo "Checking that defining 'testvar' trough -v overrides the" \
275 "one in the Atffile."
276 atf_check
-s eq
:0 -o match
:'testvar: new value' -e ignore
-x \
277 "ATF_CONFDIR=$(pwd)/etc atf-run -v testvar='new value' helper"
280 atf_test_case atffile_recursive
281 atffile_recursive_head
()
283 atf_set
"descr" "Tests that variables defined by an Atffile are not" \
284 "inherited by other Atffiles."
286 atffile_recursive_body
()
288 create_helper testvar
291 mv Atffile helper dir
293 echo "Checking that 'testvar' is not inherited."
295 echo 'conf: testvar = "a value"' >> Atffile
296 atf_check
-s eq
:1 -o ignore
-e ignore
-x "ATF_CONFDIR=$(pwd)/etc atf-run"
298 echo "Checking that defining 'testvar' in the correct Atffile works."
299 echo 'conf: testvar = "a value"' >>dir
/Atffile
300 atf_check
-s eq
:0 -o match
:'testvar: a value' -e ignore
-x \
301 "ATF_CONFDIR=$(pwd)/etc atf-run"
307 atf_set
"descr" "Tests that all streams are properly captured"
314 -o match
:'^tc-so:msg1 to stdout$' \
315 -o match
:'^tc-so:msg2 to stdout$' \
316 -o match
:'^tc-se:msg1 to stderr$' \
317 -o match
:'^tc-se:msg2 to stderr$' \
321 atf_test_case mux_streams
324 atf_set
"descr" "Tests for a race condition in stream multiplexing"
328 create_helper mux_streams
330 for i
in 1 2 3 4 5; do
332 atf_check
-s eq
:0 -o match
:'stdout 9999' -o match
:'stderr 9999' atf-run
339 atf_set
"descr" "Tests the processing of test case results and the" \
344 ln -s "$(atf_get_srcdir)/expect_helpers" .
345 create_atffile expect_helpers
348 -o match
:'death_and_exit, expected_death' \
349 -o match
:'death_and_signal, expected_death' \
350 -o match
:'death_but_pass, failed' \
351 -o match
:'exit_any_and_exit, expected_exit' \
352 -o match
:'exit_but_pass, failed' \
353 -o match
:'exit_code_and_exit, expected_exit' \
354 -o match
:'fail_and_fail_check, expected_failure' \
355 -o match
:'fail_and_fail_requirement, expected_failure' \
356 -o match
:'fail_but_pass, failed' \
357 -o match
:'pass_and_pass, passed' \
358 -o match
:'pass_but_fail_check, failed' \
359 -o match
:'pass_but_fail_requirement, failed' \
360 -o match
:'signal_any_and_signal, expected_signal' \
361 -o match
:'signal_but_pass, failed' \
362 -o match
:'signal_no_and_signal, expected_signal' \
363 -o match
:'timeout_and_hang, expected_timeout' \
364 -o match
:'timeout_but_pass, failed' \
368 atf_test_case missing_results
369 missing_results_head
()
371 atf_set
"descr" "Ensures that atf-run correctly handles test cases that " \
372 "do not create the results file"
374 missing_results_body
()
376 create_helper_stdin helper
1 <<EOF
377 test -f \${resfile} && echo "resfile found"
382 create_atffile helper
384 re
='^tc-end: [0-9][0-9]*\.[0-9]*, tc1,'
386 -o match
:"${re} failed,.*failed to create" \
387 -o not-match
:'resfile found' \
391 atf_test_case broken_results
392 broken_results_head
()
394 atf_set
"descr" "Ensures that atf-run reports test programs that" \
395 "provide a bogus results output as broken programs"
397 broken_results_body
()
399 # We produce two errors from the header to ensure that the parse
400 # errors are printed on a single line on the output file. Printing
401 # them on separate lines would be incorrect.
402 create_helper_stdin helper
1 <<EOF
403 echo 'line 1' >\${resfile}
404 echo 'line 2' >>\${resfile}
409 create_atffile helper
411 re
='^tc-end: [0-9][0-9]*\.[0-9]*, tc1,'
412 atf_check
-s eq
:1 -o match
:"${re} .*line 1.*line 2" -e empty atf-run
415 atf_test_case broken_tp_list
416 broken_tp_list_head
()
418 atf_set
"descr" "Ensures that atf-run reports test programs that" \
419 "provide a bogus test case list"
421 broken_tp_list_body
()
424 #! $(atf-config -t atf_shell)
425 while [ \${#} -gt 0 ]; do
426 if [ \${1} = -l ]; then
427 echo 'Content-Type: application/X-atf-tp; version="1"'
439 create_atffile helper
441 re
='^tp-end: [0-9][0-9]*\.[0-9]*, helper,'
442 re
="${re} Invalid format for test case list:.*First property.*ident"
443 atf_check
-s eq
:1 -o match
:"${re}" -e empty atf-run
446 atf_test_case zero_tcs
449 atf_set
"descr" "Ensures that atf-run reports test programs without" \
450 "test cases as errors"
454 create_helper_stdin helper
0 <<EOF
455 echo 'Content-Type: application/X-atf-tp; version="1"'
461 create_atffile helper
463 re
='^tp-end: [0-9][0-9]*\.[0-9]*, helper,'
465 -o match
:"${re} .*Invalid format for test case list" \
469 atf_test_case exit_codes
472 atf_set
"descr" "Ensures that atf-run reports bogus exit codes for" \
477 create_helper_stdin helper
1 <<EOF
478 echo "failed: Yes, it failed" >\${resfile}
483 create_atffile helper
485 re
='^tc-end: [0-9][0-9]*\.[0-9]*, tc1,'
487 -o match
:"${re} .*exited successfully.*reported failure" \
491 atf_test_case signaled
494 atf_set
"descr" "Ensures that atf-run reports test program's crashes" \
495 "correctly regardless of their actual results"
499 create_helper_stdin helper
2 <<EOF
500 echo "passed" >\${resfile}
503 tc2) echo "Killing myself!" ; kill -9 \$\$ ;;
508 create_atffile helper
510 re
='^tc-end: [0-9][0-9]*\.[0-9]*, tc2,'
511 atf_check
-s eq
:1 -o match
:"${re} .*received signal 9" \
518 atf_set
"descr" "Checks that the default hooks work and that they" \
519 "can be overriden by the user"
523 cp $
(atf_get_srcdir
)/pass_helper helper
524 create_atffile helper
529 echo "Checking default hooks"
530 atf_check
-s eq
:0 -o match
:'^info: time.start, ' \
531 -o match
:'^info: time.end, ' -e empty
-x \
532 "ATF_CONFDIR=$(pwd)/atf atf-run"
534 echo "Checking the system-wide info_start hook"
535 cat >atf
/atf-run.hooks
<<EOF
538 atf_tps_writer_info "test" "sw value"
542 -o match
:'^info: test, sw value' \
543 -o not-match
:'^info: time.start, ' \
544 -o match
:'^info: time.end, ' \
546 "ATF_CONFDIR=$(pwd)/atf atf-run"
548 echo "Checking the user-specific info_start hook"
549 cat >.
atf
/atf-run.hooks
<<EOF
552 atf_tps_writer_info "test" "user value"
556 -o match
:'^info: test, user value' \
557 -o not-match
:'^info: time.start, ' \
558 -o match
:'^info: time.end, ' \
560 "ATF_CONFDIR=$(pwd)/atf atf-run"
563 rm .
atf
/atf-run.hooks
565 echo "Checking the system-wide info_end hook"
566 cat >atf
/atf-run.hooks
<<EOF
569 atf_tps_writer_info "test" "sw value"
573 -o match
:'^info: time.start, ' \
574 -o not-match
:'^info: time.end, ' \
575 -o match
:'^info: test, sw value' \
577 "ATF_CONFDIR=$(pwd)/atf atf-run"
579 echo "Checking the user-specific info_end hook"
580 cat >.
atf
/atf-run.hooks
<<EOF
583 atf_tps_writer_info "test" "user value"
587 -o match
:'^info: time.start, ' \
588 -o not-match
:'^info: time.end, ' \
589 -o match
:'^info: test, user value' \
591 "ATF_CONFDIR=$(pwd)/atf atf-run"
594 atf_test_case isolation_env
597 atf_set
"descr" "Tests that atf-run sets a set of environment variables" \
598 "to known sane values"
602 undef_vars
="LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY \
607 for v
in ${undef_vars} ${def_vars}; do
608 mangleenv
="${mangleenv} ${v}=bogus-value"
611 create_helper env_list
612 create_atffile helper
614 # We must ignore stderr in this call (instead of specifying -e empty)
615 # because, when atf-run invokes the shell to run the hooks, we may get
616 # error messages about an invalid locale. This happens, at least, when
617 # the shell is bash 4.x.
618 atf_check
-s eq
:0 -o save
:stdout
-e ignore
${mangleenv} atf-run helper
620 for v
in ${undef_vars}; do
621 atf_check
-s eq
:1 -o empty
-e empty
grep "^tc-so:${v}=" stdout
624 for v
in ${def_vars}; do
625 atf_check
-s eq
:0 -o ignore
-e empty
grep "^tc-so:${v}=" stdout
628 atf_check
-s eq
:0 -o ignore
-e empty
grep "^tc-so:TZ=UTC" stdout
631 atf_test_case isolation_home
632 isolation_home_head
()
634 atf_set
"descr" "Tests that atf-run sets HOME to a sane and valid value"
636 isolation_home_body
()
638 create_helper env_home
639 create_atffile helper
640 atf_check
-s eq
:0 -o ignore
-e ignore env HOME
=foo atf-run helper
643 atf_test_case isolation_stdin
644 isolation_stdin_head
()
646 atf_set
"descr" "Tests that atf-run nullifies the stdin of test cases"
648 isolation_stdin_body
()
650 create_helper read_stdin
651 create_atffile helper
652 atf_check
-s eq
:0 -o ignore
-e ignore
-x 'echo hello world | atf-run helper'
655 atf_test_case isolation_umask
656 isolation_umask_head
()
658 atf_set
"descr" "Tests that atf-run sets the umask to a known value"
660 isolation_umask_body
()
663 create_atffile helper
665 atf_check
-s eq
:0 -o match
:'umask: 0022' -e ignore
-x \
666 "umask 0000 && atf-run helper"
669 atf_test_case cleanup_pass
672 atf_set
"descr" "Tests that atf-run calls the cleanup routine of the test" \
673 "case when the test case result is passed"
677 create_helper cleanup_states
678 create_atffile helper
680 atf_check
-s eq
:0 -o match
:'cleanup_states, passed' -e ignore atf-run \
681 -v state
=pass
-v statedir
=$
(pwd) helper
682 test -f to-stay || atf_fail
"Test case body did not run correctly"
683 if [ -f to-delete
]; then
684 atf_fail
"Test case cleanup did not run correctly"
688 atf_test_case cleanup_fail
691 atf_set
"descr" "Tests that atf-run calls the cleanup routine of the test" \
692 "case when the test case result is failed"
696 create_helper cleanup_states
697 create_atffile helper
699 atf_check
-s eq
:1 -o match
:'cleanup_states, failed' -e ignore atf-run \
700 -v state
=fail
-v statedir
=$
(pwd) helper
701 test -f to-stay || atf_fail
"Test case body did not run correctly"
702 if [ -f to-delete
]; then
703 atf_fail
"Test case cleanup did not run correctly"
707 atf_test_case cleanup_skip
710 atf_set
"descr" "Tests that atf-run calls the cleanup routine of the test" \
711 "case when the test case result is skipped"
715 create_helper cleanup_states
716 create_atffile helper
718 atf_check
-s eq
:0 -o match
:'cleanup_states, skipped' -e ignore atf-run \
719 -v state
=skip
-v statedir
=$
(pwd) helper
720 test -f to-stay || atf_fail
"Test case body did not run correctly"
721 if [ -f to-delete
]; then
722 atf_fail
"Test case cleanup did not run correctly"
726 atf_test_case cleanup_curdir
727 cleanup_curdir_head
()
729 atf_set
"descr" "Tests that atf-run calls the cleanup routine in the same" \
730 "work directory as the body so that they can share data"
732 cleanup_curdir_body
()
734 create_helper cleanup_curdir
735 create_atffile helper
737 atf_check
-s eq
:0 -o match
:'cleanup_curdir, passed' \
738 -o match
:'Old value: 1234' -e ignore atf-run helper
741 atf_test_case cleanup_signal
742 cleanup_signal_head
()
744 atf_set
"descr" "Tests that atf-run calls the cleanup routine if it gets" \
745 "a termination signal while running the body"
747 cleanup_signal_body
()
749 : # TODO: Write this.
752 atf_test_case cleanup_mount
755 atf_set
"descr" "Tests that the removal algorithm does not cross" \
757 atf_set
"require.user" "root"
761 ROOT
="$(pwd)/root"; export ROOT
763 create_mount_helper helper
<<EOF
764 echo \$(pwd) >\${ROOT}
772 mkdir foo/baz/foo/bar
773 do_mount foo/baz/foo/bar
775 create_atffile helper
780 Linux|FreeBSD|NetBSD|SunOS
)
783 # XXX Possibly specify in meta-data too.
784 atf_skip
"Test unimplemented in this platform (${platform})"
788 atf_check
-s eq
:0 -o match
:"main, passed" -e ignore atf-run helper
789 mount |
grep $
(cat root
) && atf_fail
"Some file systems remain mounted"
790 atf_check
-s eq
:1 -o empty
-e empty
test -d $
(cat root
)/foo
793 atf_test_case cleanup_symlink
794 cleanup_symlink_head
()
796 atf_set
"descr" "Tests that the removal algorithm does not follow" \
797 "symlinks, which may live in another device and thus" \
798 "be treated as mount points"
799 atf_set
"require.user" "root"
801 cleanup_symlink_body
()
803 ROOT
="$(pwd)/root"; export ROOT
805 create_mount_helper helper
<<EOF
806 echo \$(pwd) >\${ROOT}
807 atf_check -s eq:0 -o empty -e empty mkdir foo
808 atf_check -s eq:0 -o empty -e empty mkdir foo/bar
810 atf_check -s eq:0 -o empty -e empty touch a
811 atf_check -s eq:0 -o empty -e empty ln -s "\$(pwd)/a" foo/bar
813 create_atffile helper
818 Linux|FreeBSD|NetBSD|SunOS
)
821 # XXX Possibly specify in meta-data too.
822 atf_skip
"Test unimplemented in this platform (${platform})"
826 atf_check
-s eq
:0 -o match
:"main, passed" -e ignore atf-run helper
827 mount |
grep $
(cat root
) && atf_fail
"Some file systems remain mounted"
828 atf_check
-s eq
:1 -o empty
-e empty
test -d $
(cat root
)/foo
831 atf_test_case require_arch
834 atf_set
"descr" "Tests that atf-run validates the require.arch property"
838 create_helper require_arch
839 create_atffile helper
841 echo "Checking for the real architecture"
842 arch
=$
(atf-config
-t atf_arch
)
843 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
844 -v arch
="${arch}" helper
845 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
846 -v arch
="foo ${arch}" helper
847 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
848 -v arch
="${arch} foo" helper
850 echo "Checking for a fictitious architecture"
852 export ATF_ARCH
=fictitious
853 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
854 -v arch
="${arch}" helper
855 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
856 -v arch
="foo ${arch}" helper
857 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
858 -v arch
="${arch} foo" helper
860 echo "Triggering some failures"
861 atf_check
-s eq
:0 -o match
:"${TESTCASE}, skipped, .*foo.*architecture" \
862 -e ignore atf-run
-v arch
="foo" helper
864 -o match
:"${TESTCASE}, skipped, .*foo bar.*architectures" -e ignore \
865 atf-run
-v arch
="foo bar" helper
867 -o match
:"${TESTCASE}, skipped, .*fictitiousxxx.*architecture" \
868 -e ignore atf-run
-v arch
="${arch}xxx" helper
871 atf_test_case require_config
872 require_config_head
()
874 atf_set
"descr" "Tests that atf-run validates the require.config property"
876 require_config_body
()
878 create_helper require_config
879 create_atffile helper
881 atf_check
-s eq
:0 -o match
:"${TESTCASE}, skipped, .*var1.*not defined" \
882 -e ignore atf-run helper
883 atf_check
-s eq
:0 -o match
:"${TESTCASE}, skipped, .*var2.*not defined" \
884 -e ignore atf-run
-v var1
=foo helper
885 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
886 -v var1
=a
-v var2
=' ' helper
889 atf_test_case require_files
892 atf_set
"descr" "Tests that atf-run validates the require.files property"
896 create_helper require_files
897 create_atffile helper
901 echo "Checking absolute paths"
902 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
903 -v files
='/bin/cp' helper
904 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
905 -v files
="$(pwd)/i-exist" helper
907 -o match
:"${TESTCASE}, skipped, .*/dont-exist" \
908 -e ignore atf-run
-v files
="$(pwd)/i-exist $(pwd)/dont-exist" helper
910 echo "Checking that relative paths are not allowed"
912 -o match
:"${TESTCASE}, failed, Relative paths.*not allowed.*hello" \
913 -e ignore atf-run
-v files
='hello' helper
915 -o match
:"${TESTCASE}, failed, Relative paths.*not allowed.*a/b" \
916 -e ignore atf-run
-v files
='a/b' helper
919 atf_test_case require_machine
920 require_machine_head
()
922 atf_set
"descr" "Tests that atf-run validates the require.machine property"
924 require_machine_body
()
926 create_helper require_machine
927 create_atffile helper
929 echo "Checking for the real machine type"
930 machine
=$
(atf-config
-t atf_machine
)
931 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
932 -v machine
="${machine}" helper
933 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
934 -v machine
="foo ${machine}" helper
935 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
936 -v machine
="${machine} foo" helper
938 echo "Checking for a fictitious machine type"
940 export ATF_MACHINE
=fictitious
941 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
942 -v machine
="${machine}" helper
943 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
944 -v machine
="foo ${machine}" helper
945 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
946 -v machine
="${machine} foo" helper
948 echo "Triggering some failures"
949 atf_check
-s eq
:0 -o match
:"${TESTCASE}, skipped, .*foo.*machine type" \
950 -e ignore atf-run
-v machine
="foo" helper
952 -o match
:"${TESTCASE}, skipped, .*foo bar.*machine types" -e ignore \
953 atf-run
-v machine
="foo bar" helper
955 -o match
:"${TESTCASE}, skipped, .*fictitiousxxx.*machine type" \
956 -e ignore atf-run
-v machine
="${machine}xxx" helper
959 atf_test_case require_progs
962 atf_set
"descr" "Tests that atf-run validates the require.progs property"
966 create_helper require_progs
967 create_atffile helper
969 echo "Checking absolute paths"
970 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
971 -v progs
='/bin/cp' helper
973 -o match
:"${TESTCASE}, skipped, .*/bin/__non-existent__.*PATH" \
974 -e ignore atf-run
-v progs
='/bin/__non-existent__' helper
976 echo "Checking that relative paths are not allowed"
978 -o match
:"${TESTCASE}, failed, Relative paths.*not allowed.*bin/cp" \
979 -e ignore atf-run
-v progs
='bin/cp' helper
981 echo "Check plain file names, searching them in the PATH."
982 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
985 -o match
:"${TESTCASE}, skipped, .*__non-existent__.*PATH" -e ignore \
986 atf-run
-v progs
='__non-existent__' helper
989 atf_test_case require_user_root
990 require_user_root_head
()
992 atf_set
"descr" "Tests that atf-run validates the require.user property" \
993 "when it is set to 'root'"
995 require_user_root_body
()
997 create_helper require_user
998 create_atffile helper
1000 if [ $
(id
-u) -eq 0 ]; then
1005 atf_check
-s eq
:0 -o match
:"${TESTCASE}, ${exp}" -e ignore atf-run \
1009 atf_test_case require_user_unprivileged
1010 require_user_unprivileged_head
()
1012 atf_set
"descr" "Tests that atf-run validates the require.user property" \
1013 "when it is set to 'root'"
1015 require_user_unprivileged_body
()
1017 create_helper require_user
1018 create_atffile helper
1020 if [ $
(id
-u) -eq 0 ]; then
1025 atf_check
-s eq
:0 -o match
:"${TESTCASE}, ${exp}" -e ignore atf-run \
1026 -v user
=unprivileged helper
1029 atf_test_case require_user_bad
1030 require_user_bad_head
()
1032 atf_set
"descr" "Tests that atf-run validates the require.user property" \
1033 "when it is set to 'root'"
1035 require_user_bad_body
()
1037 create_helper require_user
1038 create_atffile helper
1040 atf_check
-s eq
:1 -o match
:"${TESTCASE}, failed, Invalid value.*foobar" \
1041 -e ignore atf-run
-v user
=foobar helper
1044 atf_test_case timeout
1047 atf_set
"descr" "Tests that atf-run kills a test case that times out"
1051 create_helper timeout
1052 create_atffile helper
1055 -o match
:"${TESTCASE}, failed, .*timed out after 1 second" -e ignore \
1056 atf-run
-v statedir
=$
(pwd) helper
1057 if [ -f finished
]; then
1058 atf_fail
"Test case was not killed after time out"
1062 atf_test_case timeout_forkexit
1063 timeout_forkexit_head
()
1065 atf_set
"descr" "Tests that atf-run deals gracefully with a test program" \
1066 "that forks, exits, but the child process hangs"
1068 timeout_forkexit_body
()
1070 create_helper timeout_forkexit
1071 create_atffile helper
1073 atf_check
-s eq
:0 -o match
:"${TESTCASE}, passed" -e ignore atf-run \
1074 -v statedir
=$
(pwd) helper
1075 test -f parent-finished || atf_fail
"Parent did not exit as expected"
1076 test -f child-finished
&& atf_fail
"Subprocess exited but it should have" \
1077 "been forcibly terminated" || true
1080 atf_test_case ignore_deprecated_use_fs
1081 ignore_deprecated_use_fs_head
()
1083 atf_set
"descr" "Tests that atf-run ignores the deprecated use.fs property"
1085 ignore_deprecated_use_fs_body
()
1087 create_helper use_fs
1088 create_atffile helper
1090 atf_check
-s eq
:0 -o ignore
-e ignore atf-run helper
1093 atf_init_test_cases
()
1095 atf_add_test_case no_warnings
1096 atf_add_test_case config
1097 atf_add_test_case vflag
1098 atf_add_test_case atffile
1099 atf_add_test_case atffile_recursive
1100 atf_add_test_case expect
1101 atf_add_test_case fds
1102 atf_add_test_case mux_streams
1103 atf_add_test_case missing_results
1104 atf_add_test_case broken_results
1105 atf_add_test_case broken_tp_list
1106 atf_add_test_case zero_tcs
1107 atf_add_test_case exit_codes
1108 atf_add_test_case signaled
1109 atf_add_test_case hooks
1110 atf_add_test_case isolation_env
1111 atf_add_test_case isolation_home
1112 atf_add_test_case isolation_stdin
1113 atf_add_test_case isolation_umask
1114 atf_add_test_case cleanup_pass
1115 atf_add_test_case cleanup_fail
1116 atf_add_test_case cleanup_skip
1117 atf_add_test_case cleanup_curdir
1118 atf_add_test_case cleanup_signal
1119 atf_add_test_case cleanup_mount
1120 atf_add_test_case cleanup_symlink
1121 atf_add_test_case require_arch
1122 atf_add_test_case require_config
1123 atf_add_test_case require_files
1124 atf_add_test_case require_machine
1125 atf_add_test_case require_progs
1126 atf_add_test_case require_user_root
1127 atf_add_test_case require_user_unprivileged
1128 atf_add_test_case require_user_bad
1129 atf_add_test_case timeout
1130 atf_add_test_case timeout_forkexit
1131 atf_add_test_case ignore_deprecated_use_fs
1134 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4