• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2################################################################################
3#
4# Copyright (C) 2022 Huawei Device Co., Ltd.
5# SPDX-License-Identifier: GPL-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10# See the License for the specific language governing permissions and
11# limitations under the License.
12#
13################################################################################
14# File: enhancedf2fs02.sh
15#
16# Description: life mode, discard is greater than or equal to 512 block
17#              IO Imperceptible
18#
19# Authors:     Li Zhanming - lizhanming3@h-partners.com
20#
21# History:     April 8 2022 - init scripts
22#
23################################################################################
24
25source tst_oh.sh
26
27source life_init.sh
28
29do_setup()
30{
31
32}
33
34do_test()
35{
36    local ret=0
37
38    tst_res TINFO "Start test discard size >= 512 blocks in life mode,IO imperceptible."
39
40
41    cat /sys/kernel/debug/tracing/trace_pipe | grep issue_discard >> log02.txt &
42    sh run_fio.sh > run_fio.txt &
43    sleep 60
44    mkdir $DISK_PATH/test2
45    if [ $? -eq 0 ]; then
46        tst_res TPASS "Created test2 dir successfully."
47    else
48        tst_res TFAIL "Created tets2 dir failed."
49        ret=$(( $ret + 1 ))
50    fi
51
52    local i=0
53    while [ $i -lt 30 ]
54    do
55        dd if=/dev/zero of=$DISK_PATH/test2/image$i bs=8M count=1
56        i=$(( $i + 1 ))
57    done
58    echo "y" | rm $DISK_PATH/test2/image*[1,3,5,7,9]
59    if [ $? -eq 0 ]; then
60        tst_res TPASS "Deleted successfully."
61    else
62        tst_res TFAIL "Deleted failed."
63        ret=$(( $ret + 1 ))
64    fi
65    local first=$(wc -l log02.txt | awk -F ' ' '{print$1}')
66    sleep 240
67    local second=$(wc -l log02.txt | awk -F ' ' '{print$1}')
68    sleep 90
69    kill %1
70    sleep 5
71    local err=$(cat run_fio.txt | grep err | awk -F ':' '{print$3}' | tr -cd "[0-9]")
72    if [ $err -eq 0 ]; then
73        tst_res TPASS "fio read successfully."
74    else
75        tst_res TFAIL "fio read failed."
76        ret=$(( $ret + 1 ))
77    fi
78
79    local blklen=$(cat log02.txt | awk 'NR == 1' | awk -F '0x' '{print$3}')
80    if [ $((16#$blklen)) -ge 512 ]; then
81        tst_res TPASS "blklen = $blklen >= 512 successfully."
82    else
83        tst_res TFAIL "blklen = $blklen >= 512 failed."
84        ret=$(( $ret + 1 ))
85    fi
86
87
88    if [ $ret -eq 0 ];then
89        tst_res TPASS "life mode, discard is greater than or equal to 512 block  \
90                        IO Imperceptible pass."
91    else
92        tst_res TFAIL "life mode, discard is greater than or equal to 512 block  \
93                        IO Imperceptible failed!"
94    fi
95}
96
97do_clean()
98{
99    echo "y" | rm $DISK_PATH/test2/*
100    rmdir $DISK_PATH/test2/
101    echo "y" | rm log02.txt
102}
103
104do_setup
105do_test
106do_clean
107tst_exit
108
109