Home | History | Annotate | Line # | Download | only in integration
      1  1.1  jmmv # Copyright 2011 Google Inc.
      2  1.1  jmmv # All rights reserved.
      3  1.1  jmmv #
      4  1.1  jmmv # Redistribution and use in source and binary forms, with or without
      5  1.1  jmmv # modification, are permitted provided that the following conditions are
      6  1.1  jmmv # met:
      7  1.1  jmmv #
      8  1.1  jmmv # * Redistributions of source code must retain the above copyright
      9  1.1  jmmv #   notice, this list of conditions and the following disclaimer.
     10  1.1  jmmv # * Redistributions in binary form must reproduce the above copyright
     11  1.1  jmmv #   notice, this list of conditions and the following disclaimer in the
     12  1.1  jmmv #   documentation and/or other materials provided with the distribution.
     13  1.1  jmmv # * Neither the name of Google Inc. nor the names of its contributors
     14  1.1  jmmv #   may be used to endorse or promote products derived from this software
     15  1.1  jmmv #   without specific prior written permission.
     16  1.1  jmmv #
     17  1.1  jmmv # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     18  1.1  jmmv # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     19  1.1  jmmv # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     20  1.1  jmmv # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     21  1.1  jmmv # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     22  1.1  jmmv # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     23  1.1  jmmv # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24  1.1  jmmv # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25  1.1  jmmv # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  1.1  jmmv # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27  1.1  jmmv # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  1.1  jmmv 
     29  1.1  jmmv 
     30  1.1  jmmv # Location of installed documents.  Used to validate the output of the about
     31  1.1  jmmv # messages against the golden files.
     32  1.1  jmmv KYUA_DOCDIR='__KYUA_DOCDIR__'
     33  1.1  jmmv 
     34  1.1  jmmv 
     35  1.1  jmmv # Common code to validate the output of all about information.
     36  1.1  jmmv #
     37  1.1  jmmv # \param file The name of the file with the output.
     38  1.1  jmmv check_all() {
     39  1.1  jmmv     local file="${1}"; shift
     40  1.1  jmmv 
     41  1.1  jmmv     grep -E 'kyua-cli.*[0-9]+\.[0-9]+' "${file}" || \
     42  1.1  jmmv         atf_fail 'No version reported'
     43  1.1  jmmv     grep 'Copyright' "${file}" || atf_fail 'No license reported'
     44  1.1  jmmv     grep '<.*@.*>' "${file}" || atf_fail 'No authors reported'
     45  1.1  jmmv     grep 'Homepage' "${file}" || atf_fail 'No homepage reported'
     46  1.1  jmmv }
     47  1.1  jmmv 
     48  1.1  jmmv 
     49  1.1  jmmv utils_test_case all_topics__installed
     50  1.1  jmmv all_topics__installed_head() {
     51  1.1  jmmv     atf_set "require.files" "${KYUA_DOCDIR}/AUTHORS ${KYUA_DOCDIR}/COPYING"
     52  1.1  jmmv }
     53  1.1  jmmv all_topics__installed_body() {
     54  1.1  jmmv     atf_check -s exit:0 -o save:stdout -e empty kyua about
     55  1.1  jmmv     check_all stdout
     56  1.1  jmmv }
     57  1.1  jmmv 
     58  1.1  jmmv 
     59  1.1  jmmv utils_test_case all_topics__override
     60  1.1  jmmv all_topics__override_body() {
     61  1.1  jmmv     mkdir docs
     62  1.1  jmmv     echo "Author <author (at] example.net>" >docs/AUTHORS
     63  1.1  jmmv     echo "Copyright text" >docs/COPYING
     64  1.1  jmmv     export KYUA_DOCDIR=docs
     65  1.1  jmmv     atf_check -s exit:0 -o save:stdout -e empty kyua about
     66  1.1  jmmv     check_all stdout
     67  1.1  jmmv }
     68  1.1  jmmv 
     69  1.1  jmmv 
     70  1.1  jmmv utils_test_case topic__authors__installed
     71  1.1  jmmv topic__authors__installed_head() {
     72  1.1  jmmv     atf_set "require.files" "${KYUA_DOCDIR}/AUTHORS"
     73  1.1  jmmv }
     74  1.1  jmmv topic__authors__installed_body() {
     75  1.1  jmmv     atf_check -s exit:0 -o file:"${KYUA_DOCDIR}/AUTHORS" -e empty \
     76  1.1  jmmv         kyua about authors
     77  1.1  jmmv }
     78  1.1  jmmv 
     79  1.1  jmmv 
     80  1.1  jmmv utils_test_case topic__authors__override
     81  1.1  jmmv topic__authors__override_body() {
     82  1.1  jmmv     mkdir docs
     83  1.1  jmmv     echo "Author <author (at] example.net>" >docs/AUTHORS
     84  1.1  jmmv     export KYUA_DOCDIR=docs
     85  1.1  jmmv     atf_check -s exit:0 -o file:docs/AUTHORS -e empty kyua about authors
     86  1.1  jmmv }
     87  1.1  jmmv 
     88  1.1  jmmv 
     89  1.1  jmmv utils_test_case topic__license__installed
     90  1.1  jmmv topic__license__installed_head() {
     91  1.1  jmmv     atf_set "require.files" "${KYUA_DOCDIR}/COPYING"
     92  1.1  jmmv }
     93  1.1  jmmv topic__license__installed_body() {
     94  1.1  jmmv     atf_check -s exit:0 -o file:"${KYUA_DOCDIR}/COPYING" -e empty \
     95  1.1  jmmv         kyua about license
     96  1.1  jmmv }
     97  1.1  jmmv 
     98  1.1  jmmv 
     99  1.1  jmmv utils_test_case topic__license__override
    100  1.1  jmmv topic__license__override_body() {
    101  1.1  jmmv     mkdir docs
    102  1.1  jmmv     echo "Copyright text" >docs/COPYING
    103  1.1  jmmv     export KYUA_DOCDIR=docs
    104  1.1  jmmv     atf_check -s exit:0 -o file:docs/COPYING -e empty kyua about license
    105  1.1  jmmv }
    106  1.1  jmmv 
    107  1.1  jmmv 
    108  1.1  jmmv utils_test_case topic__version
    109  1.1  jmmv topic__version_body() {
    110  1.1  jmmv     atf_check -s exit:0 -o save:stdout -e empty kyua about version
    111  1.1  jmmv 
    112  1.1  jmmv     local lines="$(wc -l stdout | awk '{ print $1 }')"
    113  1.1  jmmv     [ "${lines}" -eq 1 ] || atf_fail "Version query returned more than one line"
    114  1.1  jmmv 
    115  1.1  jmmv     grep '^kyua-cli (.*) [0-9]\.[0-9]$' stdout || \
    116  1.1  jmmv         atf_fail "Invalid version message"
    117  1.1  jmmv }
    118  1.1  jmmv 
    119  1.1  jmmv 
    120  1.1  jmmv utils_test_case topic__invalid
    121  1.1  jmmv topic__invalid_body() {
    122  1.1  jmmv     cat >experr <<EOF
    123  1.1  jmmv Usage error for command about: Invalid about topic 'foo'.
    124  1.1  jmmv Type 'kyua help about' for usage information.
    125  1.1  jmmv EOF
    126  1.1  jmmv     atf_check -s exit:3 -o empty -e file:experr kyua about foo
    127  1.1  jmmv }
    128  1.1  jmmv 
    129  1.1  jmmv 
    130  1.1  jmmv utils_test_case too_many_arguments
    131  1.1  jmmv too_many_arguments_body() {
    132  1.1  jmmv     cat >stderr <<EOF
    133  1.1  jmmv Usage error for command about: Too many arguments.
    134  1.1  jmmv Type 'kyua help about' for usage information.
    135  1.1  jmmv EOF
    136  1.1  jmmv     atf_check -s exit:3 -o empty -e file:stderr kyua about abc def
    137  1.1  jmmv }
    138  1.1  jmmv 
    139  1.1  jmmv 
    140  1.1  jmmv atf_init_test_cases() {
    141  1.1  jmmv     atf_add_test_case all_topics__installed
    142  1.1  jmmv     atf_add_test_case all_topics__override
    143  1.1  jmmv     atf_add_test_case topic__authors__installed
    144  1.1  jmmv     atf_add_test_case topic__authors__override
    145  1.1  jmmv     atf_add_test_case topic__license__installed
    146  1.1  jmmv     atf_add_test_case topic__license__override
    147  1.1  jmmv     atf_add_test_case topic__version
    148  1.1  jmmv     atf_add_test_case topic__invalid
    149  1.1  jmmv 
    150  1.1  jmmv     atf_add_test_case too_many_arguments
    151  1.1  jmmv }
    152