1#!/usr/bin/env bash 2 3# This script runs a given executable using qemu, and compare its standard 4# output with an expected plugin output. 5# Each line of output is searched (as a regexp) in the expected plugin output. 6 7set -euo pipefail 8 9die() 10{ 11 echo "$@" 1>&2 12 exit 1 13} 14 15check() 16{ 17 file=$1 18 pattern=$2 19 grep "$pattern" "$file" > /dev/null || die "\"$pattern\" not found in $file" 20} 21 22[ $# -eq 3 ] || die "usage: qemu_bin exe plugin_out_file" 23 24qemu_bin=$1; shift 25exe=$1;shift 26plugin_out=$1; shift 27 28expected() 29{ 30 $qemu_bin $exe || 31 die "running $exe failed" 32} 33 34expected | while read line; do 35 check "$plugin_out" "$line" 36done 37