qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

288 (2446B)


      1 #!/usr/bin/env bash
      2 # group: quick
      3 #
      4 # qemu-img measure tests for LUKS images
      5 #
      6 # Copyright (C) 2020 Red Hat, Inc.
      7 #
      8 # This program is free software; you can redistribute it and/or modify
      9 # it under the terms of the GNU General Public License as published by
     10 # the Free Software Foundation; either version 2 of the License, or
     11 # (at your option) any later version.
     12 #
     13 # This program is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 # GNU General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU General Public License
     19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     20 #
     21 
     22 # creator
     23 owner=stefanha@redhat.com
     24 
     25 seq=`basename $0`
     26 echo "QA output created by $seq"
     27 
     28 status=1    # failure is the default!
     29 
     30 _cleanup()
     31 {
     32     _cleanup_test_img
     33     rm -f "$TEST_IMG.converted"
     34 }
     35 trap "_cleanup; exit \$status" 0 1 2 3 15
     36 
     37 # get standard environment, filters and checks
     38 . ./common.rc
     39 . ./common.filter
     40 . ./common.pattern
     41 
     42 _supported_fmt luks
     43 _supported_proto file
     44 _supported_os Linux
     45 
     46 SECRET=secret,id=sec0,data=passphrase
     47 
     48 echo "== measure 1G image file =="
     49 echo
     50 
     51 $QEMU_IMG measure --object "$SECRET" \
     52 	          -O "$IMGFMT" \
     53 		  -o key-secret=sec0,iter-time=10 \
     54 		  --size 1G
     55 
     56 echo
     57 echo "== create 1G image file (size should be no greater than measured) =="
     58 echo
     59 
     60 _make_test_img 1G
     61 stat -c "image file size in bytes: %s" "$TEST_IMG_FILE"
     62 
     63 echo
     64 echo "== modified 1G image file (size should be no greater than measured) =="
     65 echo
     66 
     67 $QEMU_IO --object "$SECRET" --image-opts "$TEST_IMG" -c "write -P 0x51 0x10000 0x400" | _filter_qemu_io | _filter_testdir
     68 stat -c "image file size in bytes: %s" "$TEST_IMG_FILE"
     69 
     70 echo
     71 echo "== measure preallocation=falloc 1G image file =="
     72 echo
     73 
     74 $QEMU_IMG measure --object "$SECRET" \
     75 	          -O "$IMGFMT" \
     76 		  -o key-secret=sec0,iter-time=10,preallocation=falloc \
     77 		  --size 1G
     78 
     79 echo
     80 echo "== measure with input image file =="
     81 echo
     82 
     83 IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img 1G | _filter_imgfmt
     84 QEMU_IO_OPTIONS= IMGOPTSSYNTAX= $QEMU_IO -f raw -c "write -P 0x51 0x10000 0x400" "$TEST_IMG_FILE" | _filter_qemu_io | _filter_testdir
     85 $QEMU_IMG measure --object "$SECRET" \
     86 	          -O "$IMGFMT" \
     87 		  -o key-secret=sec0,iter-time=10 \
     88 		  -f raw \
     89 		  "$TEST_IMG_FILE"
     90 
     91 # success, all done
     92 echo "*** done"
     93 rm -f $seq.full
     94 status=0