import source from 3.0
[external/parted.git] / tests / t0001-tiny.sh
1 #!/bin/sh
2 # operate on a very small (1-sector) "disk"
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
21 ss=$sector_size_
22 dev=loop-file
23
24 for opt in '' -s; do
25
26   dd if=/dev/null of=$dev bs=1 seek=$ss || framework_failure
27
28   # create an msdos partition table:
29   # Before parted-2.1, without -s, this would fail with a bogus diagnostic:
30   # Error: Success during read on .../tests/loop-file
31   # Retry/Ignore/Cancel? ^C
32   parted $opt $dev mklabel msdos ---pretend-input-tty </dev/null > out 2>&1 \
33       || fail=1
34   # expect no output
35   sed 's/.*WARNING: You are not superuser.*//;/^$/d' out > k && mv k out \
36       || fail=1
37   # When run as root, there are just curses-related control chars. Remove them.
38   sed 's/^.\{1,12\}$//;/^$/d' out > k && mv k out \
39       || fail=1
40   compare out /dev/null || fail=1
41
42   parted -s $dev p || fail=1
43   rm -f $dev
44
45 done
46
47 Exit $fail