/
githubmirror
/
parted
Обзор
Документация
Войти
/
githubmirror
/
parted
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.8.7
tests/t0000-basic.sh
99 строк
3 KB
Jim Meyering
Rewrite integration tests to use a new framework (git's).
08 май 2007, 01:01
08 май 2007, 01:01
faca3cb
Код
Авторство
О чём код?
#!/bin/sh # Ensure that a simple command using -s succeeds with no prompt # Copyright (C) 2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. ../parted/parted --version > /dev/null 2>&1 if test $? != 0; then echo >&2 'You have not built parted yet.' exit 1 fi test_description='Test the very basics part #1.' . $srcdir/test-lib.sh # FIXME: is id -u portable enough? uid=`id -u` || uid=1 # create a file of size N bytes N=1M dev=loop-file test_expect_success \ 'create the test file' \ 'dd if=/dev/zero of=$dev bs=$N count=1 2> /dev/null' test_expect_success \ 'run parted -s FILE mklabel msdos' \ 'parted -s $dev mklabel msdos > out 2>&1' test_expect_success 'expect no output' '$compare out /dev/null' # ---------------------------------------------- # Now, ensure that a simple mklabel command succeeds. # Since there's no -s option, there are prompts -- sometimes. test_expect_success \ 'erase the left-over label' \ 'dd if=/dev/zero of=$dev bs=$N count=1 2> /dev/null' # First iteration works with no prompting, since there is no preexisting label. test_expect_success \ 'run parted mklabel (without -s) on a blank disk' \ 'parted $dev mklabel msdos > out 2>&1' warning_msg='WARNING: You are not superuser. Watch out for permissions.' test_expect_success \ 'create expected output file' \ 'test "$uid" = 0 && : > exp || echo "$warning_msg" > exp' test_expect_success \ 'check its "interactive" output' \ '$compare out exp 1>&2' test_expect_success 'create interactive input' 'printf "y\n\n" > in' # Now that there's a label, rerunning the same command is interactive. test_expect_success \ 'rerun that same command, but now with a preexisting label' \ 'parted ---pretend-input-tty $dev mklabel msdos < in > o2 2>&1' # Transform the actual output, to avoid spurious differences when # $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity. test_expect_success \ 'normalize the actual output' \ 'sed "s,on /.*/$dev,on DEVICE,;s, * ,,;s, $,," o2 > out' # Create expected output file. fail=0 { test "$uid" = 0 && : > exp || echo "$warning_msg" > exp; } || fail=1 cat <<EOF >> exp || fail=1 Warning: The existing disk label on DEVICE will be destroyed and all\ data on this disk will be lost. Do you want to continue? Yes/No? y New disk label type? [msdos]? EOF test_expect_success \ 'create expected output file' \ 'test $fail = 0' test_expect_success \ 'check its output -- slightly different here, due to prompts' \ '$compare out exp' test_done