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