Path: blob/main/tests/sys/geom/class/virstor/virstor_test.sh
39638 views
#1# Copyright (c) 2024 Dell Inc. or its subsidiaries. All Rights Reserved.2#3# SPDX-License-Identifier: BSD-2-Clause4#56. $(atf_get_srcdir)/conf.sh78atf_test_case basic cleanup9basic_head()10{11atf_set "descr" "geom virstor basic functional test"12atf_set "require.user" "root"13}14basic_body()15{16geom_atf_test_setup17# Choose a virstor device name18gvirstor_dev_setup name1920# Create an md backing device and initialize it with junk21psecsize=51222attach_md md -t swap -S $psecsize -s 5M || atf_fail "attach_md"23jot -b uninitialized 0 | dd status=none of=/dev/$md 2> /dev/null2425# Create a virstor device26vsizemb=6427vsize=$((vsizemb * 1024 * 1024))28atf_check -o ignore -e ignore \29gvirstor label -v -s ${vsizemb}M -m 512 $name /dev/$md30devwait31vdev="/dev/$class/$name"3233ssize=$(diskinfo $vdev | awk '{print $2}')34atf_check_equal $psecsize $ssize3536size=$(diskinfo $vdev | awk '{print $3}')37atf_check_equal $vsize $size3839# Write the first and last sectors of the virtual address space40hasha=$(jot -b a 0 | head -c $ssize | sha1)41hashz=$(jot -b z 0 | head -c $ssize | sha1)42zsector=$((vsize / ssize - 1))43jot -b a 0 | dd status=none of=$vdev bs=$ssize count=1 conv=notrunc44jot -b z 0 | dd status=none of=$vdev bs=$ssize count=1 conv=notrunc \45seek=$zsector4647# Read back and compare48hashx=$(dd status=none if=$vdev bs=$ssize count=1 | sha1)49atf_check_equal $hasha $hashx50hashx=$(dd status=none if=$vdev bs=$ssize count=1 skip=$zsector | sha1)51atf_check_equal $hashz $hashx5253# Destroy, then retaste and reload54atf_check -o ignore gvirstor destroy $name55true > /dev/$md56devwait5758# Read back and compare59hashx=$(dd status=none if=$vdev bs=$ssize count=1 | sha1)60atf_check_equal $hasha $hashx61hashx=$(dd status=none if=$vdev bs=$ssize count=1 skip=$zsector | sha1)62atf_check_equal $hashz $hashx63}64basic_cleanup()65{66gvirstor_test_cleanup67}6869atf_init_test_cases()70{71atf_add_test_case basic72}737475