4 ##############################################################
6 # Copyright (c) International Business Machines Corp., 2003
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 # the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 # USAGE : sysfs.sh [ -k <kernel_module> ]
25 # DESCRIPTION : A script that will test sysfs on Linux system.
26 # REQUIREMENTS: CONFIG_DUMMY must have been used to build kernel, and the
27 # dummy network module must exist.
30 # 06/24/2003 Prakash Narayana (prakashn@us.ibm.com)
32 # CODE COVERAGE: 31.3% - fs/sysfs (Total Coverage)
34 # 0.0% - fs/sysfs/bin.c
35 # 61.8% - fs/sysfs/dir.c
36 # 27.5% - fs/sysfs/file.c
37 # 40.4% - fs/sysfs/inode.c
38 # 41.2% - fs/sysfs/mount.c
39 # 58.1% - fs/sysfs/symlink.c
41 ##############################################################
44 MNT_POINT
="/tmp/sysfs_$$"
46 KERNEL_NAME
=`uname -a | awk ' { print $3 } '`
47 KERN_MODULE
=/lib
/modules
/$KERNEL_NAME/kernel
/drivers
/net
/dummy.ko
48 USAGE
="$0 [ -k <kernel_module> ]"
51 ##############################################################
53 # Make sure that uid=root is running this script.
54 # Validate the command line arguments.
56 ##############################################################
60 echo "FAILED: Must have root access to execute this script"
67 k
) KERN_MODULE
=$OPTARG ;;
68 \?) echo $USAGE ; exit 1 ;;
72 if [ -z "$KERN_MODULE" ]
75 echo "FAILED: kernel module to insert not specified"
79 # Here is the code coverage for fs/sysfs
80 # insmod/rmmod net/dummy.ko creates and deletes a directory
82 # In kernel, 2.5.73 or higher, insert/delete base/firmware_class.ko
84 mkdir
-p -m 777 $MNT_POINT
85 mount
-t sysfs sysfs
$MNT_POINT
88 echo "FAILED: sysfs mount failed"
97 echo "FAILED: insmod failed"
106 echo "FAILED: rmmod failed"
111 #######################################################
113 # Just before exit, perform the cleanup.
115 #######################################################
120 echo "PASSED: $0 passed!"