• 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: cpuisolation07.sh
18#
19# Description: check enable node status about CPU isolation
20#
21# Authors:     liudanning - liudanning@h-partners.com
22#
23# History:     Mar 24 2022 - init scripts
24#
25################################################################################
26
27source tst_oh.sh
28
29do_setup()
30{
31
32}
33
34do_test()
35{
36    local ret=0
37    dir_name=/sys/devices/system/cpu/cpu0/core_ctl
38    enable=${dir_name}/enable
39    pre_enable=$(cat $enable)
40
41    cat $enable
42    if [ $? -eq 0 ]; then
43        tst_res TPASS "Node enable can be read."
44    else
45        tst_res TFAIL "Node enable status error."
46        ret=$(( $ret + 1 ))
47    fi
48
49    echo 1 > $enable
50    if [ $? -eq 0 ]; then
51        tst_res TPASS "Node enable can be opened."
52    else
53        tst_res TFAIL "Node enable open error."
54        ret=$(( $ret + 1 ))
55    fi
56
57    echo 0 > $enable
58    if [ $? -eq 0 ]; then
59        tst_res TPASS "Node enable can be closed."
60    else
61        tst_res TFAIL "Node enable close error."
62        ret=$(( $ret + 1 ))
63    fi
64
65    echo 2 > $enable
66    if [ $(cat $enable) -eq 1 ]; then
67        tst_res TPASS "Node enable writing 2 is abnormal."
68    else
69        tst_res TFAIL "Node enable writing 2 is normal."
70        ret=$(( $ret + 1 ))
71    fi
72
73    echo -1 > $enable
74    if [ $(cat $enable) -eq 1 ]; then
75        tst_res TPASS "Node enable writing -1 is abnormal."
76    else
77        tst_res TFAIL "Node enable writing -1 is normal."
78        ret=$(( $ret + 1 ))
79    fi
80
81    echo ret=$ret
82    if [ $ret -eq 0 ]; then
83        tst_res TPASS "enable node status is right."
84    else
85        tst_res TFAIL "enable node status is wrong!"
86    fi
87}
88
89do_clean()
90{
91    echo $pre_enable > $enable
92}
93
94do_setup
95do_test
96do_clean
97tst_exit