#!/bin/bash - # libguestfs # Copyright (C) 2011 Red Hat 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. # Test guestfish md-create and md-detail commands. set -e rm -f md-test1.img md-test2.img md-test3.img md-test4.img ../../fish/guestfish < md-detail.out sed 's/:\s*/=/' md-detail.out > md-detail.out.sh . md-detail.out.sh rm -f md-detail.out.sh error=0 case "$name" in *:r1t1) [ "$level" == "raid1" ] || error=1 [ "$devices" == "2" ] || error=1 ;; *:r1t2) [ "$level" == "raid1" ] || error=1 [ "$devices" == "2" ] || error=1 ;; *:r5t1) [ "$level" == "raid5" ] || error=1 [ "$devices" == "4" ] || error=1 ;; *:r5t2) [ "$level" == "raid5" ] || error=1 [ "$devices" == "3" ] || error=1 ;; *:r5t3) [ "$level" == "raid5" ] || error=1 [ "$devices" == "2" ] || error=1 ;; *) error=1 esac [[ "$uuid" =~ ([0-9a-f]{8}:){3}[0-9a-f]{8} ]] || error=1 [ ! -z "$metadata" ] || error=1 if [ "$error" == "1" ]; then echo "$0: Unexpected output from md-detail for device $md" cat md-detail.out ../../fish/guestfish --remote exit exit 1 fi done ../../fish/guestfish --remote exit eval `../../fish/guestfish --listen` ../../fish/guestfish --remote add-ro md-test1.img ../../fish/guestfish --remote add-ro md-test2.img ../../fish/guestfish --remote add-ro md-test3.img ../../fish/guestfish --remote add-ro md-test4.img ../../fish/guestfish --remote run for md in `../../fish/guestfish --remote list-md-devices`; do ../../fish/guestfish --remote md-stop "$md" done ../../fish/guestfish --remote exit rm -f md-detail.out md-test1.img md-test2.img md-test3.img md-test4.img