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