xref: /minix3/external/bsd/kyua-cli/dist/integration/cmd_list_test.sh (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
111be35a1SLionel Sambuc# Copyright 2011 Google Inc.
211be35a1SLionel Sambuc# All rights reserved.
311be35a1SLionel Sambuc#
411be35a1SLionel Sambuc# Redistribution and use in source and binary forms, with or without
511be35a1SLionel Sambuc# modification, are permitted provided that the following conditions are
611be35a1SLionel Sambuc# met:
711be35a1SLionel Sambuc#
811be35a1SLionel Sambuc# * Redistributions of source code must retain the above copyright
911be35a1SLionel Sambuc#   notice, this list of conditions and the following disclaimer.
1011be35a1SLionel Sambuc# * Redistributions in binary form must reproduce the above copyright
1111be35a1SLionel Sambuc#   notice, this list of conditions and the following disclaimer in the
1211be35a1SLionel Sambuc#   documentation and/or other materials provided with the distribution.
1311be35a1SLionel Sambuc# * Neither the name of Google Inc. nor the names of its contributors
1411be35a1SLionel Sambuc#   may be used to endorse or promote products derived from this software
1511be35a1SLionel Sambuc#   without specific prior written permission.
1611be35a1SLionel Sambuc#
1711be35a1SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1811be35a1SLionel Sambuc# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1911be35a1SLionel Sambuc# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2011be35a1SLionel Sambuc# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2111be35a1SLionel Sambuc# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2211be35a1SLionel Sambuc# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2311be35a1SLionel Sambuc# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2411be35a1SLionel Sambuc# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2511be35a1SLionel Sambuc# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2611be35a1SLionel Sambuc# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2711be35a1SLionel Sambuc# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2811be35a1SLionel Sambuc
2911be35a1SLionel Sambuc
3011be35a1SLionel Sambucutils_test_case no_args
3111be35a1SLionel Sambucno_args_body() {
3211be35a1SLionel Sambuc    cat >Kyuafile <<EOF
3311be35a1SLionel Sambucsyntax(2)
3411be35a1SLionel Sambuctest_suite("integration")
3511be35a1SLionel Sambucatf_test_program{name="metadata"}
3611be35a1SLionel Sambucatf_test_program{name="simple_all_pass"}
3711be35a1SLionel Sambucinclude("subdir/Kyuafile")
3811be35a1SLionel SambucEOF
3911be35a1SLionel Sambuc    utils_cp_helper metadata .
4011be35a1SLionel Sambuc    utils_cp_helper simple_all_pass .
4111be35a1SLionel Sambuc
4211be35a1SLionel Sambuc    mkdir subdir
4311be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
4411be35a1SLionel Sambucsyntax(2)
4511be35a1SLionel Sambuctest_suite("integration2")
4611be35a1SLionel Sambucatf_test_program{name="simple_some_fail"}
4711be35a1SLionel SambucEOF
4811be35a1SLionel Sambuc    utils_cp_helper simple_some_fail subdir
4911be35a1SLionel Sambuc
5011be35a1SLionel Sambuc    cat >expout <<EOF
5111be35a1SLionel Sambucmetadata:no_properties
5211be35a1SLionel Sambucmetadata:one_property
5311be35a1SLionel Sambucmetadata:many_properties
5411be35a1SLionel Sambucmetadata:with_cleanup
5511be35a1SLionel Sambucsimple_all_pass:pass
5611be35a1SLionel Sambucsimple_all_pass:skip
5711be35a1SLionel Sambucsubdir/simple_some_fail:fail
5811be35a1SLionel Sambucsubdir/simple_some_fail:pass
5911be35a1SLionel SambucEOF
6011be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list
6111be35a1SLionel Sambuc}
6211be35a1SLionel Sambuc
6311be35a1SLionel Sambuc
6411be35a1SLionel Sambucutils_test_case one_arg__subdir
6511be35a1SLionel Sambucone_arg__subdir_body() {
6611be35a1SLionel Sambuc    cat >Kyuafile <<EOF
6711be35a1SLionel Sambucsyntax(2)
6811be35a1SLionel Sambuctest_suite("top-level")
6911be35a1SLionel Sambucinclude("subdir/Kyuafile")
7011be35a1SLionel SambucEOF
7111be35a1SLionel Sambuc
7211be35a1SLionel Sambuc    mkdir subdir
7311be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
7411be35a1SLionel Sambucsyntax(2)
7511be35a1SLionel Sambuctest_suite("in-subdir")
7611be35a1SLionel Sambucatf_test_program{name="simple_all_pass"}
7711be35a1SLionel SambucEOF
7811be35a1SLionel Sambuc    utils_cp_helper simple_all_pass subdir
7911be35a1SLionel Sambuc
8011be35a1SLionel Sambuc    cat >expout <<EOF
8111be35a1SLionel Sambucsubdir/simple_all_pass:pass
8211be35a1SLionel Sambucsubdir/simple_all_pass:skip
8311be35a1SLionel SambucEOF
8411be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list subdir
8511be35a1SLionel Sambuc}
8611be35a1SLionel Sambuc
8711be35a1SLionel Sambuc
8811be35a1SLionel Sambucutils_test_case one_arg__test_case
8911be35a1SLionel Sambucone_arg__test_case_body() {
9011be35a1SLionel Sambuc    cat >Kyuafile <<EOF
9111be35a1SLionel Sambucsyntax(2)
9211be35a1SLionel Sambuctest_suite("top-level")
9311be35a1SLionel Sambucatf_test_program{name="first"}
9411be35a1SLionel Sambucatf_test_program{name="second"}
9511be35a1SLionel SambucEOF
9611be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
9711be35a1SLionel Sambuc    utils_cp_helper simple_all_pass second
9811be35a1SLionel Sambuc
9911be35a1SLionel Sambuc    cat >expout <<EOF
10011be35a1SLionel Sambucfirst:skip
10111be35a1SLionel SambucEOF
10211be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list first:skip
10311be35a1SLionel Sambuc}
10411be35a1SLionel Sambuc
10511be35a1SLionel Sambuc
10611be35a1SLionel Sambucutils_test_case one_arg__test_program
10711be35a1SLionel Sambucone_arg__test_program_body() {
10811be35a1SLionel Sambuc    cat >Kyuafile <<EOF
10911be35a1SLionel Sambucsyntax(2)
11011be35a1SLionel Sambuctest_suite("top-level")
11111be35a1SLionel Sambucatf_test_program{name="first"}
11211be35a1SLionel Sambucatf_test_program{name="second"}
11311be35a1SLionel SambucEOF
11411be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
11511be35a1SLionel Sambuc    utils_cp_helper simple_some_fail second
11611be35a1SLionel Sambuc
11711be35a1SLionel Sambuc    cat >expout <<EOF
11811be35a1SLionel Sambucsecond:fail
11911be35a1SLionel Sambucsecond:pass
12011be35a1SLionel SambucEOF
12111be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list second
12211be35a1SLionel Sambuc}
12311be35a1SLionel Sambuc
12411be35a1SLionel Sambuc
12511be35a1SLionel Sambucutils_test_case one_arg__invalid
12611be35a1SLionel Sambucone_arg__invalid_body() {
12711be35a1SLionel Sambuccat >experr <<EOF
12811be35a1SLionel Sambuckyua: E: Test case component in 'foo:' is empty.
12911be35a1SLionel SambucEOF
13011be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e file:experr kyua list foo:
13111be35a1SLionel Sambuc
13211be35a1SLionel Sambuccat >experr <<EOF
13311be35a1SLionel Sambuckyua: E: Program name '/a/b' must be relative to the test suite, not absolute.
13411be35a1SLionel SambucEOF
13511be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e file:experr kyua list /a/b
13611be35a1SLionel Sambuc}
13711be35a1SLionel Sambuc
13811be35a1SLionel Sambuc
13911be35a1SLionel Sambucutils_test_case many_args__ok
14011be35a1SLionel Sambucmany_args__ok_body() {
14111be35a1SLionel Sambuc    cat >Kyuafile <<EOF
14211be35a1SLionel Sambucsyntax(2)
14311be35a1SLionel Sambuctest_suite("top-level")
14411be35a1SLionel Sambucinclude("subdir/Kyuafile")
14511be35a1SLionel Sambucatf_test_program{name="first"}
14611be35a1SLionel SambucEOF
14711be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
14811be35a1SLionel Sambuc
14911be35a1SLionel Sambuc    mkdir subdir
15011be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
15111be35a1SLionel Sambucsyntax(2)
15211be35a1SLionel Sambuctest_suite("in-subdir")
15311be35a1SLionel Sambucatf_test_program{name="second"}
15411be35a1SLionel SambucEOF
15511be35a1SLionel Sambuc    utils_cp_helper simple_some_fail subdir/second
15611be35a1SLionel Sambuc
15711be35a1SLionel Sambuc    cat >expout <<EOF
15811be35a1SLionel Sambucsubdir/second:fail (in-subdir)
15911be35a1SLionel Sambucsubdir/second:pass (in-subdir)
16011be35a1SLionel Sambucfirst:pass (top-level)
16111be35a1SLionel SambucEOF
16211be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list -v subdir first:pass
16311be35a1SLionel Sambuc}
16411be35a1SLionel Sambuc
16511be35a1SLionel Sambuc
16611be35a1SLionel Sambucutils_test_case many_args__invalid
16711be35a1SLionel Sambucmany_args__invalid_body() {
16811be35a1SLionel Sambuccat >experr <<EOF
16911be35a1SLionel Sambuckyua: E: Program name component in ':badbad' is empty.
17011be35a1SLionel SambucEOF
17111be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e file:experr kyua list this-is-ok :badbad
17211be35a1SLionel Sambuc
17311be35a1SLionel Sambuccat >experr <<EOF
17411be35a1SLionel Sambuckyua: E: Program name '/foo' must be relative to the test suite, not absolute.
17511be35a1SLionel SambucEOF
17611be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e file:experr kyua list this-is-ok /foo
17711be35a1SLionel Sambuc}
17811be35a1SLionel Sambuc
17911be35a1SLionel Sambuc
18011be35a1SLionel Sambucutils_test_case many_args__no_match__all
18111be35a1SLionel Sambucmany_args__no_match__all_body() {
18211be35a1SLionel Sambuc    cat >Kyuafile <<EOF
18311be35a1SLionel Sambucsyntax(2)
18411be35a1SLionel Sambuctest_suite("top-level")
18511be35a1SLionel Sambucatf_test_program{name="first"}
18611be35a1SLionel Sambucatf_test_program{name="second"}
18711be35a1SLionel SambucEOF
18811be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
18911be35a1SLionel Sambuc    utils_cp_helper simple_all_pass second
19011be35a1SLionel Sambuc
19111be35a1SLionel Sambuc    cat >experr <<EOF
19211be35a1SLionel Sambuckyua: W: No test cases matched by the filter 'first1'.
19311be35a1SLionel SambucEOF
19411be35a1SLionel Sambuc    atf_check -s exit:1 -o empty -e file:experr kyua list first1
19511be35a1SLionel Sambuc}
19611be35a1SLionel Sambuc
19711be35a1SLionel Sambuc
19811be35a1SLionel Sambucutils_test_case many_args__no_match__some
19911be35a1SLionel Sambucmany_args__no_match__some_body() {
20011be35a1SLionel Sambuc    cat >Kyuafile <<EOF
20111be35a1SLionel Sambucsyntax(2)
20211be35a1SLionel Sambuctest_suite("top-level")
20311be35a1SLionel Sambucatf_test_program{name="first"}
20411be35a1SLionel Sambucatf_test_program{name="second"}
20511be35a1SLionel Sambucatf_test_program{name="third"}
20611be35a1SLionel SambucEOF
20711be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
20811be35a1SLionel Sambuc    utils_cp_helper simple_all_pass second
20911be35a1SLionel Sambuc    utils_cp_helper simple_some_fail third
21011be35a1SLionel Sambuc
21111be35a1SLionel Sambuc    cat >expout <<EOF
21211be35a1SLionel Sambucfirst:pass
21311be35a1SLionel Sambucfirst:skip
21411be35a1SLionel Sambucthird:fail
21511be35a1SLionel Sambucthird:pass
21611be35a1SLionel SambucEOF
21711be35a1SLionel Sambuc
21811be35a1SLionel Sambuc    cat >experr <<EOF
21911be35a1SLionel Sambuckyua: W: No test cases matched by the filter 'fifth'.
22011be35a1SLionel Sambuckyua: W: No test cases matched by the filter 'fourth'.
22111be35a1SLionel SambucEOF
22211be35a1SLionel Sambuc    atf_check -s exit:1 -o file:expout -e file:experr kyua list first fourth \
22311be35a1SLionel Sambuc        third fifth
22411be35a1SLionel Sambuc}
22511be35a1SLionel Sambuc
22611be35a1SLionel Sambuc
22711be35a1SLionel Sambucutils_test_case args_are_relative
22811be35a1SLionel Sambucargs_are_relative_body() {
22911be35a1SLionel Sambuc    mkdir root
23011be35a1SLionel Sambuc    cat >root/Kyuafile <<EOF
23111be35a1SLionel Sambucsyntax(2)
23211be35a1SLionel Sambuctest_suite("integration-1")
23311be35a1SLionel Sambucatf_test_program{name="first"}
23411be35a1SLionel Sambucatf_test_program{name="second"}
23511be35a1SLionel Sambucinclude("subdir/Kyuafile")
23611be35a1SLionel SambucEOF
23711be35a1SLionel Sambuc    utils_cp_helper simple_all_pass root/first
23811be35a1SLionel Sambuc    utils_cp_helper simple_some_fail root/second
23911be35a1SLionel Sambuc
24011be35a1SLionel Sambuc    mkdir root/subdir
24111be35a1SLionel Sambuc    cat >root/subdir/Kyuafile <<EOF
24211be35a1SLionel Sambucsyntax(2)
24311be35a1SLionel Sambuctest_suite("integration-2")
24411be35a1SLionel Sambucatf_test_program{name="third"}
24511be35a1SLionel Sambucatf_test_program{name="fourth"}
24611be35a1SLionel SambucEOF
24711be35a1SLionel Sambuc    utils_cp_helper simple_all_pass root/subdir/third
24811be35a1SLionel Sambuc    utils_cp_helper simple_some_fail root/subdir/fourth
24911be35a1SLionel Sambuc
25011be35a1SLionel Sambuc    cat >expout <<EOF
25111be35a1SLionel Sambucfirst:pass (integration-1)
25211be35a1SLionel Sambucfirst:skip (integration-1)
25311be35a1SLionel Sambucsubdir/fourth:fail (integration-2)
25411be35a1SLionel SambucEOF
25511be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list \
25611be35a1SLionel Sambuc        -v -k "$(pwd)/root/Kyuafile" first subdir/fourth:fail
25711be35a1SLionel Sambuc}
25811be35a1SLionel Sambuc
25911be35a1SLionel Sambuc
26011be35a1SLionel Sambucutils_test_case only_load_used_test_programs
26111be35a1SLionel Sambuconly_load_used_test_programs_body() {
26211be35a1SLionel Sambuc    cat >Kyuafile <<EOF
26311be35a1SLionel Sambucsyntax(2)
26411be35a1SLionel Sambuctest_suite("integration")
26511be35a1SLionel Sambucatf_test_program{name="first"}
26611be35a1SLionel Sambucatf_test_program{name="second"}
26711be35a1SLionel SambucEOF
26811be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
26911be35a1SLionel Sambuc    utils_cp_helper bad_test_program second
27011be35a1SLionel Sambuc
27111be35a1SLionel Sambuc    cat >expout <<EOF
27211be35a1SLionel Sambucfirst:pass
27311be35a1SLionel Sambucfirst:skip
27411be35a1SLionel SambucEOF
27511be35a1SLionel Sambuc    CREATE_COOKIE="$(pwd)/cookie"; export CREATE_COOKIE
27611be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list first
27711be35a1SLionel Sambuc    if test -f "${CREATE_COOKIE}"; then
27811be35a1SLionel Sambuc        atf_fail "An unmatched test case has been executed, which harms" \
27911be35a1SLionel Sambuc            "performance"
28011be35a1SLionel Sambuc    fi
28111be35a1SLionel Sambuc}
28211be35a1SLionel Sambuc
28311be35a1SLionel Sambuc
28411be35a1SLionel Sambucutils_test_case build_root_flag
28511be35a1SLionel Sambucbuild_root_flag_body() {
28611be35a1SLionel Sambuc    mkdir subdir
28711be35a1SLionel Sambuc    mkdir build
28811be35a1SLionel Sambuc    mkdir build/subdir
28911be35a1SLionel Sambuc
29011be35a1SLionel Sambuc    cat >Kyuafile <<EOF
29111be35a1SLionel Sambucsyntax(2)
29211be35a1SLionel Sambuctest_suite("top-level")
29311be35a1SLionel Sambucinclude("subdir/Kyuafile")
29411be35a1SLionel Sambucatf_test_program{name="first"}
29511be35a1SLionel SambucEOF
29611be35a1SLionel Sambuc    echo 'invalid' >first
29711be35a1SLionel Sambuc    utils_cp_helper simple_all_pass build/first
29811be35a1SLionel Sambuc
29911be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
30011be35a1SLionel Sambucsyntax(2)
30111be35a1SLionel Sambuctest_suite("in-subdir")
30211be35a1SLionel Sambucatf_test_program{name="second"}
30311be35a1SLionel SambucEOF
30411be35a1SLionel Sambuc    echo 'invalid' >subdir/second
30511be35a1SLionel Sambuc    utils_cp_helper simple_some_fail build/subdir/second
30611be35a1SLionel Sambuc
30711be35a1SLionel Sambuc    cat >expout <<EOF
30811be35a1SLionel Sambucsubdir/second:fail
30911be35a1SLionel Sambucsubdir/second:pass
31011be35a1SLionel Sambucfirst:pass
31111be35a1SLionel SambucEOF
31211be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list --build-root=build \
31311be35a1SLionel Sambuc        subdir first:pass
31411be35a1SLionel Sambuc}
31511be35a1SLionel Sambuc
31611be35a1SLionel Sambuc
31711be35a1SLionel Sambucutils_test_case kyuafile_flag__no_args
31811be35a1SLionel Sambuckyuafile_flag__no_args_body() {
31911be35a1SLionel Sambuc    cat >Kyuafile <<EOF
32011be35a1SLionel SambucThis file is bogus but it is not loaded.
32111be35a1SLionel SambucEOF
32211be35a1SLionel Sambuc
32311be35a1SLionel Sambuc    cat >myfile <<EOF
32411be35a1SLionel Sambucsyntax(2)
32511be35a1SLionel Sambuctest_suite("integration")
32611be35a1SLionel Sambucatf_test_program{name="sometest"}
32711be35a1SLionel SambucEOF
32811be35a1SLionel Sambuc    utils_cp_helper simple_all_pass sometest
32911be35a1SLionel Sambuc
33011be35a1SLionel Sambuc    cat >expout <<EOF
33111be35a1SLionel Sambucsometest:pass
33211be35a1SLionel Sambucsometest:skip
33311be35a1SLionel SambucEOF
33411be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list -k myfile
33511be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list --kyuafile=myfile
33611be35a1SLionel Sambuc}
33711be35a1SLionel Sambuc
33811be35a1SLionel Sambuc
33911be35a1SLionel Sambucutils_test_case kyuafile_flag__some_args
34011be35a1SLionel Sambuckyuafile_flag__some_args_body() {
34111be35a1SLionel Sambuc    cat >Kyuafile <<EOF
34211be35a1SLionel SambucThis file is bogus but it is not loaded.
34311be35a1SLionel SambucEOF
34411be35a1SLionel Sambuc
34511be35a1SLionel Sambuc    cat >myfile <<EOF
34611be35a1SLionel Sambucsyntax(2)
34711be35a1SLionel Sambuctest_suite("hello-world")
34811be35a1SLionel Sambucatf_test_program{name="sometest"}
34911be35a1SLionel SambucEOF
35011be35a1SLionel Sambuc    utils_cp_helper simple_all_pass sometest
35111be35a1SLionel Sambuc
35211be35a1SLionel Sambuc    cat >expout <<EOF
35311be35a1SLionel Sambucsometest:pass (hello-world)
35411be35a1SLionel Sambucsometest:skip (hello-world)
35511be35a1SLionel SambucEOF
35611be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list -v -k myfile sometest
35711be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list -v --kyuafile=myfile \
35811be35a1SLionel Sambuc        sometest
35911be35a1SLionel Sambuc}
36011be35a1SLionel Sambuc
36111be35a1SLionel Sambuc
36211be35a1SLionel Sambucutils_test_case verbose_flag
36311be35a1SLionel Sambucverbose_flag_body() {
36411be35a1SLionel Sambuc    cat >Kyuafile <<EOF
36511be35a1SLionel Sambucsyntax(2)
36611be35a1SLionel Sambuctest_suite("integration-suite-1")
36711be35a1SLionel Sambucatf_test_program{name="simple_all_pass"}
36811be35a1SLionel Sambucplain_test_program{name="i_am_plain", timeout=654}
36911be35a1SLionel Sambucinclude("subdir/Kyuafile")
37011be35a1SLionel SambucEOF
37111be35a1SLionel Sambuc    utils_cp_helper simple_all_pass .
37211be35a1SLionel Sambuc    touch i_am_plain
37311be35a1SLionel Sambuc
37411be35a1SLionel Sambuc    mkdir subdir
37511be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
37611be35a1SLionel Sambucsyntax(2)
37711be35a1SLionel Sambuctest_suite("integration-suite-2")
37811be35a1SLionel Sambucatf_test_program{name="metadata"}
37911be35a1SLionel SambucEOF
38011be35a1SLionel Sambuc    utils_cp_helper metadata subdir
38111be35a1SLionel Sambuc
38211be35a1SLionel Sambuc    cat >expout <<EOF
38311be35a1SLionel Sambucsimple_all_pass:pass (integration-suite-1)
38411be35a1SLionel Sambucsimple_all_pass:skip (integration-suite-1)
38511be35a1SLionel Sambuci_am_plain:main (integration-suite-1)
38611be35a1SLionel Sambuc    timeout = 654
38711be35a1SLionel Sambucsubdir/metadata:no_properties (integration-suite-2)
38811be35a1SLionel Sambucsubdir/metadata:one_property (integration-suite-2)
38911be35a1SLionel Sambuc    description = Does nothing but has one metadata property
39011be35a1SLionel Sambucsubdir/metadata:many_properties (integration-suite-2)
39111be35a1SLionel Sambuc    allowed_architectures = some-architecture
39211be35a1SLionel Sambuc    allowed_platforms = some-platform
39311be35a1SLionel Sambuc    custom.X-no-meaning = I am a custom variable
39411be35a1SLionel Sambuc    description =     A description with some padding
39511be35a1SLionel Sambuc    required_configs = var1 var2 var3
39611be35a1SLionel Sambuc    required_files = /my/file1 /some/other/file
39711be35a1SLionel Sambuc    required_programs = /nonexistent/bin3 bin1 bin2
39811be35a1SLionel Sambuc    required_user = root
39911be35a1SLionel Sambucsubdir/metadata:with_cleanup (integration-suite-2)
40011be35a1SLionel Sambuc    has_cleanup = true
40111be35a1SLionel Sambuc    timeout = 250
40211be35a1SLionel SambucEOF
40311be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list -v
40411be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list --verbose
40511be35a1SLionel Sambuc}
40611be35a1SLionel Sambuc
40711be35a1SLionel Sambuc
40811be35a1SLionel Sambucutils_test_case no_test_program_match
40911be35a1SLionel Sambucno_test_program_match_body() {
41011be35a1SLionel Sambuc    cat >Kyuafile <<EOF
41111be35a1SLionel Sambucsyntax(2)
41211be35a1SLionel Sambuctest_suite("integration")
41311be35a1SLionel Sambucatf_test_program{name="first"}
41411be35a1SLionel SambucEOF
41511be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
41611be35a1SLionel Sambuc    utils_cp_helper simple_all_pass second
41711be35a1SLionel Sambuc
41811be35a1SLionel Sambuc    cat >experr <<EOF
41911be35a1SLionel Sambuckyua: W: No test cases matched by the filter 'second'.
42011be35a1SLionel SambucEOF
42111be35a1SLionel Sambuc    atf_check -s exit:1 -o empty -e file:experr kyua list second
42211be35a1SLionel Sambuc}
42311be35a1SLionel Sambuc
42411be35a1SLionel Sambuc
42511be35a1SLionel Sambucutils_test_case no_test_case_match
42611be35a1SLionel Sambucno_test_case_match_body() {
42711be35a1SLionel Sambuc    cat >Kyuafile <<EOF
42811be35a1SLionel Sambucsyntax(2)
42911be35a1SLionel Sambuctest_suite("integration")
43011be35a1SLionel Sambucatf_test_program{name="first"}
43111be35a1SLionel SambucEOF
43211be35a1SLionel Sambuc    utils_cp_helper simple_all_pass first
43311be35a1SLionel Sambuc
43411be35a1SLionel Sambuc    cat >experr <<EOF
43511be35a1SLionel Sambuckyua: W: No test cases matched by the filter 'first:foobar'.
43611be35a1SLionel SambucEOF
43711be35a1SLionel Sambuc    atf_check -s exit:1 -o empty -e file:experr kyua list first:foobar
43811be35a1SLionel Sambuc}
43911be35a1SLionel Sambuc
44011be35a1SLionel Sambuc
44111be35a1SLionel Sambucutils_test_case missing_kyuafile__no_args
44211be35a1SLionel Sambucmissing_kyuafile__no_args_body() {
44311be35a1SLionel Sambuc    cat >experr <<EOF
44411be35a1SLionel Sambuckyua: E: Load of 'Kyuafile' failed: File 'Kyuafile' not found.
44511be35a1SLionel SambucEOF
44611be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e file:experr kyua list
44711be35a1SLionel Sambuc}
44811be35a1SLionel Sambuc
44911be35a1SLionel Sambuc
45011be35a1SLionel Sambucutils_test_case missing_kyuafile__test_program
45111be35a1SLionel Sambucmissing_kyuafile__test_program_body() {
45211be35a1SLionel Sambuc    mkdir subdir
45311be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
45411be35a1SLionel Sambucsyntax(2)
45511be35a1SLionel Sambuctest_suite("integration")
45611be35a1SLionel Sambucatf_test_program{name="unused"}
45711be35a1SLionel SambucEOF
45811be35a1SLionel Sambuc    utils_cp_helper simple_all_pass subdir/unused
45911be35a1SLionel Sambuc
46011be35a1SLionel Sambuc    cat >experr <<EOF
46111be35a1SLionel Sambuckyua: E: Load of 'Kyuafile' failed: File 'Kyuafile' not found.
46211be35a1SLionel SambucEOF
46311be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e file:experr kyua list subdir/unused
46411be35a1SLionel Sambuc}
46511be35a1SLionel Sambuc
46611be35a1SLionel Sambuc
46711be35a1SLionel Sambucutils_test_case missing_kyuafile__subdir
46811be35a1SLionel Sambucmissing_kyuafile__subdir_body() {
46911be35a1SLionel Sambuc    mkdir subdir
47011be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
47111be35a1SLionel Sambucsyntax(2)
47211be35a1SLionel Sambuctest_suite("integration")
47311be35a1SLionel Sambucatf_test_program{name="unused"}
47411be35a1SLionel SambucEOF
47511be35a1SLionel Sambuc    utils_cp_helper simple_all_pass subdir/unused
47611be35a1SLionel Sambuc
47711be35a1SLionel Sambuc    cat >experr <<EOF
47811be35a1SLionel Sambuckyua: E: Load of 'Kyuafile' failed: File 'Kyuafile' not found.
47911be35a1SLionel SambucEOF
48011be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e file:experr kyua list subdir
48111be35a1SLionel Sambuc}
48211be35a1SLionel Sambuc
48311be35a1SLionel Sambuc
48411be35a1SLionel Sambucutils_test_case bogus_kyuafile
48511be35a1SLionel Sambucbogus_kyuafile_body() {
48611be35a1SLionel Sambuc    cat >Kyuafile <<EOF
48711be35a1SLionel SambucHello, world.
48811be35a1SLionel SambucEOF
489*84d9c625SLionel Sambuc    atf_check -s exit:2 -o empty \
490*84d9c625SLionel Sambuc        -e match:"Load of 'Kyuafile' failed: .* Kyuafile:2:" kyua list
49111be35a1SLionel Sambuc}
49211be35a1SLionel Sambuc
49311be35a1SLionel Sambuc
49411be35a1SLionel Sambucutils_test_case bogus_test_program
49511be35a1SLionel Sambucbogus_test_program_body() {
49611be35a1SLionel Sambuc    cat >Kyuafile <<EOF
49711be35a1SLionel Sambucsyntax(2)
49811be35a1SLionel Sambuctest_suite("integration")
49911be35a1SLionel Sambucatf_test_program{name="crash_on_list"}
50011be35a1SLionel Sambucatf_test_program{name="non_executable"}
50111be35a1SLionel SambucEOF
50211be35a1SLionel Sambuc    utils_cp_helper bad_test_program crash_on_list
50311be35a1SLionel Sambuc    echo 'I am not executable' >non_executable
50411be35a1SLionel Sambuc
50511be35a1SLionel Sambuc    cat >expout <<EOF
50611be35a1SLionel Sambuccrash_on_list:__test_cases_list__
50711be35a1SLionel Sambucnon_executable:__test_cases_list__
50811be35a1SLionel SambucEOF
50911be35a1SLionel Sambuc    atf_check -s exit:0 -o file:expout -e empty kyua list
51011be35a1SLionel Sambuc}
51111be35a1SLionel Sambuc
51211be35a1SLionel Sambuc
51311be35a1SLionel Sambucutils_test_case missing_test_program
51411be35a1SLionel Sambucmissing_test_program_body() {
51511be35a1SLionel Sambuc    cat >Kyuafile <<EOF
51611be35a1SLionel Sambucsyntax(2)
51711be35a1SLionel Sambucinclude("subdir/Kyuafile")
51811be35a1SLionel SambucEOF
51911be35a1SLionel Sambuc    mkdir subdir
52011be35a1SLionel Sambuc    cat >subdir/Kyuafile <<EOF
52111be35a1SLionel Sambucsyntax(2)
52211be35a1SLionel Sambuctest_suite("integration")
52311be35a1SLionel Sambucatf_test_program{name="ok"}
52411be35a1SLionel Sambucatf_test_program{name="i-am-missing"}
52511be35a1SLionel SambucEOF
52611be35a1SLionel Sambuc    echo 'I should not be touched because the Kyuafile is bogus' >subdir/ok
52711be35a1SLionel Sambuc
52811be35a1SLionel Sambuc    cat >experr <<EOF
52911be35a1SLionel Sambuckyua: E: Load of 'Kyuafile' failed: .*Non-existent test program 'subdir/i-am-missing'.
53011be35a1SLionel SambucEOF
53111be35a1SLionel Sambuc    atf_check -s exit:2 -o empty -e "match:$(cat experr)" kyua list
53211be35a1SLionel Sambuc}
53311be35a1SLionel Sambuc
53411be35a1SLionel Sambuc
53511be35a1SLionel Sambucatf_init_test_cases() {
53611be35a1SLionel Sambuc    atf_add_test_case no_args
53711be35a1SLionel Sambuc    atf_add_test_case one_arg__subdir
53811be35a1SLionel Sambuc    atf_add_test_case one_arg__test_case
53911be35a1SLionel Sambuc    atf_add_test_case one_arg__test_program
54011be35a1SLionel Sambuc    atf_add_test_case one_arg__invalid
54111be35a1SLionel Sambuc    atf_add_test_case many_args__ok
54211be35a1SLionel Sambuc    atf_add_test_case many_args__invalid
54311be35a1SLionel Sambuc    atf_add_test_case many_args__no_match__all
54411be35a1SLionel Sambuc    atf_add_test_case many_args__no_match__some
54511be35a1SLionel Sambuc
54611be35a1SLionel Sambuc    atf_add_test_case args_are_relative
54711be35a1SLionel Sambuc
54811be35a1SLionel Sambuc    atf_add_test_case only_load_used_test_programs
54911be35a1SLionel Sambuc
55011be35a1SLionel Sambuc    atf_add_test_case build_root_flag
55111be35a1SLionel Sambuc
55211be35a1SLionel Sambuc    atf_add_test_case kyuafile_flag__no_args
55311be35a1SLionel Sambuc    atf_add_test_case kyuafile_flag__some_args
55411be35a1SLionel Sambuc
55511be35a1SLionel Sambuc    atf_add_test_case verbose_flag
55611be35a1SLionel Sambuc
55711be35a1SLionel Sambuc    atf_add_test_case no_test_program_match
55811be35a1SLionel Sambuc    atf_add_test_case no_test_case_match
55911be35a1SLionel Sambuc
56011be35a1SLionel Sambuc    atf_add_test_case missing_kyuafile__no_args
56111be35a1SLionel Sambuc    atf_add_test_case missing_kyuafile__test_program
56211be35a1SLionel Sambuc    atf_add_test_case missing_kyuafile__subdir
56311be35a1SLionel Sambuc
56411be35a1SLionel Sambuc    atf_add_test_case bogus_kyuafile
56511be35a1SLionel Sambuc    atf_add_test_case bogus_test_program
56611be35a1SLionel Sambuc    atf_add_test_case missing_test_program
56711be35a1SLionel Sambuc}
568