cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

232 (5842B)


      1#!/usr/bin/env bash
      2# group: quick
      3#
      4# Test for auto-read-only
      5#
      6# Copyright (C) 2018 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
     23owner=kwolf@redhat.com
     24
     25seq=`basename $0`
     26echo "QA output created by $seq"
     27
     28status=1	# failure is the default!
     29
     30_cleanup()
     31{
     32    _cleanup_test_img
     33    for img in "$TEST_IMG".[01234]; do
     34        _rm_test_img "$img"
     35    done
     36}
     37trap "_cleanup; exit \$status" 0 1 2 3 15
     38
     39# get standard environment, filters and checks
     40. ./common.rc
     41. ./common.filter
     42
     43_supported_fmt generic
     44_supported_proto file
     45_supported_os Linux
     46
     47do_run_qemu()
     48{
     49    echo Testing: "$@"
     50    (
     51        if ! test -t 0; then
     52            while read cmd; do
     53                echo $cmd
     54            done
     55        fi
     56        echo quit
     57    ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
     58    echo
     59}
     60
     61run_qemu()
     62{
     63    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
     64        _filter_generated_node_ids | _filter_imgfmt
     65}
     66
     67run_qemu_info_block()
     68{
     69    echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
     70}
     71
     72size=128M
     73
     74_make_test_img $size
     75
     76if [ -n "$TEST_IMG_FILE" ]; then
     77    TEST_IMG=$TEST_IMG_FILE
     78fi
     79
     80chmod a-w $TEST_IMG
     81(echo test > $TEST_IMG) 2>/dev/null && \
     82    _notrun "Readonly attribute is ignored, probably you run this test as" \
     83            "root, which is unsupported."
     84chmod a+w $TEST_IMG
     85
     86echo
     87echo "=== -drive with read-write image: read-only/auto-read-only combinations ==="
     88echo
     89
     90run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
     91run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
     92run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
     93echo
     94run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
     95run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
     96run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
     97echo
     98run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
     99run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
    100run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
    101
    102echo
    103echo "=== -drive with read-only image: read-only/auto-read-only combinations ==="
    104echo
    105
    106chmod a-w $TEST_IMG
    107
    108run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
    109run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
    110run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
    111echo
    112run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
    113run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
    114run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
    115echo
    116run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
    117run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
    118run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
    119
    120echo
    121echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ==="
    122echo
    123
    124chmod a+w $TEST_IMG
    125
    126run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
    127run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
    128run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
    129echo
    130run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
    131run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
    132run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
    133echo
    134run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
    135run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
    136run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
    137
    138echo
    139echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ==="
    140echo
    141
    142chmod a-w $TEST_IMG
    143
    144run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
    145run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
    146run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
    147echo
    148run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
    149run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
    150run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
    151echo
    152run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
    153run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
    154run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
    155
    156# success, all done
    157echo "*** done"
    158rm -f $seq.full
    159status=0