41ce5e5a6691d2d89d5b2bc3d09df92261a28ead
[libguestfs.git] / fish / test-upload-to-dir.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2011 Red Hat 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 2 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, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 # If you used the guestfish command 'upload' and accidentally set the
20 # target to a directory instead of the full filename, then previously
21 # libguestfs would hang.  It should return an error instead.
22
23 set -e
24
25 rm -f test1.img test.out
26
27 if ../fish/guestfish -N fs -m /dev/sda1 upload ../images/test.iso / 2>test.out
28 then
29   echo "$0: expecting guestfish to return an error"
30   exit 1
31 fi
32
33 if ! grep -q "upload: /: Is a directory" test.out; then
34   echo "$0: unexpected error message from guestfish"
35   cat test.out
36   exit 1
37 fi
38
39 rm -f test1.img test.out