1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2020 Intel Corporation 4# All rights reserved. 5# 6testdir=$(readlink -f "$(dirname "$0")") 7rootdir=$(readlink -f "$testdir/../../") 8source "$testdir/common.sh" 9 10basic_rw() { 11 local native_bs=$1 12 local count size 13 local qds bss 14 15 qds=(1 64) 16 # Generate some bs for tests based on the native_bs 17 for bs in {0..2}; do 18 bss+=($((native_bs << bs))) 19 done 20 21 for bs in "${bss[@]}"; do 22 for qd in "${qds[@]}"; do 23 count=$((0xffff / bs)) 24 count=$((count == 0 ? 1 : count)) 25 size=$((count * bs)) 26 27 gen_bytes "$size" > "$test_file0" 28 29 "${DD_APP[@]}" \ 30 --if="$test_file0" \ 31 --ob="$bdev0" \ 32 --bs="$bs" \ 33 --qd="$qd" \ 34 --json <(gen_conf) 35 36 "${DD_APP[@]}" \ 37 --ib="$bdev0" \ 38 --of="$test_file1" \ 39 --bs="$bs" \ 40 --qd="$qd" \ 41 --count="$count" \ 42 --json <(gen_conf) 43 44 diff -q "$test_file0" "$test_file1" 45 clear_nvme "$bdev0" "" "$size" 46 done 47 done 48} 49 50basic_offset() { 51 # Check if offsetting works - using default io size of 4k 52 local count seek skip data data_check 53 54 gen_bytes 4096 > "$test_file0" 55 ((count = seek = skip = 1)) 56 data=$(< "$test_file0") 57 58 "${DD_APP[@]}" \ 59 --if="$test_file0" \ 60 --ob="$bdev0" \ 61 --seek="$seek" \ 62 --json <(gen_conf) 63 64 "${DD_APP[@]}" \ 65 --ib="$bdev0" \ 66 --of="$test_file1" \ 67 --skip="$skip" \ 68 --count="$count" \ 69 --json <(gen_conf) 70 71 read -rn${#data} data_check < "$test_file1" 72 [[ $data == "$data_check" ]] 73} 74 75cleanup() { 76 clear_nvme "$bdev0" 77 rm -f "$test_file0" "$test_file1" 78} 79 80trap "cleanup" EXIT 81 82nvmes=("$@") 83nvme0=Nvme0 nvme0_pci=${nvmes[0]} bdev0=Nvme0n1 84 85declare -A method_bdev_nvme_attach_controller_0=( 86 ["name"]=$nvme0 87 ["traddr"]=$nvme0_pci 88 ["trtype"]=pcie 89) 90 91test_file0=$SPDK_TEST_STORAGE/dd.dump0 92test_file1=$SPDK_TEST_STORAGE/dd.dump1 93native_bs=$(get_native_nvme_bs "$nvme0_pci") 94 95# Test if running with bs < native_bs successfully fails 96run_test "dd_bs_lt_native_bs" \ 97 NOT "${DD_APP[@]}" \ 98 --if=<(:) \ 99 --ob="$bdev0" \ 100 --bs=$((native_bs >> 1)) \ 101 --json <(gen_conf) 102 103run_test "dd_rw" basic_rw "$native_bs" 104run_test "dd_rw_offset" basic_offset 105