3 # Copyright (C) 2010-2011 Red Hat Inc.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 if ../fish/guestfish -a /dev/null run : available "ntfs3g ntfsprogs"; then
29 # Engage in some montecarlo testing of virt-make-fs.
31 if [ "$ntfs_supported" = "yes" ]; then
32 case $((RANDOM % 4)) in
33 0) type="--type=ext2" ;;
34 1) type="--type=ext3" ;;
35 2) type="--type=ext4" ;;
36 3) type="--type=ntfs" ;;
37 # Can't test vfat because we cannot create a tar archive
38 # where files are owned by UID:GID 0:0. As a result, tar
39 # in the appliance fails when trying to change the UID of
40 # the files to some non-zero value (not supported by FAT).
41 # 4) type="--type=vfat" ;;
44 case $((RANDOM % 3)) in
45 0) type="--type=ext2" ;;
46 1) type="--type=ext3" ;;
47 2) type="--type=ext4" ;;
51 case $((RANDOM % 2)) in
52 0) format="--format=raw" ;;
53 1) format="--format=qcow2" ;;
56 case $((RANDOM % 3)) in
57 0) partition="--partition" ;;
58 1) partition="--partition=gpt" ;;
62 case $((RANDOM % 2)) in
64 1) size="--size=+1M" ;;
67 if [ -n "$LIBGUESTFS_DEBUG" ]; then debug=--debug; fi
69 params="$type $format $partition $size $debug"
70 echo "test-virt-make-fs: parameters: $params"
72 rm -f test.file test.tar output.img
74 tarsize=$((RANDOM & 8191))
75 echo "test-virt-make-fs: size of test file: $tarsize KB"
76 dd if=/dev/zero of=test.file bs=1024 count=$tarsize
77 tar -c -f test.tar test.file
80 ./virt-make-fs $params -- test.tar output.img
82 rm test.tar output.img