• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#
18
19TCID=lsmod01
20TST_TOTAL=1
21. test.sh
22
23setup()
24{
25	tst_check_cmds lsmod
26
27	tst_tmpdir
28
29	TST_CLEANUP="cleanup"
30}
31
32cleanup()
33{
34	tst_rmdir
35}
36
37lsmod_test()
38{
39	lsmod >temp 2>&1
40	if [ $? -ne 0 ]; then
41		tst_resm TFAIL "'lsmod' failed."
42		cat temp
43		return
44	fi
45
46	awk '!/Module/{print $1, $2, $3}' temp |sort >temp1
47
48	awk '{print $1, $2, $3}' /proc/modules |sort >temp2
49
50	diff temp1 temp2 >temp3
51	if [ $? -ne 0 ]; then
52		tst_resm TFAIL "lsmod output different from /proc/modules."
53		cat temp3
54		return
55	fi
56
57	tst_resm TPASS "'lsmod' passed."
58}
59
60setup
61
62lsmod_test
63
64tst_exit
65