• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2016 Fujitsu Ltd.
4# Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
5#
6# Test basic functionality of insmod command.
7
8TST_CLEANUP=cleanup
9TST_TESTFUNC=do_test
10TST_NEEDS_ROOT=1
11TST_NEEDS_CMDS="rmmod insmod"
12TST_NEEDS_MODULE="ltp_insmod01.ko"
13. tst_test.sh
14
15inserted=0
16
17cleanup()
18{
19	if [ $inserted -ne 0 ]; then
20		tst_res TINFO "running rmmod ltp_insmod01"
21		rmmod ltp_insmod01
22		if [ $? -ne 0 ]; then
23			tst_res TWARN "failed to rmmod ltp_insmod01"
24		fi
25		inserted=0
26	fi
27}
28
29do_test()
30{
31	insmod "$TST_MODPATH"
32	if [ $? -ne 0 ]; then
33		tst_res TFAIL "insmod failed"
34		return
35	fi
36	inserted=1
37
38	grep -q ltp_insmod01 /proc/modules
39	if [ $? -ne 0 ]; then
40		tst_res TFAIL "ltp_insmod01 not found in /proc/modules"
41		return
42	fi
43
44	cleanup
45
46	tst_res TPASS "insmod passed"
47}
48
49tst_run
50