1#!/bin/sh 2# 3# Copyright (c) 2015 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 lsmod command. 17# 18TST_ID="lsmod01" 19TST_TESTFUNC=lsmod_test 20TST_NEEDS_TMPDIR=1 21TST_NEEDS_CMDS="lsmod" 22. tst_test.sh 23 24lsmod_test() 25{ 26 lsmod_output=$(lsmod | awk '!/Module/{print $1, $2, $3}' | sort) 27 if [ -z "$lsmod_output" ]; then 28 tst_res TFAIL "Failed to parse the output from lsmod" 29 return 30 fi 31 32 modules_output=$(awk '{print $1, $2, $3}' /proc/modules | sort) 33 if [ -z "$modules_output" ]; then 34 tst_res TFAIL "Failed to parse /proc/modules" 35 return 36 fi 37 38 if [ "$lsmod_output" != "$modules_output" ]; then 39 tst_res TFAIL "lsmod output different from /proc/modules." 40 41 echo "$lsmod_output" > temp1 42 echo "$modules_output" > temp2 43 diff temp1 temp2 44 45 return 46 fi 47 48 tst_res TPASS "'lsmod' passed." 49} 50 51tst_run 52