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 : autofs4.sh <disk_partition>
25 # DESCRIPTION : A script that will test autofs on Linux system.
27 # 1) System with a floppy device with a floppy disk in it.
28 # 2) A spare (scratch) disk partition of 100MB or larger.
31 # 06/11/2003 Prakash Narayana (prakashn@us.ibm.com)
33 # CODE COVERAGE: 26.8% - fs/autofs4 (Total Coverage)
35 # 24.1% - fs/autofs4/expire.c
36 # 33.3% - fs/autofs4/init.c
37 # 24.0% - fs/autofs4/inode.c
38 # 29.9% - fs/autofs4/root.c
39 # 0.0% - fs/autofs4/symlink.c
40 # 29.1% - fs/autofs4/waitq.c
42 ##############################################################
45 ##############################################################
47 # Make sure that uid=root is running this script.
48 # Validate the command line argument as a block special device.
49 # Make sure that autofs package has been installed.
50 # Make sure that autofs module is built into the kernel or loaded.
52 ##############################################################
56 echo "FAILED: Must have root access to execute this script"
62 echo "FAILED: Usage $0 <disk_partition>"
66 if [ ! -b $disk_partition ]
68 echo "FAILED: Usage $0 <block special disk_partition>"
71 mkfs
-t ext2
$disk_partition 2>&1 > /dev
/null
74 rpm
-q -a |
grep autofs
2>&1 > /dev
/null
77 echo "FAILED: autofs package is not installed"
81 grep autofs
/proc
/filesystems
2>&1 > /dev
/null
84 echo "FAILED: autofs module is not built into the kernel or loaded"
89 ##############################################################
91 # Pick the floppy device name from /etc/fstab
92 # Format (mkfs -t ext2) the floppy to ext2 file system
93 # Create the /etc/auto.master
94 # Create the /etc/auto.media
95 # Create /AUTOFS directory.
97 ##############################################################
99 floppy_dev
=`grep floppy /etc/fstab | awk '{print $1}'`
101 if [ $floppy_dev != "" ]
103 /sbin
/mkfs
-t ext2
$floppy_dev 2>&1 > /dev
/null
106 echo "FAILED: mkfs -t ext2 $floppy_dev failed"
116 echo "/AUTOFS/MEDIA /etc/auto.media " > /etc
/auto.master
117 echo "floppy -fstype=ext2 :$floppy_dev" > /etc
/auto.media
120 ##############################################################
122 # Verify that "/etc/init.d/autofs start|restart|stop|status|reload"
125 # If fails, cleanup and exit.
127 ##############################################################
129 /etc
/init.d
/autofs start
2>&1 > /dev
/null
132 rm -rf /etc
/auto.master
/etc
/auto.media
/AUTOFS
133 echo "FAILED: "/etc
/init.d
/autofs start
""
136 echo "Resuming test, please wait..."
139 /etc
/init.d
/autofs stop
2>&1 > /dev
/null
142 rm -rf /etc
/auto.master
/etc
/auto.media
/AUTOFS
143 echo "FAILED: "/etc
/init.d
/autofs stop
""
146 /etc
/init.d
/autofs start
2>&1 > /dev
/null
150 /etc
/init.d
/autofs restart
2>&1 > /dev
/null
153 /etc
/init.d
/autofs stop
2>&1 > /dev
/null
154 rm -rf /etc
/auto.master
/etc
/auto.media
/AUTOFS
155 echo "FAILED: "/etc
/init.d
/autofs restart
""
158 echo "Resuming test, please wait..."
161 /etc
/init.d
/autofs status
2>&1 > /dev
/null
164 /etc
/init.d
/autofs stop
2>&1 > /dev
/null
165 rm -rf /etc
/auto.master
/etc
/auto.media
/AUTOFS
166 echo "FAILED: "/etc
/init.d
/autofs status
""
170 /etc
/init.d
/autofs reload
2>&1 > /dev
/null
173 /etc
/init.d
/autofs stop
2>&1 > /dev
/null
174 rm -rf /etc
/auto.master
/etc
/auto.media
/AUTOFS
175 echo "FAILED: "/etc
/init.d
/autofs reload
""
180 ##############################################################
182 # Tryout some error code paths by:
183 # (1) Write into automount directory
184 # (2) Remove automount parent directory
185 # (3) Automount the floppy disk
186 # (4) Hit automounter timeout by sleep 60; then wakeup with error
189 ##############################################################
191 mkdir
/AUTOFS
/MEDIA
/mydir
2>&1 > /dev
/null
192 rm -rf /AUTOFS
2>&1 > /dev
/null
194 mkdir
/AUTOFS
/MEDIA
/floppy
/test
195 cp /etc
/auto.master
/etc
/auto.media
/AUTOFS
/MEDIA
/floppy
/test
197 echo "Resuming test, please wait..."
199 mkdir
/AUTOFS
/MEDIA
/mydir
2>&1 > /dev
/null
200 rm -rf /AUTOFS
2>&1 > /dev
/null
203 ##############################################################
205 # Add an entry to the /etc/auto.master and reload.
207 ##############################################################
209 echo "/AUTOFS/DISK /etc/auto.disk " >> /etc
/auto.master
210 echo "disk -fstype=ext2 :$disk_partition " > /etc
/auto.disk
211 /etc
/init.d
/autofs reload
2>&1 > /dev
/null
212 echo "Resuming test, please wait..."
215 mkdir
/AUTOFS
/DISK
/disk
/test
216 cp /etc
/auto.master
/etc
/auto.media
/AUTOFS
/DISK
/disk
/test
218 echo "Resuming test, please wait..."
221 cd /AUTOFS
/DISK
/disk
/test
222 umount
/AUTOFS
/DISK
/disk
/ 2>&1 > /dev
/null
225 /etc
/init.d
/autofs stop
2>&1 > /dev
/null
226 rm -rf /etc
/auto.master
/etc
/auto.media
/etc
/auto.disk
/AUTOFS
227 echo "FAILED: unmounted a busy file system!"
232 umount
/AUTOFS
/DISK
/disk
/ 2>&1 > /dev
/null
235 /etc
/init.d
/autofs stop
2>&1 > /dev
/null
236 rm -rf /etc
/auto.master
/etc
/auto.media
/etc
/auto.disk
/AUTOFS
237 echo "FAILED: Could not unmount automounted file system"
242 # Mount the disk partition somewhere else and then reference automount
243 # point for disk partition.
245 mount
-t ext2
$disk_partition /mnt
/
246 ls -l /AUTOFS
/DISK
/disk
250 #######################################################
252 # Just before exit, stop autofs and cleanup.
254 #######################################################
256 /etc
/init.d
/autofs stop
2>&1 > /dev
/null
257 rm -rf /etc
/auto.master
/etc
/auto.media
/etc
/auto.disk
/AUTOFS
258 echo "PASSED: $0 passed!"