aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-04-18 13:09:10 -0700
committerEric Biggers <ebiggers@google.com>2018-04-18 13:09:10 -0700
commit681bd1dbc53d214d5c5ff0863bc1ed5647249101 (patch)
tree5012eed4ef0627d8cb2e41bc528687ca68a79fb5
parentf5c61adf568ba2cbe58ee571a7bb550708b0cfcd (diff)
downloadxfstests-681bd1dbc53d214d5c5ff0863bc1ed5647249101.tar.gz
generic: test that fs-verity is using the correct measurement values
Signed-off-by: Eric Biggers <ebiggers@google.com>
-rwxr-xr-xtests/generic/90473
-rw-r--r--tests/generic/904.out12
-rw-r--r--tests/generic/group1
3 files changed, 86 insertions, 0 deletions
diff --git a/tests/generic/904 b/tests/generic/904
new file mode 100755
index 0000000000..4cc064a20a
--- /dev/null
+++ b/tests/generic/904
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test generic/904
+#
+# Test that fs-verity is using the correct measurement values
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2018 Google, Inc. All Rights Reserved.
+#
+# Author: Eric Biggers <ebiggers@google.com>
+#
+# 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.
+#
+# This program is distributed in the hope that it would 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 the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/verity
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch_verity
+
+_scratch_mkfs_verity &>> $seqres.full
+_scratch_mount
+fsv_orig_file=$SCRATCH_MNT/file
+fsv_file=$SCRATCH_MNT/file.fsv
+
+_fsv_begin_subtest "Check for expected measurement values"
+for size in 4096 65536 100000000; do
+ head -c $size /dev/zero > $fsv_orig_file
+ for arg in '' '--hash=sha256' '--hash=crc32'; do
+ measurement=$(_fsv_setup_file $arg $fsv_orig_file $fsv_file)
+ echo "size=$size arg=$arg measurement=$measurement"
+ $FSVERITY_PROG enable $fsv_file
+ $FSVERITY_PROG set_measurement $arg $fsv_file $measurement
+ cmp $fsv_orig_file $fsv_file
+ rm -f $fsv_file
+ done
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/904.out b/tests/generic/904.out
new file mode 100644
index 0000000000..66d8f1f892
--- /dev/null
+++ b/tests/generic/904.out
@@ -0,0 +1,12 @@
+QA output created by 904
+
+# Check for expected measurement values
+size=4096 arg= measurement=90f3acf6690d725c27b6f843053771d3c638583be93f7f4cdf447c5f485886ee
+size=4096 arg=--hash=sha256 measurement=90f3acf6690d725c27b6f843053771d3c638583be93f7f4cdf447c5f485886ee
+size=4096 arg=--hash=crc32 measurement=587cac5a
+size=65536 arg= measurement=ab1a9a5149c44d32d645778812cbfbb77b7d3a3b72a58c55e7d2f82fb4025fab
+size=65536 arg=--hash=sha256 measurement=ab1a9a5149c44d32d645778812cbfbb77b7d3a3b72a58c55e7d2f82fb4025fab
+size=65536 arg=--hash=crc32 measurement=d26e6f44
+size=100000000 arg= measurement=82cda3e5ec252ded0279424eb4bb920fadd62e023b83022e99cd9e90a419b043
+size=100000000 arg=--hash=sha256 measurement=82cda3e5ec252ded0279424eb4bb920fadd62e023b83022e99cd9e90a419b043
+size=100000000 arg=--hash=crc32 measurement=64a4c064
diff --git a/tests/generic/group b/tests/generic/group
index 2f29c15485..09f32e8f22 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -490,3 +490,4 @@
901 auto quick verity
902 auto quick verity
903 auto quick verity
+904 auto quick verity