• 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: tracepointtestko.sh
18#
19# Description: tracepoint ko test
20#
21# Authors:     yang ming di
22#
23# History:     August 4 2022 - tracepoint ko test
24#
25################################################################################
26
27set -e
28
29CURRENT_DIR=$(pwd)
30KO_DIR=${CURRENT_DIR}/kofile
31
32insmod_ko() {
33  for file in $(ls ${KO_DIR}); do
34    if [[ "${file}" != "tracepoint_test.ko" ]]; then
35      insmod ${KO_DIR}/${file}
36      echo "${KO_DIR}/${file} is loaded"
37    fi
38  done
39
40  if [ -e "${KO_DIR}/tracepoint_test.ko" ]; then
41    insmod ${KO_DIR}/tracepoint_test.ko
42  else
43    echo "no such file tracepoint_test.ko"
44    exit 1
45  fi
46
47  arr=(vendor_do_mmap vendor_do_mprotect_pkey vendor_aml_emmc_partition vendor_fake_boot_partition)
48  set +e
49  for i in ${arr[@]}; do
50    dmesg | grep $i >/dev/null
51    if [ $? -eq 0 ]; then
52      echo "tracepoint $i succeed"
53    else
54      echo "tracepoint $i failed"
55    fi
56  done
57  set -e
58}
59
60rmmod_ko() {
61  for dir in $(ls ${KO_DIR}); do
62      rmmod ${KO_DIR}/${dir}
63      echo "${KO_DIR}/${dir} is removed"
64  done
65}
66
67main() {
68  if [[ "$1" == "rmmod_ko" ]]; then
69    rmmod_ko
70  else
71    insmod_ko
72  fi
73}
74
75main $1
76