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