[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.6.1

1.1.6.1 ! yamt        1: # $NetBSD: t_modload.sh,v 1.1 2008/03/02 11:22:10 jmmv Exp $
1.1       jmmv        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: #
                     15: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     16: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     17: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     18: # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     19: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     20: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     21: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     22: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     23: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     24: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     25: # POSSIBILITY OF SUCH DAMAGE.
                     26: #
                     27:
                     28: check_sysctl() {
                     29:        echo "${1} = ${2}" >expout
                     30:        atf_check "sysctl ${1}" 0 expout null
                     31: }
                     32:
                     33: atf_test_case plain
                     34: plain_head() {
                     35:        atf_set "descr" "Test load without arguments"
                     36:        atf_set "require.user" "root"
                     37: }
                     38: plain_body() {
                     39:        cat >experr <<EOF
                     40: modload: No such file or directory
                     41: EOF
                     42:        atf_check "modload non-existent.o" 1 null experr
                     43:
1.1.6.1 ! yamt       44:        atf_check "modload $(atf_get_srcdir)/k_helper.kmod" 0 null null
1.1       jmmv       45:        check_sysctl vendor.k_helper.present 1
                     46:        check_sysctl vendor.k_helper.prop_int_ok 0
                     47:        check_sysctl vendor.k_helper.prop_str_ok 0
                     48:        atf_check "modunload k_helper" 0 null null
                     49: }
                     50: plain_cleanup() {
                     51:        modunload k_helper >/dev/null 2>&1
                     52: }
                     53:
                     54: atf_test_case bflag
                     55: bflag_head() {
                     56:        atf_set "descr" "Test the -b flag"
                     57:        atf_set "require.user" "root"
                     58: }
                     59: bflag_body() {
                     60:        echo "Checking error conditions"
                     61:
1.1.6.1 ! yamt       62:        atf_check "modload -b foo k_helper.kmod" 1 null stderr
1.1       jmmv       63:        atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
                     64:
1.1.6.1 ! yamt       65:        atf_check "modload -b foo= k_helper.kmod" 1 null stderr
1.1       jmmv       66:        atf_check "grep 'Invalid boolean value' stderr" 0 ignore null
                     67:
1.1.6.1 ! yamt       68:        atf_check "modload -b foo=bar k_helper.kmod" 1 null stderr
1.1       jmmv       69:        atf_check "grep 'Invalid boolean value.*bar' stderr" 0 ignore null
                     70:
1.1.6.1 ! yamt       71:        atf_check "modload -b foo=falsea k_helper.kmod" 1 null stderr
1.1       jmmv       72:        atf_check "grep 'Invalid boolean value.*falsea' stderr" 0 ignore null
                     73:
1.1.6.1 ! yamt       74:        atf_check "modload -b foo=truea k_helper.kmod" 1 null stderr
1.1       jmmv       75:        atf_check "grep 'Invalid boolean value.*truea' stderr" 0 ignore null
                     76:
                     77:        # TODO Once sysctl(8) supports CTLTYPE_BOOL nodes.
                     78:        #echo "Checking valid values"
                     79: }
                     80: bflag_cleanup() {
                     81:        modunload k_helper >/dev/null 2>&1
                     82: }
                     83:
                     84: atf_test_case iflag
                     85: iflag_head() {
                     86:        atf_set "descr" "Test the -i flag"
                     87:        atf_set "require.user" "root"
                     88: }
                     89: iflag_body() {
                     90:        echo "Checking error conditions"
                     91:
1.1.6.1 ! yamt       92:        atf_check "modload -i foo k_helper.kmod" 1 null stderr
1.1       jmmv       93:        atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
                     94:
1.1.6.1 ! yamt       95:        atf_check "modload -i foo= k_helper.kmod" 1 null stderr
1.1       jmmv       96:        atf_check "grep 'Invalid integer value' stderr" 0 ignore null
                     97:
1.1.6.1 ! yamt       98:        atf_check "modload -i foo=bar k_helper.kmod" 1 null stderr
1.1       jmmv       99:        atf_check "grep 'Invalid integer value.*bar' stderr" 0 ignore null
                    100:
1.1.6.1 ! yamt      101:        atf_check "modload -i foo=123a k_helper.kmod" 1 null stderr
1.1       jmmv      102:        atf_check "grep 'Invalid integer value.*123a' stderr" 0 ignore null
                    103:
                    104:        echo "Checking valid values"
                    105:
                    106:        for v in 5 10; do
                    107:                atf_check "modload -i prop_int='${v}' \
1.1.6.1 ! yamt      108:                           $(atf_get_srcdir)/k_helper.kmod" 0 null null
1.1       jmmv      109:                check_sysctl vendor.k_helper.prop_int_ok 1
                    110:                check_sysctl vendor.k_helper.prop_int_val "${v}"
                    111:                atf_check "modunload k_helper" 0 null null
                    112:        done
                    113: }
                    114: iflag_cleanup() {
                    115:        modunload k_helper >/dev/null 2>&1
                    116: }
                    117:
                    118: atf_test_case sflag
                    119: sflag_head() {
                    120:        atf_set "descr" "Test the -s flag"
                    121:        atf_set "require.user" "root"
                    122: }
                    123: sflag_body() {
                    124:        echo "Checking error conditions"
                    125:
1.1.6.1 ! yamt      126:        atf_check "modload -s foo k_helper.kmod" 1 null stderr
1.1       jmmv      127:        atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
                    128:
                    129:        echo "Checking valid values"
                    130:
                    131:        for v in '1st string' '2nd string'; do
                    132:                atf_check "modload -s prop_str='${v}' \
1.1.6.1 ! yamt      133:                           $(atf_get_srcdir)/k_helper.kmod" 0 null null
1.1       jmmv      134:                check_sysctl vendor.k_helper.prop_str_ok 1
                    135:                check_sysctl vendor.k_helper.prop_str_val "${v}"
                    136:                atf_check "modunload k_helper" 0 null null
                    137:        done
                    138: }
                    139: sflag_cleanup() {
                    140:        modunload k_helper >/dev/null 2>&1
                    141: }
                    142:
                    143: atf_init_test_cases()
                    144: {
                    145:        atf_add_test_case plain
                    146:        atf_add_test_case bflag
                    147:        atf_add_test_case iflag
                    148:        atf_add_test_case sflag
                    149: }

CVSweb <webmaster@jp.NetBSD.org>