xref: /openbmc/qemu/tests/qemu-iotests/059 (revision f4c129a3)
1ca6cbb65SFam Zheng#!/bin/bash
2ca6cbb65SFam Zheng#
3ca6cbb65SFam Zheng# Test case for vmdk
4ca6cbb65SFam Zheng#
5ca6cbb65SFam Zheng# Copyright (C) 2013 Red Hat, Inc.
6ca6cbb65SFam Zheng#
7ca6cbb65SFam Zheng# This program is free software; you can redistribute it and/or modify
8ca6cbb65SFam Zheng# it under the terms of the GNU General Public License as published by
9ca6cbb65SFam Zheng# the Free Software Foundation; either version 2 of the License, or
10ca6cbb65SFam Zheng# (at your option) any later version.
11ca6cbb65SFam Zheng#
12ca6cbb65SFam Zheng# This program is distributed in the hope that it will be useful,
13ca6cbb65SFam Zheng# but WITHOUT ANY WARRANTY; without even the implied warranty of
14ca6cbb65SFam Zheng# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15ca6cbb65SFam Zheng# GNU General Public License for more details.
16ca6cbb65SFam Zheng#
17ca6cbb65SFam Zheng# You should have received a copy of the GNU General Public License
18ca6cbb65SFam Zheng# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19ca6cbb65SFam Zheng#
20ca6cbb65SFam Zheng
21ca6cbb65SFam Zheng# creator
22ca6cbb65SFam Zhengowner=famz@redhat.com
23ca6cbb65SFam Zheng
24ca6cbb65SFam Zhengseq=`basename $0`
25ca6cbb65SFam Zhengecho "QA output created by $seq"
26ca6cbb65SFam Zheng
27ca6cbb65SFam Zhenghere=`pwd`
28ca6cbb65SFam Zhengtmp=/tmp/$$
29ca6cbb65SFam Zhengstatus=1	# failure is the default!
30ca6cbb65SFam Zheng
31ca6cbb65SFam Zheng_cleanup()
32ca6cbb65SFam Zheng{
33ca6cbb65SFam Zheng	_cleanup_test_img
34ca6cbb65SFam Zheng}
35ca6cbb65SFam Zhengtrap "_cleanup; exit \$status" 0 1 2 3 15
36ca6cbb65SFam Zheng
37ca6cbb65SFam Zheng# get standard environment, filters and checks
38ca6cbb65SFam Zheng. ./common.rc
39ca6cbb65SFam Zheng. ./common.filter
40ca6cbb65SFam Zheng
41ca6cbb65SFam Zheng# This tests vmdk-specific low-level functionality
42ca6cbb65SFam Zheng_supported_fmt vmdk
43ca6cbb65SFam Zheng_supported_proto generic
44ca6cbb65SFam Zheng_supported_os Linux
45ca6cbb65SFam Zheng
462c43e43cSFam Zhengcapacity_offset=16
478aa1331cSFam Zhenggranularity_offset=20
48f8ce0403SFam Zhenggrain_table_size_offset=44
498aa1331cSFam Zheng
508aa1331cSFam Zhengecho
515dd75f9aSFam Zhengecho "=== Testing invalid granularity ==="
528aa1331cSFam Zheng_make_test_img 64M
538aa1331cSFam Zhengpoke_file "$TEST_IMG" "$granularity_offset" "\xff\xff\xff\xff\xff\xff\xff\xff"
54fef9c191SJeff Cody{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
55ca6cbb65SFam Zheng
56f8ce0403SFam Zhengecho
575dd75f9aSFam Zhengecho "=== Testing too big L2 table size ==="
58f8ce0403SFam Zheng_make_test_img 64M
59f8ce0403SFam Zhengpoke_file "$TEST_IMG" "$grain_table_size_offset" "\xff\xff\xff\xff"
60fef9c191SJeff Cody{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
61f8ce0403SFam Zheng
622c43e43cSFam Zhengecho
635dd75f9aSFam Zhengecho "=== Testing too big L1 table size ==="
642c43e43cSFam Zheng_make_test_img 64M
652c43e43cSFam Zhengpoke_file "$TEST_IMG" "$capacity_offset" "\xff\xff\xff\xff"
662c43e43cSFam Zhengpoke_file "$TEST_IMG" "$grain_table_size_offset" "\x01\x00\x00\x00"
67fef9c191SJeff Cody{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
682c43e43cSFam Zheng
692fe2e290SFam Zhengecho
705dd75f9aSFam Zhengecho "=== Testing monolithicFlat creation and opening ==="
712fe2e290SFam ZhengIMGOPTS="subformat=monolithicFlat" _make_test_img 2G
72*f4c129a3SFam Zheng_img_info
732fe2e290SFam Zheng
7452c8d629SFam Zhengecho
7552c8d629SFam Zhengecho "=== Testing monolithicFlat with zeroed_grain ==="
7652c8d629SFam ZhengIMGOPTS="subformat=monolithicFlat,zeroed_grain=on" _make_test_img 2G
7752c8d629SFam Zheng
78ca6cbb65SFam Zheng# success, all done
79ca6cbb65SFam Zhengecho "*** done"
80ca6cbb65SFam Zhengrm -f $seq.full
81ca6cbb65SFam Zhengstatus=0
82