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 19TST_CLEANUP=cleanup 20TST_TESTFUNC=do_test 21TST_NEEDS_ROOT=1 22TST_NEEDS_CMDS="rmmod insmod" 23TST_NEEDS_MODULE="ltp_insmod01.ko" 24. tst_test.sh 25 26inserted=0 27 28cleanup() 29{ 30 if [ $inserted -ne 0 ]; then 31 tst_res TINFO "running rmmod ltp_insmod01" 32 rmmod ltp_insmod01 33 if [ $? -ne 0 ]; then 34 tst_res TWARN "failed to rmmod ltp_insmod01" 35 fi 36 inserted=0 37 fi 38} 39 40do_test() 41{ 42 insmod "$TST_MODPATH" 43 if [ $? -ne 0 ]; then 44 tst_res TFAIL "insmod failed" 45 return 46 fi 47 inserted=1 48 49 grep -q ltp_insmod01 /proc/modules 50 if [ $? -ne 0 ]; then 51 tst_res TFAIL "ltp_insmod01 not found in /proc/modules" 52 return 53 fi 54 55 cleanup 56 57 tst_res TPASS "insmod passed" 58} 59 60tst_run 61