Guangwen Feng | b3494f1 | 2016-04-22 14:28:29 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2016 Fujitsu Ltd. |
| 4 | # Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com> |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; either version 2 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 14 | # the GNU General Public License for more details. |
| 15 | # |
| 16 | # Test the basic functionality of insmod command. |
| 17 | # |
| 18 | |
| 19 | TCID=insmod01 |
| 20 | TST_TOTAL=1 |
| 21 | . test.sh |
| 22 | |
| 23 | setup() |
| 24 | { |
| 25 | tst_require_root |
| 26 | |
| 27 | tst_check_cmds rmmod insmod |
| 28 | |
| 29 | tst_module_exists ltp_insmod01.ko |
| 30 | |
| 31 | inserted=0 |
| 32 | |
| 33 | TST_CLEANUP="cleanup" |
| 34 | } |
| 35 | |
| 36 | cleanup() |
| 37 | { |
| 38 | if [ $inserted -ne 0 ]; then |
| 39 | echo "about to rmmod ltp_insmod01" |
| 40 | rmmod ltp_insmod01 |
| 41 | if [ $? -ne 0 ]; then |
| 42 | echo "failed to rmmod ltp_insmod01" |
| 43 | fi |
| 44 | fi |
| 45 | } |
| 46 | |
| 47 | insmod_test() |
| 48 | { |
| 49 | insmod "$TST_MODPATH" |
| 50 | if [ $? -ne 0 ]; then |
| 51 | tst_resm TFAIL "'insmod' failed." |
| 52 | return |
| 53 | fi |
| 54 | inserted=1 |
| 55 | |
| 56 | grep -q ltp_insmod01 /proc/modules |
| 57 | |
| 58 | if [ $? -ne 0 ]; then |
| 59 | tst_resm TINFO "ltp_insmod01 not found in /proc/modules" |
| 60 | tst_resm TFAIL "'insmod' failed, not expected." |
| 61 | return |
| 62 | fi |
| 63 | |
| 64 | tst_resm TPASS "'insmod' passed." |
| 65 | } |
| 66 | |
| 67 | setup |
| 68 | |
| 69 | insmod_test |
| 70 | |
| 71 | tst_exit |