All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] can: add can tests to default
@ 2014-06-02  5:04 Zeng Linggang
  2014-06-12 13:10 ` chrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Zeng Linggang @ 2014-06-02  5:04 UTC (permalink / raw)
  To: ltp-list

* Add can testes to scenario_groups/default

* Makefile cleanup:
  - Intall the files into the expect points

* run_ltp-can_tests.sh cleanup:
  - Use TCID, TST_TOTAL and TST_COUNT
  - Use tst_require_root and tst_resm
  - Add cleanup function

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 runtest/can                                        |  2 +-
 scenario_groups/default                            |  1 +
 testcases/network/.gitignore                       |  2 +
 testcases/network/can/filter-tests/Makefile        | 39 +++++----
 .../network/can/filter-tests/run_ltp-can_tests.sh  | 99 ++++++++++++++++------
 5 files changed, 101 insertions(+), 42 deletions(-)

diff --git a/runtest/can b/runtest/can
index 0928bc1..2fa4424 100644
--- a/runtest/can
+++ b/runtest/can
@@ -1 +1 @@
-CONTROLLER_AREA_NETWORK_01 ( cd $LTPROOT/testcases/network/can/filter-tests/; make && ./run_ltp-can_tests.sh )
+CONTROLLER_AREA_NETWORK_01 run_ltp-can_tests.sh
diff --git a/scenario_groups/default b/scenario_groups/default
index bf7ab79..4e8ce44 100644
--- a/scenario_groups/default
+++ b/scenario_groups/default
@@ -28,3 +28,4 @@ kernel_misc
 modules
 fs_ext4
 pipes
+can
diff --git a/testcases/network/.gitignore b/testcases/network/.gitignore
index e5fbb88..16469dc 100644
--- a/testcases/network/.gitignore
+++ b/testcases/network/.gitignore
@@ -1,3 +1,5 @@
+/can/filter-tests/tst-filter
+/can/filter-tests/tst-rcv-own-msgs
 /datafiles/
 /lib6/asapi_01
 /lib6/asapi_02
diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
index c88f704..c03e8a3 100644
--- a/testcases/network/can/filter-tests/Makefile
+++ b/testcases/network/can/filter-tests/Makefile
@@ -1,24 +1,33 @@
 #
+#    Copyright (c) 2014 Fujitsu Ltd.
+#
+#    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.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+#
 #  $Id: Makefile,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
 #
 #  Send feedback to <socketcan-users@lists.berlios.de>
 
-CFLAGS    = -O2 -Wall -Wno-parentheses \
-	-fno-strict-aliasing \
-	-DETH_P_CAN=0x000C \
-	-DPF_CAN=29 \
-	-DAF_CAN=PF_CAN
-
-PROGRAMS =      tst-filter tst-rcv-own-msgs
-
-all: $(PROGRAMS)
+top_srcdir		?= ../../../..
 
-install:
-	cp -f $(PROGRAMS) /usr/local/bin
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	rm -f $(PROGRAMS)
+CPPFLAGS		+= -Wno-parentheses -DETH_P_CAN=0x000C -DPF_CAN=29 \
+                           -DAF_CAN=PF_CAN
 
-distclean:
-	rm -f $(PROGRAMS) *~
+INSTALL_TARGETS		:= run_ltp-can_tests.sh
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/can/filter-tests/run_ltp-can_tests.sh b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
index b955ec6..4885f3d 100644
--- a/testcases/network/can/filter-tests/run_ltp-can_tests.sh
+++ b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
@@ -14,44 +14,91 @@
 ## for more details.                                                          ##
 ##                                                                            ##
 ## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
 
-if [ $(id -ru) -ne 0 ]; then
-     echo You need to be root to execute these tests
-     exit 1
-fi
+export TCID="run_ltp-can_tests"
+export TST_TOTAL=2
+export TST_COUNT=1
 
-# load needed CAN networklayer modules
-modprobe -f can
-modprobe -f can_raw
+. cmdlib.sh
 
-# ensure the vcan driver to perform the ECHO on driver level
-modprobe -r vcan
-modprobe -f vcan echo=1
+setup()
+{
+	tst_require_root
 
-VCAN=vcan0
+	if [ ! -d "/lib/modules/`uname -r`/kernel/net/can" ]; then
+		tst_resm TCONF "Not find CAN modules"
+		exit
+	fi
+	if [ -e "/lib/modules/`uname -r`/kernel/net/can/can.ko" ] &&\
+	   [ -e "/lib/modules/`uname -r`/kernel/net/can/can-raw.ko" ]; then
+		# load needed CAN networklayer modules
+		modprobe -f can
+		modprobe -f can_raw
+	else
+		tst_resm TCONF "Not find can can_raw modules"
+		exit
+	fi
 
-# create virtual CAN device
-ip link add dev $VCAN type vcan || exit 1
-ifconfig $VCAN up
+	if [ -e "/lib/modules/`uname -r`/kernel/drivers/net/can/" ]; then
+		# ensure the vcan driver to perform the ECHO on driver level
+		modprobe -r vcan
+		modprobe -f vcan echo=1
+	else
+		tst_resm TCONF "Not find vcan modules"
+		exit
+	fi
 
-# check precondition for CAN frame flow test
-HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
+	VCAN=vcan0
 
-if [ $HAS_ECHO -ne 1 ]
-then
-    exit 1
-fi
+	# create virtual CAN device
+	ip link add dev $VCAN type vcan || exit 1
+	ifconfig $VCAN up
+
+	# check precondition for CAN frame flow test
+	HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
+
+	if [ $HAS_ECHO -ne 1 ]; then
+		exit 1
+	fi
+
+	RET=0
+}
+
+cleanup()
+{
+	ifconfig $VCAN down
+	ip link del dev $VCAN
+	modprobe -r vcan
+	modprobe -r can_raw
+	modprobe -r can
+}
+
+setup
 
 # test of CAN filters on af_can.c
-./tst-filter $VCAN || exit 1
+./tst-filter $VCAN
+ret=$?
+if [ $ret -ne 0 ]; then
+	RET=1
+	tst_resm TFAIL "Test tst-filter FAIL with exit num: $ret"
+else
+	tst_resm TPASS "Test tst-filter PASS"
+fi
 
 # test of CAN frame flow down to the netdevice and up again
-./tst-rcv-own-msgs $VCAN || exit 1
-
-exit 0
+./tst-rcv-own-msgs $VCAN
+ret=$?
+if [ $ret -ne 0 ]; then
+	RET=1
+	tst_resm TFAIL "Test tst-rcv-own-msgs FAIL with exit num: $ret"
+else
+	tst_resm TPASS "Test tst-rcv-own-msgs PASS"
+fi
 
+cleanup
 
+exit $RET
-- 
1.8.3.1




------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] can: add can tests to default
  2014-06-02  5:04 [LTP] [PATCH] can: add can tests to default Zeng Linggang
@ 2014-06-12 13:10 ` chrubis
       [not found]   ` <1403179593.7741.2.camel@G08JYZSD130126>
       [not found]   ` <1403179709.11671.0.camel@G08JYZSD130126>
  0 siblings, 2 replies; 7+ messages in thread
From: chrubis @ 2014-06-12 13:10 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> ---
>  runtest/can                                        |  2 +-
>  scenario_groups/default                            |  1 +
>  testcases/network/.gitignore                       |  2 +
>  testcases/network/can/filter-tests/Makefile        | 39 +++++----
>  .../network/can/filter-tests/run_ltp-can_tests.sh  | 99 ++++++++++++++++------
>  5 files changed, 101 insertions(+), 42 deletions(-)
> 
> diff --git a/runtest/can b/runtest/can
> index 0928bc1..2fa4424 100644
> --- a/runtest/can
> +++ b/runtest/can
> @@ -1 +1 @@
> -CONTROLLER_AREA_NETWORK_01 ( cd $LTPROOT/testcases/network/can/filter-tests/; make && ./run_ltp-can_tests.sh )
> +CONTROLLER_AREA_NETWORK_01 run_ltp-can_tests.sh

This is no-go. You should really follow one test per runtest record
rule. The best solution here would be to change the run_ltp-can_test.sh
to accept the test to run as a parameter.

Also the script sould be renamed to more saner name, i.e.
can_run_tests.sh or similar. (And please do that in a separate patch.)

> diff --git a/scenario_groups/default b/scenario_groups/default
> index bf7ab79..4e8ce44 100644
> --- a/scenario_groups/default
> +++ b/scenario_groups/default
> @@ -28,3 +28,4 @@ kernel_misc
>  modules
>  fs_ext4
>  pipes
> +can
> diff --git a/testcases/network/.gitignore b/testcases/network/.gitignore
> index e5fbb88..16469dc 100644
> --- a/testcases/network/.gitignore
> +++ b/testcases/network/.gitignore
> @@ -1,3 +1,5 @@
> +/can/filter-tests/tst-filter
> +/can/filter-tests/tst-rcv-own-msgs
>  /datafiles/
>  /lib6/asapi_01
>  /lib6/asapi_02
> diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
> index c88f704..c03e8a3 100644
> --- a/testcases/network/can/filter-tests/Makefile
> +++ b/testcases/network/can/filter-tests/Makefile
> @@ -1,24 +1,33 @@
>  #
> +#    Copyright (c) 2014 Fujitsu Ltd.
> +#
> +#    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.
> +#
> +#    You should have received a copy of the GNU General Public License along
> +#    with this program; if not, write to the Free Software Foundation, Inc.,
> +#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> +#
> +
> +#
>  #  $Id: Makefile,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $

This CVS export line should be removed.

>  #  Send feedback to <socketcan-users@lists.berlios.de>
>  
> -CFLAGS    = -O2 -Wall -Wno-parentheses \
> -	-fno-strict-aliasing \
> -	-DETH_P_CAN=0x000C \
> -	-DPF_CAN=29 \
> -	-DAF_CAN=PF_CAN
> -
> -PROGRAMS =      tst-filter tst-rcv-own-msgs
> -
> -all: $(PROGRAMS)
> +top_srcdir		?= ../../../..
>  
> -install:
> -	cp -f $(PROGRAMS) /usr/local/bin
> +include $(top_srcdir)/include/mk/testcases.mk
>  
> -clean:
> -	rm -f $(PROGRAMS)
> +CPPFLAGS		+= -Wno-parentheses -DETH_P_CAN=0x000C -DPF_CAN=29 \
> +                           -DAF_CAN=PF_CAN
>  
> -distclean:
> -	rm -f $(PROGRAMS) *~
> +INSTALL_TARGETS		:= run_ltp-can_tests.sh
>  
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/network/can/filter-tests/run_ltp-can_tests.sh b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
> index b955ec6..4885f3d 100644
> --- a/testcases/network/can/filter-tests/run_ltp-can_tests.sh
> +++ b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
> @@ -14,44 +14,91 @@
>  ## for more details.                                                          ##
>  ##                                                                            ##
>  ## You should have received a copy of the GNU General Public License          ##
> -## along with this program;  if not, write to the Free Software               ##
> -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
>  ##                                                                            ##
>  ################################################################################
>  
> -if [ $(id -ru) -ne 0 ]; then
> -     echo You need to be root to execute these tests
> -     exit 1
> -fi
> +export TCID="run_ltp-can_tests"
> +export TST_TOTAL=2
> +export TST_COUNT=1
>  
> -# load needed CAN networklayer modules
> -modprobe -f can
> -modprobe -f can_raw
> +. cmdlib.sh

cmdlib.sh is deprecated, you should use test.sh instead

> -# ensure the vcan driver to perform the ECHO on driver level
> -modprobe -r vcan
> -modprobe -f vcan echo=1
> +setup()
> +{
> +	tst_require_root
>  
> -VCAN=vcan0
> +	if [ ! -d "/lib/modules/`uname -r`/kernel/net/can" ]; then
> +		tst_resm TCONF "Not find CAN modules"
> +		exit
> +	fi
> +	if [ -e "/lib/modules/`uname -r`/kernel/net/can/can.ko" ] &&\
> +	   [ -e "/lib/modules/`uname -r`/kernel/net/can/can-raw.ko" ]; then
> +		# load needed CAN networklayer modules
> +		modprobe -f can
> +		modprobe -f can_raw
> +	else
> +		tst_resm TCONF "Not find can can_raw modules"
> +		exit
> +	fi

Can't we just use return value from modprobe? It should exit with 0 if
module was succesfuly loaded and non-zero if not.

Also why the -f (force) parameter. This should be only needed when
version information of the module and running kernel does not match.

> -# create virtual CAN device
> -ip link add dev $VCAN type vcan || exit 1
> -ifconfig $VCAN up
> +	if [ -e "/lib/modules/`uname -r`/kernel/drivers/net/can/" ]; then
> +		# ensure the vcan driver to perform the ECHO on driver level
> +		modprobe -r vcan
> +		modprobe -f vcan echo=1
> +	else
> +		tst_resm TCONF "Not find vcan modules"
> +		exit
> +	fi

Here as well.

> -# check precondition for CAN frame flow test
> -HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
> +	VCAN=vcan0
>  
> -if [ $HAS_ECHO -ne 1 ]
> -then
> -    exit 1
> -fi
> +	# create virtual CAN device
> +	ip link add dev $VCAN type vcan || exit 1
> +	ifconfig $VCAN up
> +
> +	# check precondition for CAN frame flow test
> +	HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
> +
> +	if [ $HAS_ECHO -ne 1 ]; then
> +		exit 1
> +	fi
> +
> +	RET=0
> +}
> +
> +cleanup()
> +{
> +	ifconfig $VCAN down
> +	ip link del dev $VCAN
> +	modprobe -r vcan
> +	modprobe -r can_raw
> +	modprobe -r can
> +}
> +
> +setup
>  
>  # test of CAN filters on af_can.c
> -./tst-filter $VCAN || exit 1
> +./tst-filter $VCAN
> +ret=$?
> +if [ $ret -ne 0 ]; then
> +	RET=1
> +	tst_resm TFAIL "Test tst-filter FAIL with exit num: $ret"
> +else
> +	tst_resm TPASS "Test tst-filter PASS"
> +fi

The ./ should be removed here. It expects that the $CWD for the test is
$LTPROOT/testcases/bin/ which is only true if test does not create the
test temporary directory. This will break for no apparent reason if
somebody adds tst_tmpdir() to the test setup.

Also the scripts called from this testcase should be renamed so that
it's clear that they are testing can. I.e. this one should be called
can_filter

>  
>  # test of CAN frame flow down to the netdevice and up again
> -./tst-rcv-own-msgs $VCAN || exit 1
> -
> -exit 0
> +./tst-rcv-own-msgs $VCAN

Here remove the ./ and the binary should be named with can_rcv_own_msgs
or similar.

> +ret=$?
> +if [ $ret -ne 0 ]; then
> +	RET=1
> +	tst_resm TFAIL "Test tst-rcv-own-msgs FAIL with exit num: $ret"
> +else
> +	tst_resm TPASS "Test tst-rcv-own-msgs PASS"
> +fi
>  
> +cleanup
>  
> +exit $RET

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v2 2/3] can: cleanup
       [not found]   ` <1403179593.7741.2.camel@G08JYZSD130126>
@ 2014-06-25 15:39     ` chrubis
       [not found]       ` <1403866408.2119.28.camel@G08JYZSD130126>
       [not found]       ` <1403840536.2119.24.camel@G08JYZSD130126>
  0 siblings, 2 replies; 7+ messages in thread
From: chrubis @ 2014-06-25 15:39 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> ---
>  testcases/network/can/filter-tests/Makefile        | 37 +++++----
>  .../network/can/filter-tests/run_ltp-can_tests.sh  | 97 ++++++++++++++++------
>  testcases/network/can/filter-tests/tst-filter.c    | 45 +++++-----
>  .../network/can/filter-tests/tst-rcv-own-msgs.c    | 24 +++---
>  4 files changed, 122 insertions(+), 81 deletions(-)
> 
> diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
> index c88f704..70e2a42 100644
> --- a/testcases/network/can/filter-tests/Makefile
> +++ b/testcases/network/can/filter-tests/Makefile
> @@ -1,24 +1,29 @@
>  #
> -#  $Id: Makefile,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
> +#    Copyright (c) 2014 Fujitsu Ltd.
> +#
> +#    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.
> +#
> +#    You should have received a copy of the GNU General Public License along
> +#    with this program; if not, write to the Free Software Foundation, Inc.,
> +#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>  #
>  #  Send feedback to <socketcan-users@lists.berlios.de>
>  
> -CFLAGS    = -O2 -Wall -Wno-parentheses \
> -	-fno-strict-aliasing \
> -	-DETH_P_CAN=0x000C \
> -	-DPF_CAN=29 \
> -	-DAF_CAN=PF_CAN
> -
> -PROGRAMS =      tst-filter tst-rcv-own-msgs
> -
> -all: $(PROGRAMS)
> +top_srcdir		?= ../../../..
>  
> -install:
> -	cp -f $(PROGRAMS) /usr/local/bin
> +include $(top_srcdir)/include/mk/testcases.mk
>  
> -clean:
> -	rm -f $(PROGRAMS)
> +CPPFLAGS		+= -Wno-parentheses -DETH_P_CAN=0x000C -DPF_CAN=29 \
                               ^
			    This should be removed and warnings (if
			    there are any) fixed

> +                           -DAF_CAN=PF_CAN
>  
> -distclean:
> -	rm -f $(PROGRAMS) *~
> +INSTALL_TARGETS		:= *.sh
>  
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/network/can/filter-tests/run_ltp-can_tests.sh b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
> index b955ec6..17d841d 100644
> --- a/testcases/network/can/filter-tests/run_ltp-can_tests.sh
> +++ b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
> @@ -14,44 +14,89 @@
>  ## for more details.                                                          ##
>  ##                                                                            ##
>  ## You should have received a copy of the GNU General Public License          ##
> -## along with this program;  if not, write to the Free Software               ##
> -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
>  ##                                                                            ##
>  ################################################################################
>  
> -if [ $(id -ru) -ne 0 ]; then
> -     echo You need to be root to execute these tests
> -     exit 1
> -fi
> +setup()
> +{
> +	tst_require_root
> +
> +	# load needed CAN networklayer modules
> +	modprobe can
> +	ret=$?
> +	if [ $ret -ne 0 ]; then
> +		tst_resm TCONF "insmod can modules fail: errno - $ret"
                                 ^
				modprobe
> +		exit 1

                The message says TCONF but then exits with 1, which is
		TFAIL.

		Why don't you use the tst_brkm() which (after sourcing
		test.sh) will exit with correct exit value for you?
> +	fi
> +
> +	modprobe can_raw
> +	ret=$?
> +	if [ $ret -ne 0 ]; then
> +		tst_resm TCONF "insmod can_raw modules fail: errno - $ret"
                                  ^
				modprobe
> +		exit 1
> +	fi
> +
> +	# ensure the vcan driver to perform the ECHO on driver level
> +	modprobe -r vcan
> +	ret=$?
> +	if [ $ret -ne 0 ]; then
> +		tst_resm TCONF "rmsmod vcan modules fail: errno - $ret"
                                 ^
				modprobe -r
> +		exit 1
> +	fi
>  
> -# load needed CAN networklayer modules
> -modprobe -f can
> -modprobe -f can_raw
> +	modprobe vcan echo=1
> +	ret=$?
> +	if [ $ret -ne 0 ]; then
> +		tst_resm TCONF "insmod vcan modules fail: errno - $ret"
                                  ^
				modprobe vcan echo=1
> +		exit 1
> +	fi
>  
> -# ensure the vcan driver to perform the ECHO on driver level
> -modprobe -r vcan
> -modprobe -f vcan echo=1
> +	VCAN=vcan0
>  
> -VCAN=vcan0
> +	# create virtual CAN device
> +	ip link add dev $VCAN type vcan || exit 1
> +	ifconfig $VCAN up

It would be better to stick with just ip.

i.e.

ip link set dev $VCAN up

> -# create virtual CAN device
> -ip link add dev $VCAN type vcan || exit 1
> -ifconfig $VCAN up
> +	# check precondition for CAN frame flow test
> +	HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
>  
> -# check precondition for CAN frame flow test
> -HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
> +	if [ $HAS_ECHO -ne 1 ]; then

There should be some error message here.

> +		exit 1
> +	fi
> +}
>  
> -if [ $HAS_ECHO -ne 1 ]
> -then
> -    exit 1
> +cleanup()
> +{
> +	ifconfig $VCAN down

ip link set dev $VCAN down

> +	ip link del dev $VCAN
> +	modprobe -r vcan
> +	modprobe -r can_raw
> +	modprobe -r can
> +}
> +
> +if [ $# -ne 1 ]; then
> +	echo "Usage: $0 [can_filter | can_rcv_own_msgs]"
> +	exit 1
>  fi
>  
> -# test of CAN filters on af_can.c
> -./tst-filter $VCAN || exit 1
> +TCID="$1"
> +TST_TOTAL=1
> +TST_COUNT=1
> +
> +. test.sh

This should rather be at the start of the script and the TST_COUNT
should not be initialized.

> +TST_CLEANUP=cleanup
>  
> -# test of CAN frame flow down to the netdevice and up again
> -./tst-rcv-own-msgs $VCAN || exit 1
> +setup
>  
> -exit 0
> +"$1" "$VCAN"
> +ret=$?
>  
> +if [ $ret -ne 0 ]; then
> +	tst_resm TFAIL "Test $1 FAIL with exit num: $ret"
> +else
> +	tst_resm TPASS "Test $1 PASS"
> +fi
>  
> +tst_exit
> diff --git a/testcases/network/can/filter-tests/tst-filter.c b/testcases/network/can/filter-tests/tst-filter.c
> index 26eacf7..f248999 100644
> --- a/testcases/network/can/filter-tests/tst-filter.c
> +++ b/testcases/network/can/filter-tests/tst-filter.c
> @@ -1,8 +1,4 @@
>  /*
> - *  $Id: tst-filter.c 1263 2011-07-09 18:00:41Z hartkopp $
> - */
> -
> -/*
>   * tst-filter.c
>   *
>   * Copyright (c) 2011 Volkswagen Group Electronic Research
> @@ -65,9 +61,8 @@
>  #define TC 18			/* # of testcases */
>  
>  const int rx_res[TC] = { 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1 };
> -const int rxbits_res[TC] =
> -    { 4369, 4369, 4369, 4369, 17, 4352, 17, 4352, 257, 257, 4112, 4112, 1, 256,
> -16, 4096, 1, 256 };
> +const int rxbits_res[TC] = { 4369, 4369, 4369, 4369, 17, 4352, 17, 4352, 257,
> +			     257, 4112, 4112, 1, 256, 16, 4096, 1, 256 };
>  
>  canid_t calc_id(int testcase)
>  {
> @@ -85,13 +80,12 @@ canid_t calc_mask(int testcase)
>  {
>  	canid_t mask = CAN_SFF_MASK;
>  
> -	if (testcase > 15)
> -		return (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG);
> -
>  	if (testcase & 4)
>  		mask |= CAN_EFF_FLAG;
>  	if (testcase & 8)
>  		mask |= CAN_RTR_FLAG;
> +	if (testcase > 15)
> +		mask = (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG);

What is the reason for this change? Does the test fail without it?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v2 3/3] can: change the entry
       [not found]   ` <1403179709.11671.0.camel@G08JYZSD130126>
@ 2014-06-25 15:43     ` chrubis
  0 siblings, 0 replies; 7+ messages in thread
From: chrubis @ 2014-06-25 15:43 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> * Change the entry:
> 	can_filter can_run_tests.sh can_filter
> 	can_rcv_own_msgs can_run_tests.sh can_rcv_own_msgs
> 
> * Add can_filter and can_rcv_own_msgs to network/.gitignore
> 
> * Make the test's name more saner:
> 	tst-filter.c --> can_filter.c
> 	tst-rcv-own-msgs.c --> can_rcv_own_msgs.c
> 	run_ltp-can_tests.sh --> can_run_tests.sh
> 
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
>  runtest/can                                        |   3 +-
>  testcases/network/.gitignore                       |   2 +
>  testcases/network/can/filter-tests/can_filter.c    | 263 +++++++++++++++++++++
>  .../network/can/filter-tests/can_rcv_own_msgs.c    | 255 ++++++++++++++++++++
>  .../network/can/filter-tests/can_run_tests.sh      | 102 ++++++++
>  .../network/can/filter-tests/run_ltp-can_tests.sh  | 102 --------
>  testcases/network/can/filter-tests/tst-filter.c    | 263 ---------------------
>  .../network/can/filter-tests/tst-rcv-own-msgs.c    | 255 --------------------
>  8 files changed, 624 insertions(+), 621 deletions(-)
>  create mode 100644 testcases/network/can/filter-tests/can_filter.c
>  create mode 100644 testcases/network/can/filter-tests/can_rcv_own_msgs.c
>  create mode 100755 testcases/network/can/filter-tests/can_run_tests.sh
>  delete mode 100644 testcases/network/can/filter-tests/run_ltp-can_tests.sh
>  delete mode 100644 testcases/network/can/filter-tests/tst-filter.c
>  delete mode 100644 testcases/network/can/filter-tests/tst-rcv-own-msgs.c

This looks good but I'm missing a Makefile in testcases/network/can so
that the tests are compiled and installed by default.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v3 1/3] Add autoconf test for CAN.
       [not found]       ` <1403866408.2119.28.camel@G08JYZSD130126>
@ 2014-07-15 14:39         ` chrubis
       [not found]           ` <1405932572.5156.7.camel@G08JYZSD130126>
  0 siblings, 1 reply; 7+ messages in thread
From: chrubis @ 2014-07-15 14:39 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> +int main(void)
> +{
> +	printf("The linux/can.h was missing upon compilation.\n");
> +	return 0;
> +}

Ideally this should return non-zero value so that we can return TCONF
from the test script in this case (since we changed the test library
to propagate TCONF into return value).

The rest of looks ok.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v2 2/3] can: cleanup
       [not found]       ` <1403840536.2119.24.camel@G08JYZSD130126>
@ 2014-07-15 14:57         ` chrubis
  0 siblings, 0 replies; 7+ messages in thread
From: chrubis @ 2014-07-15 14:57 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> When I use <kernel_path>/scripts/checkpatch.pl to check the patch, it
> output like:
> #20: FILE: testcases/network/can/filter-tests/tst-filter.c:84:
> +		return (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG);

This misses the important part which says:

ERROR: return is not a function, parentheses are not required

so the script is telling you to do:

		reutrn CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG;

instead ;).

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v4 3/3] Make can testes' name more saner
       [not found]             ` <1405934632.5156.13.camel@G08JYZSD130126>
@ 2014-07-22 14:08               ` chrubis
  0 siblings, 0 replies; 7+ messages in thread
From: chrubis @ 2014-07-22 14:08 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> * Add can to scenario_groups/default.
> 
> * Add can_filter and can_rcv_own_msgs to network/.gitignore.
> 
> * Make the test's name more saner:
> 	tst-filter.c --> can_filter.c
> 	tst-rcv-own-msgs.c --> can_rcv_own_msgs.c
> 	run_ltp-can_tests.sh --> can_run_tests.sh

Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-07-22 14:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-02  5:04 [LTP] [PATCH] can: add can tests to default Zeng Linggang
2014-06-12 13:10 ` chrubis
     [not found]   ` <1403179593.7741.2.camel@G08JYZSD130126>
2014-06-25 15:39     ` [LTP] [PATCH v2 2/3] can: cleanup chrubis
     [not found]       ` <1403866408.2119.28.camel@G08JYZSD130126>
2014-07-15 14:39         ` [LTP] [PATCH v3 1/3] Add autoconf test for CAN chrubis
     [not found]           ` <1405932572.5156.7.camel@G08JYZSD130126>
     [not found]             ` <1405934632.5156.13.camel@G08JYZSD130126>
2014-07-22 14:08               ` [LTP] [PATCH v4 3/3] Make can testes' name more saner chrubis
     [not found]       ` <1403840536.2119.24.camel@G08JYZSD130126>
2014-07-15 14:57         ` [LTP] [PATCH v2 2/3] can: cleanup chrubis
     [not found]   ` <1403179709.11671.0.camel@G08JYZSD130126>
2014-06-25 15:43     ` [LTP] [PATCH v2 3/3] can: change the entry chrubis

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.