All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] commands/insmod: add new testcase to test insmod(8)
Date: Mon, 18 Apr 2016 10:33:05 +0800	[thread overview]
Message-ID: <57144761.2030700@cn.fujitsu.com> (raw)
In-Reply-To: <1458029005-8807-1-git-send-email-fenggw-fnst@cn.fujitsu.com>

Hi!

Ping! thanks.


Best Regards,
Guangwen Feng

On 03/15/2016 04:03 PM, Guangwen Feng wrote:
> Test the basic functionality of insmod(8) command.
> 
> Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> ---
>  runtest/commands                         |  1 +
>  testcases/commands/insmod/Makefile       | 36 ++++++++++++++++
>  testcases/commands/insmod/insmod01.sh    | 71 ++++++++++++++++++++++++++++++++
>  testcases/commands/insmod/ltp_insmod01.c | 35 ++++++++++++++++
>  testcases/lib/test.sh                    | 28 +++++++++++++
>  5 files changed, 171 insertions(+)
>  create mode 100644 testcases/commands/insmod/Makefile
>  create mode 100755 testcases/commands/insmod/insmod01.sh
>  create mode 100644 testcases/commands/insmod/ltp_insmod01.c
> 
> diff --git a/runtest/commands b/runtest/commands
> index db89424..abbbd96 100644
> --- a/runtest/commands
> +++ b/runtest/commands
> @@ -41,3 +41,4 @@ mkfs01_ntfs mkfs01.sh -f ntfs
>  mkswap01 mkswap01.sh
>  which01 which01.sh
>  lsmod01 lsmod01.sh
> +insmod01 insmod01.sh
> diff --git a/testcases/commands/insmod/Makefile b/testcases/commands/insmod/Makefile
> new file mode 100644
> index 0000000..e5e68b6
> --- /dev/null
> +++ b/testcases/commands/insmod/Makefile
> @@ -0,0 +1,36 @@
> +#
> +#    Copyright (c) 2016 Fujitsu Ltd.
> +#    Author:Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> +#
> +#    This program is free software; you can redistribute it and/or modify
> +#    it under the terms of the GNU General Public License as published by
> +#    the Free Software Foundation; either version 2 of the License, or
> +#    (at your option) any later version.
> +#
> +#    This program is distributed in the hope that it will be useful,
> +#    but WITHOUT ANY WARRANTY; without even the implied warranty of
> +#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +#    GNU General Public License for more details.
> +#
> +
> +ifneq ($(KERNELRELEASE),)
> +
> +obj-m := ltp_insmod01.o
> +
> +else
> +
> +top_srcdir		?= ../../..
> +include $(top_srcdir)/include/mk/testcases.mk
> +
> +REQ_VERSION_MAJOR       := 2
> +REQ_VERSION_PATCH       := 6
> +MAKE_TARGETS            := ltp_insmod01.ko
> +
> +include $(top_srcdir)/include/mk/env_pre.mk
> +
> +INSTALL_TARGETS		:= insmod01.sh
> +
> +include $(top_srcdir)/include/mk/module.mk
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> +
> +endif
> diff --git a/testcases/commands/insmod/insmod01.sh b/testcases/commands/insmod/insmod01.sh
> new file mode 100755
> index 0000000..f19c068
> --- /dev/null
> +++ b/testcases/commands/insmod/insmod01.sh
> @@ -0,0 +1,71 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2016 Fujitsu Ltd.
> +# Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> +# the GNU General Public License for more details.
> +#
> +# Test the basic functionality of insmod command.
> +#
> +
> +TCID=insmod01
> +TST_TOTAL=1
> +. test.sh
> +
> +setup()
> +{
> +	tst_require_root
> +
> +	tst_check_cmds rmmod insmod
> +
> +	tst_module_exists ltp_insmod01.ko
> +
> +	inserted=0
> +
> +	TST_CLEANUP="cleanup"
> +}
> +
> +cleanup()
> +{
> +	if [ $inserted -ne 0 ]; then
> +		echo "about to rmmod ltp_insmod01"
> +		rmmod ltp_insmod01
> +		if [ $? -ne 0 ]; then
> +			echo "failed to rmmod ltp_insmod01"
> +		fi
> +	fi
> +}
> +
> +insmod_test()
> +{
> +	insmod "$TST_MODPATH"
> +	if [ $? -ne 0 ]; then
> +		tst_resm TFAIL "'insmod' failed."
> +		return
> +	fi
> +	inserted=1
> +
> +	grep -q ltp_insmod01 /proc/modules
> +
> +	if [ $? -ne 0 ]; then
> +		tst_resm TINFO "ltp_insmod01 not found in /proc/modules"
> +		tst_resm TFAIL "'insmod' failed, not expected."
> +		return
> +	fi
> +
> +	tst_resm TPASS "'insmod' passed."
> +}
> +
> +setup
> +
> +insmod_test
> +
> +tst_exit
> diff --git a/testcases/commands/insmod/ltp_insmod01.c b/testcases/commands/insmod/ltp_insmod01.c
> new file mode 100644
> index 0000000..398714e
> --- /dev/null
> +++ b/testcases/commands/insmod/ltp_insmod01.c
> @@ -0,0 +1,35 @@
> +/*
> + * Copyright (c) 2016 Fujitsu Ltd.
> + * Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> + * the GNU General Public License for more details.
> + *
> + * Description:
> + *  This is a kernel loadable module programme used by insmod01.sh
> + *  testcase which inserts this module for test of insmod command.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +
> +static int test_init(void)
> +{
> +	return 0;
> +}
> +
> +static void test_exit(void)
> +{
> +
> +}
> +
> +module_init(test_init);
> +module_exit(test_exit);
> diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
> index 9b652c0..56e1c60 100644
> --- a/testcases/lib/test.sh
> +++ b/testcases/lib/test.sh
> @@ -352,6 +352,34 @@ tst_umount()
>  	tst_resm TWARN "Failed to umount($device) after 50 retries"
>  }
>  
> +# Check a module file existence
> +# Should be called after tst_tmpdir()
> +tst_module_exists()
> +{
> +	local mod_name="$1"
> +
> +	if [ -f "$mod_name" ]; then
> +		TST_MODPATH="$mod_name"
> +		return
> +	fi
> +
> +	local mod_path="$LTPROOT/testcases/bin/$mod_name"
> +	if [ -f "$mod_path" ]; then
> +		TST_MODPATH="$mod_path"
> +		return
> +	fi
> +
> +	if [ -n "$TST_TMPDIR" ]; then
> +		mod_path="$TST_TMPDIR/$mod_name"
> +		if [ -f "$mod_path" ]; then
> +			TST_MODPATH="$mod_path"
> +			return
> +		fi
> +	fi
> +
> +	tst_brkm TCONF "Failed to find module '$mod_name'"
> +}
> +
>  # Check that test name is set
>  if [ -z "$TCID" ]; then
>  	tst_brkm TBROK "TCID is not defined"
> 



  reply	other threads:[~2016-04-18  2:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18  7:07 [LTP] [PATCH 1/2] commands/lsmod: Added new testcase to test lsmod(8) Guangwen Feng
2015-12-18  7:07 ` [LTP] [PATCH 2/2] commands/insmod: Added new testcase to test insmod(8) Guangwen Feng
2016-01-27 16:28   ` Cyril Hrubis
2016-01-28  9:42     ` Guangwen Feng
2016-03-15  8:03       ` [LTP] [PATCH v2] commands/insmod: add " Guangwen Feng
2016-04-18  2:33         ` Guangwen Feng [this message]
2016-04-18 15:44         ` Cyril Hrubis
2016-04-22  6:28           ` [LTP] [PATCH v3] " Guangwen Feng
2016-05-10 16:28             ` Cyril Hrubis
2016-01-27 16:11 ` [LTP] [PATCH 1/2] commands/lsmod: Added new testcase to test lsmod(8) Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57144761.2030700@cn.fujitsu.com \
    --to=fenggw-fnst@cn.fujitsu.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.