[BACK]Return to t_modload.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / tests / modules

Annotation of src/tests/modules/t_modload.sh, Revision 1.1

1.1     ! jmmv        1: # $NetBSD$
        !             2: #
        !             3: # Copyright (c) 2008 The NetBSD Foundation, Inc.
        !             4: # All rights reserved.
        !             5: #
        !             6: # Redistribution and use in source and binary forms, with or without
        !             7: # modification, are permitted provided that the following conditions
        !             8: # are met:
        !             9: # 1. Redistributions of source code must retain the above copyright
        !            10: #    notice, this list of conditions and the following disclaimer.
        !            11: # 2. Redistributions in binary form must reproduce the above copyright
        !            12: #    notice, this list of conditions and the following disclaimer in the
        !            13: #    documentation and/or other materials provided with the distribution.
        !            14: # 3. All advertising materials mentioning features or use of this software
        !            15: #    must display the following acknowledgement:
        !            16: #        This product includes software developed by the NetBSD
        !            17: #        Foundation, Inc. and its contributors.
        !            18: # 4. Neither the name of The NetBSD Foundation nor the names of its
        !            19: #    contributors may be used to endorse or promote products derived
        !            20: #    from this software without specific prior written permission.
        !            21: #
        !            22: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            23: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            24: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            25: # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            26: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            27: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            28: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            29: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            30: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            31: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            32: # POSSIBILITY OF SUCH DAMAGE.
        !            33: #
        !            34:
        !            35: check_sysctl() {
        !            36:        echo "${1} = ${2}" >expout
        !            37:        atf_check "sysctl ${1}" 0 expout null
        !            38: }
        !            39:
        !            40: atf_test_case plain
        !            41: plain_head() {
        !            42:        atf_set "descr" "Test load without arguments"
        !            43:        atf_set "require.user" "root"
        !            44: }
        !            45: plain_body() {
        !            46:        cat >experr <<EOF
        !            47: modload: No such file or directory
        !            48: EOF
        !            49:        atf_check "modload non-existent.o" 1 null experr
        !            50:
        !            51:        atf_check "modload $(atf_get_srcdir)/k_helper.o" 0 null null
        !            52:        check_sysctl vendor.k_helper.present 1
        !            53:        check_sysctl vendor.k_helper.prop_int_ok 0
        !            54:        check_sysctl vendor.k_helper.prop_str_ok 0
        !            55:        atf_check "modunload k_helper" 0 null null
        !            56: }
        !            57: plain_cleanup() {
        !            58:        modunload k_helper >/dev/null 2>&1
        !            59: }
        !            60:
        !            61: atf_test_case bflag
        !            62: bflag_head() {
        !            63:        atf_set "descr" "Test the -b flag"
        !            64:        atf_set "require.user" "root"
        !            65: }
        !            66: bflag_body() {
        !            67:        echo "Checking error conditions"
        !            68:
        !            69:        atf_check "modload -b foo k_helper.o" 1 null stderr
        !            70:        atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
        !            71:
        !            72:        atf_check "modload -b foo= k_helper.o" 1 null stderr
        !            73:        atf_check "grep 'Invalid boolean value' stderr" 0 ignore null
        !            74:
        !            75:        atf_check "modload -b foo=bar k_helper.o" 1 null stderr
        !            76:        atf_check "grep 'Invalid boolean value.*bar' stderr" 0 ignore null
        !            77:
        !            78:        atf_check "modload -b foo=falsea k_helper.o" 1 null stderr
        !            79:        atf_check "grep 'Invalid boolean value.*falsea' stderr" 0 ignore null
        !            80:
        !            81:        atf_check "modload -b foo=truea k_helper.o" 1 null stderr
        !            82:        atf_check "grep 'Invalid boolean value.*truea' stderr" 0 ignore null
        !            83:
        !            84:        # TODO Once sysctl(8) supports CTLTYPE_BOOL nodes.
        !            85:        #echo "Checking valid values"
        !            86: }
        !            87: bflag_cleanup() {
        !            88:        modunload k_helper >/dev/null 2>&1
        !            89: }
        !            90:
        !            91: atf_test_case iflag
        !            92: iflag_head() {
        !            93:        atf_set "descr" "Test the -i flag"
        !            94:        atf_set "require.user" "root"
        !            95: }
        !            96: iflag_body() {
        !            97:        echo "Checking error conditions"
        !            98:
        !            99:        atf_check "modload -i foo k_helper.o" 1 null stderr
        !           100:        atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
        !           101:
        !           102:        atf_check "modload -i foo= k_helper.o" 1 null stderr
        !           103:        atf_check "grep 'Invalid integer value' stderr" 0 ignore null
        !           104:
        !           105:        atf_check "modload -i foo=bar k_helper.o" 1 null stderr
        !           106:        atf_check "grep 'Invalid integer value.*bar' stderr" 0 ignore null
        !           107:
        !           108:        atf_check "modload -i foo=123a k_helper.o" 1 null stderr
        !           109:        atf_check "grep 'Invalid integer value.*123a' stderr" 0 ignore null
        !           110:
        !           111:        echo "Checking valid values"
        !           112:
        !           113:        for v in 5 10; do
        !           114:                atf_check "modload -i prop_int='${v}' \
        !           115:                           $(atf_get_srcdir)/k_helper.o" 0 null null
        !           116:                check_sysctl vendor.k_helper.prop_int_ok 1
        !           117:                check_sysctl vendor.k_helper.prop_int_val "${v}"
        !           118:                atf_check "modunload k_helper" 0 null null
        !           119:        done
        !           120: }
        !           121: iflag_cleanup() {
        !           122:        modunload k_helper >/dev/null 2>&1
        !           123: }
        !           124:
        !           125: atf_test_case sflag
        !           126: sflag_head() {
        !           127:        atf_set "descr" "Test the -s flag"
        !           128:        atf_set "require.user" "root"
        !           129: }
        !           130: sflag_body() {
        !           131:        echo "Checking error conditions"
        !           132:
        !           133:        atf_check "modload -s foo k_helper.o" 1 null stderr
        !           134:        atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
        !           135:
        !           136:        echo "Checking valid values"
        !           137:
        !           138:        for v in '1st string' '2nd string'; do
        !           139:                atf_check "modload -s prop_str='${v}' \
        !           140:                           $(atf_get_srcdir)/k_helper.o" 0 null null
        !           141:                check_sysctl vendor.k_helper.prop_str_ok 1
        !           142:                check_sysctl vendor.k_helper.prop_str_val "${v}"
        !           143:                atf_check "modunload k_helper" 0 null null
        !           144:        done
        !           145: }
        !           146: sflag_cleanup() {
        !           147:        modunload k_helper >/dev/null 2>&1
        !           148: }
        !           149:
        !           150: atf_init_test_cases()
        !           151: {
        !           152:        atf_add_test_case plain
        !           153:        atf_add_test_case bflag
        !           154:        atf_add_test_case iflag
        !           155:        atf_add_test_case sflag
        !           156: }

CVSweb <webmaster@jp.NetBSD.org>