OSDN Git Service

tests: make t8000-loop.sh stop immediately upon failiure
[android-x86/external-parted.git] / tests / t8000-loop.sh
1 #!/bin/sh
2
3 # Copyright (C) 2008-2009 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 test_description='Test usage of loop devices'
19
20 privileges_required_=1
21 device_mapper_required_=1
22
23 : ${srcdir=.}
24 . $srcdir/test-lib.sh
25
26 # Stop immediately, upon failure.
27 # Otherwise, subsequent tests would fail,
28 # too and just obscure the earlier failure.
29 immediate=1
30
31 cleanup_() {
32     test -n "$d1" && losetup -d "$d1"
33     rm -f "$f1";
34 }
35
36 emit_expected_diagnostic()
37 {
38     printf '%s\n' \
39       'Error: Error informing the kernel about modifications to partiti' \
40       'Warning: The kernel was unable to re-read the partition table on'
41 }
42
43 test_expect_success \
44     "setup: create loop devices" \
45     'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1")'
46
47 test_expect_success \
48     'run parted -s "$d1" mklabel msdos' \
49     'parted -s $d1 mklabel msdos > out 2>&1'
50 test_expect_success 'check for empty output' 'compare out /dev/null'
51
52 test_expect_failure \
53     'run parted -s "$d1" mkpart primary 1 10' \
54     'parted -s $d1 mkpart primary 1 10 > out 2>&1'
55 test_expect_success 'prepare actual/expected output' \
56     'emit_expected_diagnostic > exp &&
57      cut -b1-64 out > k && mv k out'
58 test_expect_success 'check for expected output' 'compare exp out'
59
60 test_done