OSDN Git Service

tests: t9030 wait for partition removal
[android-x86/external-parted.git] / tests / t9030-align-check.sh
1 #!/bin/sh
2 # exercise the align-check command
3
4 # Copyright (C) 2009-2011 Free Software Foundation, Inc.
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 3 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 the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
20 ss=$sector_size_
21
22 require_root_
23 require_scsi_debug_module_
24
25 grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
26   skip_ 'this system lacks a new-enough libblkid'
27
28 # create memory-backed device
29 scsi_debug_setup_ physblk_exp=3 lowest_aligned=7 sector_size=$ss > dev-name ||
30   skip_ 'failed to create scsi_debug device'
31 scsi_dev=$(cat dev-name)
32 p1=${scsi_dev}1
33
34 parted -s $scsi_dev mklabel gpt || fail=1
35
36 i=60
37 while :; do
38   parted -s $scsi_dev mkpart p1 ext2 ${i}s 800s || fail=1
39   wait_for_dev_to_appear_ $p1 || fail=1
40   parted -s $scsi_dev align-check min 1 > out 2>&1
41   result=$?
42
43   test $(expr $i % 8) = 7 && exp_result=0 || exp_result=1
44   test $result = $exp_result || fail=1
45   compare out /dev/null || fail=1
46
47   parted -s $scsi_dev rm 1
48   i=$(expr $i + 1)
49   test $i = 70 && break
50
51   # Wait up to 10s for the partition file to disappear.
52   wait_for_dev_to_disappear_ $p1 10 || { fail=1; warn $p1 failed to disappear; }
53 done
54
55 Exit $fail