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