* 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...@cn.fujitsu.com>
---
 runtest/can                                        |   3 +-
 testcases/network/.gitignore                       |   2 +
 testcases/network/can/filter-tests/can_filter.c    | 264 +++++++++++++++++++++
 .../network/can/filter-tests/can_rcv_own_msgs.c    | 256 ++++++++++++++++++++
 .../network/can/filter-tests/can_run_tests.sh      | 106 +++++++++
 .../network/can/filter-tests/run_ltp-can_tests.sh  | 106 ---------
 testcases/network/can/filter-tests/tst-filter.c    | 264 ---------------------
 .../network/can/filter-tests/tst-rcv-own-msgs.c    | 256 --------------------
 8 files changed, 630 insertions(+), 627 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 100644 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

diff --git a/runtest/can b/runtest/can
index 0928bc1..6aa2ae9 100644
--- a/runtest/can
+++ b/runtest/can
@@ -1 +1,2 @@
-CONTROLLER_AREA_NETWORK_01 ( cd $LTPROOT/testcases/network/can/filter-tests/; 
make && ./run_ltp-can_tests.sh )
+can_filter can_run_tests.sh can_filter
+can_rcv_own_msgs can_run_tests.sh can_rcv_own_msgs
diff --git a/testcases/network/.gitignore b/testcases/network/.gitignore
index e5fbb88..95a3862 100644
--- a/testcases/network/.gitignore
+++ b/testcases/network/.gitignore
@@ -1,3 +1,5 @@
+/can/filter-tests/can_filter
+/can/filter-tests/can_rcv_own_msgs
 /datafiles/
 /lib6/asapi_01
 /lib6/asapi_02
diff --git a/testcases/network/can/filter-tests/can_filter.c 
b/testcases/network/can/filter-tests/can_filter.c
new file mode 100644
index 0000000..b24e339
--- /dev/null
+++ b/testcases/network/can/filter-tests/can_filter.c
@@ -0,0 +1,264 @@
+/*
+ * tst-filter.c
+ *
+ * Copyright (c) 2011 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-us...@lists.berlios.de>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <net/if.h>
+#include "config.h"
+
+#ifdef HAVE_LINUX_CAN_H
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#define ID 0x123
+#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 };
+
+canid_t calc_id(int testcase)
+{
+       canid_t id = ID;
+
+       if (testcase & 1)
+               id |= CAN_EFF_FLAG;
+       if (testcase & 2)
+               id |= CAN_RTR_FLAG;
+
+       return id;
+}
+
+canid_t calc_mask(int testcase)
+{
+       canid_t mask = CAN_SFF_MASK;
+
+       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);
+
+       return mask;
+}
+
+int main(int argc, char **argv)
+{
+       fd_set rdfs;
+       struct timeval tv;
+       int s;
+       struct sockaddr_can addr;
+       struct can_filter rfilter;
+       struct can_frame frame;
+       int testcase;
+       int have_rx;
+       int rx;
+       int rxbits, rxbitval;
+       int ret;
+       int recv_own_msgs = 1;
+       struct ifreq ifr;
+
+       /* check command line options */
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s <device>\n", argv[0]);
+               return 1;
+       }
+
+       s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
+       if (s < 0) {
+               perror("socket");
+               return 1;
+       }
+
+       strcpy(ifr.ifr_name, argv[1]);
+       if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
+               perror("SIOCGIFINDEX");
+               return 1;
+       }
+       addr.can_family = AF_CAN;
+       addr.can_ifindex = ifr.ifr_ifindex;
+
+       setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
+                  &recv_own_msgs, sizeof(recv_own_msgs));
+
+       if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+               perror("bind");
+               return 1;
+       }
+
+       printf("---\n");
+
+       for (testcase = 0; testcase < TC; testcase++) {
+
+               rfilter.can_id = calc_id(testcase);
+               rfilter.can_mask = calc_mask(testcase);
+               setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER,
+                          &rfilter, sizeof(rfilter));
+
+               printf("testcase %2d filters : can_id = 0x%08X can_mask = "
+                      "0x%08X\n", testcase, rfilter.can_id, rfilter.can_mask);
+
+               printf("testcase %2d sending patterns ... ", testcase);
+
+               frame.can_dlc = 1;
+               frame.data[0] = testcase;
+
+               frame.can_id = ID;
+               if (write(s, &frame, sizeof(frame)) < 0) {
+                       perror("write");
+                       exit(1);
+               }
+               frame.can_id = (ID | CAN_RTR_FLAG);
+               if (write(s, &frame, sizeof(frame)) < 0) {
+                       perror("write");
+                       exit(1);
+               }
+               frame.can_id = (ID | CAN_EFF_FLAG);
+               if (write(s, &frame, sizeof(frame)) < 0) {
+                       perror("write");
+                       exit(1);
+               }
+               frame.can_id = (ID | CAN_EFF_FLAG | CAN_RTR_FLAG);
+               if (write(s, &frame, sizeof(frame)) < 0) {
+                       perror("write");
+                       exit(1);
+               }
+
+               printf("ok\n");
+
+               have_rx = 1;
+               rx = 0;
+               rxbits = 0;
+
+               while (have_rx) {
+
+                       have_rx = 0;
+                       FD_ZERO(&rdfs);
+                       FD_SET(s, &rdfs);
+                       tv.tv_sec = 0;
+                       tv.tv_usec = 50000;     /* 50ms timeout */
+
+                       ret = select(s + 1, &rdfs, NULL, NULL, &tv);
+                       if (ret < 0) {
+                               perror("select");
+                               exit(1);
+                       }
+
+                       if (FD_ISSET(s, &rdfs)) {
+                               have_rx = 1;
+                               ret = read(s, &frame, sizeof(struct can_frame));
+                               if (ret < 0) {
+                                       perror("read");
+                                       exit(1);
+                               }
+                               if ((frame.can_id & CAN_SFF_MASK) != ID) {
+                                       fprintf(stderr,
+                                               "received wrong can_id!\n");
+                                       exit(1);
+                               }
+                               if (frame.data[0] != testcase) {
+                                       fprintf(stderr,
+                                               "received wrong testcase!\n");
+                                       exit(1);
+                               }
+
+                               /* test & calc rxbits */
+                               rxbitval = 1 << ((frame.can_id &
+                                                (CAN_EFF_FLAG | CAN_RTR_FLAG |
+                                                 CAN_ERR_FLAG)) >> 28);
+
+                               /* only receive a rxbitval once */
+                               if ((rxbits & rxbitval) == rxbitval) {
+                                       fprintf(stderr,
+                                               "received rxbitval %d twice!\n",
+                                               rxbitval);
+                                       exit(1);
+                               }
+                               rxbits |= rxbitval;
+                               rx++;
+
+                               printf("testcase %2d rx : can_id = 0x%08X rx = "
+                                      "%d rxbits = %d\n", testcase,
+                                      frame.can_id, rx, rxbits);
+                       }
+               }
+               /* rx timed out -> check the received results */
+               if (rx_res[testcase] != rx) {
+                       fprintf(stderr,
+                               "wrong rx value in testcase %d : %d (expected "
+                               "%d)\n", testcase, rx, rx_res[testcase]);
+                       exit(1);
+               }
+               if (rxbits_res[testcase] != rxbits) {
+                       fprintf(stderr,
+                               "wrong rxbits value in testcase %d : %d "
+                               "(expected %d)\n", testcase, rxbits,
+                               rxbits_res[testcase]);
+                       exit(1);
+               }
+               printf("testcase %2d ok\n---\n", testcase);
+       }
+
+       close(s);
+
+       return 0;
+}
+
+#else
+
+int main(void)
+{
+       printf("The linux/can.h was missing upon compilation.\n");
+       return 0;
+}
+
+#endif /* HAVE_LINUX_CAN_H */
diff --git a/testcases/network/can/filter-tests/can_rcv_own_msgs.c 
b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
new file mode 100644
index 0000000..233bd66
--- /dev/null
+++ b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
@@ -0,0 +1,256 @@
+/*
+ * tst-rcv-own-msgs.c
+ *
+ * Copyright (c) 2010 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-us...@lists.berlios.de>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <net/if.h>
+#include "config.h"
+
+#ifdef HAVE_LINUX_CAN_H
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#define max(a, b) ((a) > (b) ? (a) : (b))
+
+struct rxs {
+       int s;
+       int t;
+};
+
+struct rxs test_sockets(int s, int t, canid_t can_id)
+{
+       fd_set rdfs;
+       struct timeval tv;
+       int m = max(s, t) + 1;
+       int have_rx = 1;
+       struct can_frame frame;
+       struct rxs rx;
+       int ret;
+
+       frame.can_id = can_id;
+       frame.can_dlc = 0;
+       if (write(s, &frame, sizeof(frame)) < 0) {
+               perror("write");
+               exit(1);
+       }
+
+       rx.s = rx.t = 0;
+
+       while (have_rx) {
+
+               FD_ZERO(&rdfs);
+               FD_SET(s, &rdfs);
+               FD_SET(t, &rdfs);
+               tv.tv_sec = 0;
+               tv.tv_usec = 50000;     /* 50ms timeout */
+               have_rx = 0;
+
+               ret = select(m, &rdfs, NULL, NULL, &tv);
+               if (ret < 0) {
+                       perror("select");
+                       exit(1);
+               }
+
+               if (FD_ISSET(s, &rdfs)) {
+
+                       have_rx = 1;
+                       ret = read(s, &frame, sizeof(struct can_frame));
+                       if (ret < 0) {
+                               perror("read");
+                               exit(1);
+                       }
+                       if (frame.can_id != can_id) {
+                               fprintf(stderr, "received wrong can_id!\n");
+                               exit(1);
+                       }
+                       rx.s++;
+               }
+
+               if (FD_ISSET(t, &rdfs)) {
+
+                       have_rx = 1;
+                       ret = read(t, &frame, sizeof(struct can_frame));
+                       if (ret < 0) {
+                               perror("read");
+                               exit(1);
+                       }
+                       if (frame.can_id != can_id) {
+                               fprintf(stderr, "received wrong can_id!\n");
+                               exit(1);
+                       }
+                       rx.t++;
+               }
+       }
+
+       /* timeout */
+
+       return rx;
+}
+
+void setopts(int s, int loopback, int recv_own_msgs)
+{
+       setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback,
+                  sizeof(loopback));
+       setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, &recv_own_msgs,
+                  sizeof(recv_own_msgs));
+
+       printf("check loopback %d recv_own_msgs %d ... ", loopback,
+              recv_own_msgs);
+}
+
+int main(int argc, char **argv)
+{
+       int s, t;
+       struct sockaddr_can addr;
+       struct ifreq ifr;
+       struct rxs rx;
+
+       /* check command line options */
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s <device>\n", argv[0]);
+               return 1;
+       }
+
+       s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
+       if (s < 0) {
+               perror("socket");
+               return 1;
+       }
+       t = socket(PF_CAN, SOCK_RAW, CAN_RAW);
+       if (t < 0) {
+               perror("socket");
+               return 1;
+       }
+
+       strcpy(ifr.ifr_name, argv[1]);
+       if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
+               perror("SIOCGIFINDEX");
+               return 1;
+       }
+       addr.can_ifindex = ifr.ifr_ifindex;
+       addr.can_family = AF_CAN;
+
+       if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+               perror("bind");
+               return 1;
+       }
+       if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+               perror("bind");
+               return 1;
+       }
+
+       printf("Starting PF_CAN frame flow test.\n");
+       printf("checking socket default settings ... ");
+       rx = test_sockets(s, t, 0x340);
+       if (rx.s == 0 && rx.t == 1)
+               printf("ok.\n");
+       else {
+               printf("failure!\n");
+               return 1;
+       }
+
+       /* check loopback 0 recv_own_msgs 0 */
+       setopts(s, 0, 0);
+       rx = test_sockets(s, t, 0x341);
+       if (rx.s == 0 && rx.t == 0)
+               printf("ok.\n");
+       else {
+               printf("failure!\n");
+               return 1;
+       }
+
+       /* check loopback 0 recv_own_msgs 1 */
+       setopts(s, 0, 1);
+       rx = test_sockets(s, t, 0x342);
+       if (rx.s == 0 && rx.t == 0)
+               printf("ok.\n");
+       else {
+               printf("failure!\n");
+               return 1;
+       }
+
+       /* check loopback 1 recv_own_msgs 0 */
+       setopts(s, 1, 0);
+       rx = test_sockets(s, t, 0x343);
+       if (rx.s == 0 && rx.t == 1)
+               printf("ok.\n");
+       else {
+               printf("failure!\n");
+               return 1;
+       }
+
+       /* check loopback 1 recv_own_msgs 1 */
+       setopts(s, 1, 1);
+       rx = test_sockets(s, t, 0x344);
+       if (rx.s == 1 && rx.t == 1)
+               printf("ok.\n");
+       else {
+               printf("failure!\n");
+               return 1;
+       }
+
+       printf("PF_CAN frame flow test was successful.\n");
+
+       close(s);
+       close(t);
+
+       return 0;
+}
+
+#else
+
+int main(void)
+{
+       printf("The linux/can.h was missing upon compilation.\n");
+       return 0;
+}
+
+#endif /* HAVE_LINUX_CAN_H */
diff --git a/testcases/network/can/filter-tests/can_run_tests.sh 
b/testcases/network/can/filter-tests/can_run_tests.sh
new file mode 100644
index 0000000..cd43875
--- /dev/null
+++ b/testcases/network/can/filter-tests/can_run_tests.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+################################################################################
+## Copyright (c) Oliver Hartkopp <oliver.hartk...@volkswagen.de>, 2011        
##
+## Copyright (c) International Business Machines  Corp., 2009                 
##
+##                                                                            
##
+## 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           
##
+##                                                                            
##
+################################################################################
+
+TCID="$1"
+TST_TOTAL=1
+export TST_COUNT
+
+. test.sh
+
+setup()
+{
+       tst_require_root
+
+       # load needed CAN networklayer modules
+       modprobe can
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               tst_brkm TCONF "modprobe can failed: ret - $ret"
+       fi
+
+       modprobe can_raw
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               tst_brkm TCONF "modprobe can_raw failed: ret - $ret"
+       fi
+
+       # ensure the vcan driver to perform the ECHO on driver level
+       modprobe -r vcan
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               tst_brkm TCONF "modprobe -r vcan failed: ret - $ret"
+       fi
+
+       modprobe vcan echo=1
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               tst_brkm TCONF "modprobe vcan echo=1 failed: ret - $ret"
+       fi
+
+       VCAN=vcan0
+
+       # create virtual CAN device
+       ip link add dev $VCAN type vcan
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               tst_brkm TBROK
+                        "ip link add dev $VCAN type vcan failed: ret - $ret"
+       fi
+
+       ip link set dev $VCAN up
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               tst_brkm TBROK "ip link set dev $VCAN up failed: ret - $ret"
+       fi
+
+       # check precondition for CAN frame flow test
+       HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
+       if [ $HAS_ECHO -ne 1 ]; then
+               tst_brkm TBROK "ECHO is not 1"
+       fi
+}
+
+cleanup()
+{
+       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
+       tst_brkm TBROK "Usage: $0 [can_filter | can_rcv_own_msgs]"
+fi
+
+setup
+TST_CLEANUP=cleanup
+
+"$1" "$VCAN"
+ret=$?
+
+if [ $ret -ne 0 ]; then
+       tst_resm TFAIL "Test $1 FAIL with exit number: $ret"
+else
+       tst_resm TPASS "Test $1 PASS"
+fi
+
+tst_exit
diff --git a/testcases/network/can/filter-tests/run_ltp-can_tests.sh 
b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
deleted file mode 100644
index cd43875..0000000
--- a/testcases/network/can/filter-tests/run_ltp-can_tests.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/sh
-################################################################################
-## Copyright (c) Oliver Hartkopp <oliver.hartk...@volkswagen.de>, 2011        
##
-## Copyright (c) International Business Machines  Corp., 2009                 
##
-##                                                                            
##
-## 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           
##
-##                                                                            
##
-################################################################################
-
-TCID="$1"
-TST_TOTAL=1
-export TST_COUNT
-
-. test.sh
-
-setup()
-{
-       tst_require_root
-
-       # load needed CAN networklayer modules
-       modprobe can
-       ret=$?
-       if [ $ret -ne 0 ]; then
-               tst_brkm TCONF "modprobe can failed: ret - $ret"
-       fi
-
-       modprobe can_raw
-       ret=$?
-       if [ $ret -ne 0 ]; then
-               tst_brkm TCONF "modprobe can_raw failed: ret - $ret"
-       fi
-
-       # ensure the vcan driver to perform the ECHO on driver level
-       modprobe -r vcan
-       ret=$?
-       if [ $ret -ne 0 ]; then
-               tst_brkm TCONF "modprobe -r vcan failed: ret - $ret"
-       fi
-
-       modprobe vcan echo=1
-       ret=$?
-       if [ $ret -ne 0 ]; then
-               tst_brkm TCONF "modprobe vcan echo=1 failed: ret - $ret"
-       fi
-
-       VCAN=vcan0
-
-       # create virtual CAN device
-       ip link add dev $VCAN type vcan
-       ret=$?
-       if [ $ret -ne 0 ]; then
-               tst_brkm TBROK
-                        "ip link add dev $VCAN type vcan failed: ret - $ret"
-       fi
-
-       ip link set dev $VCAN up
-       ret=$?
-       if [ $ret -ne 0 ]; then
-               tst_brkm TBROK "ip link set dev $VCAN up failed: ret - $ret"
-       fi
-
-       # check precondition for CAN frame flow test
-       HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
-       if [ $HAS_ECHO -ne 1 ]; then
-               tst_brkm TBROK "ECHO is not 1"
-       fi
-}
-
-cleanup()
-{
-       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
-       tst_brkm TBROK "Usage: $0 [can_filter | can_rcv_own_msgs]"
-fi
-
-setup
-TST_CLEANUP=cleanup
-
-"$1" "$VCAN"
-ret=$?
-
-if [ $ret -ne 0 ]; then
-       tst_resm TFAIL "Test $1 FAIL with exit number: $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
deleted file mode 100644
index b24e339..0000000
--- a/testcases/network/can/filter-tests/tst-filter.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * tst-filter.c
- *
- * Copyright (c) 2011 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-us...@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <net/if.h>
-#include "config.h"
-
-#ifdef HAVE_LINUX_CAN_H
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define ID 0x123
-#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 };
-
-canid_t calc_id(int testcase)
-{
-       canid_t id = ID;
-
-       if (testcase & 1)
-               id |= CAN_EFF_FLAG;
-       if (testcase & 2)
-               id |= CAN_RTR_FLAG;
-
-       return id;
-}
-
-canid_t calc_mask(int testcase)
-{
-       canid_t mask = CAN_SFF_MASK;
-
-       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);
-
-       return mask;
-}
-
-int main(int argc, char **argv)
-{
-       fd_set rdfs;
-       struct timeval tv;
-       int s;
-       struct sockaddr_can addr;
-       struct can_filter rfilter;
-       struct can_frame frame;
-       int testcase;
-       int have_rx;
-       int rx;
-       int rxbits, rxbitval;
-       int ret;
-       int recv_own_msgs = 1;
-       struct ifreq ifr;
-
-       /* check command line options */
-       if (argc != 2) {
-               fprintf(stderr, "Usage: %s <device>\n", argv[0]);
-               return 1;
-       }
-
-       s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-       if (s < 0) {
-               perror("socket");
-               return 1;
-       }
-
-       strcpy(ifr.ifr_name, argv[1]);
-       if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-               perror("SIOCGIFINDEX");
-               return 1;
-       }
-       addr.can_family = AF_CAN;
-       addr.can_ifindex = ifr.ifr_ifindex;
-
-       setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
-                  &recv_own_msgs, sizeof(recv_own_msgs));
-
-       if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-               perror("bind");
-               return 1;
-       }
-
-       printf("---\n");
-
-       for (testcase = 0; testcase < TC; testcase++) {
-
-               rfilter.can_id = calc_id(testcase);
-               rfilter.can_mask = calc_mask(testcase);
-               setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER,
-                          &rfilter, sizeof(rfilter));
-
-               printf("testcase %2d filters : can_id = 0x%08X can_mask = "
-                      "0x%08X\n", testcase, rfilter.can_id, rfilter.can_mask);
-
-               printf("testcase %2d sending patterns ... ", testcase);
-
-               frame.can_dlc = 1;
-               frame.data[0] = testcase;
-
-               frame.can_id = ID;
-               if (write(s, &frame, sizeof(frame)) < 0) {
-                       perror("write");
-                       exit(1);
-               }
-               frame.can_id = (ID | CAN_RTR_FLAG);
-               if (write(s, &frame, sizeof(frame)) < 0) {
-                       perror("write");
-                       exit(1);
-               }
-               frame.can_id = (ID | CAN_EFF_FLAG);
-               if (write(s, &frame, sizeof(frame)) < 0) {
-                       perror("write");
-                       exit(1);
-               }
-               frame.can_id = (ID | CAN_EFF_FLAG | CAN_RTR_FLAG);
-               if (write(s, &frame, sizeof(frame)) < 0) {
-                       perror("write");
-                       exit(1);
-               }
-
-               printf("ok\n");
-
-               have_rx = 1;
-               rx = 0;
-               rxbits = 0;
-
-               while (have_rx) {
-
-                       have_rx = 0;
-                       FD_ZERO(&rdfs);
-                       FD_SET(s, &rdfs);
-                       tv.tv_sec = 0;
-                       tv.tv_usec = 50000;     /* 50ms timeout */
-
-                       ret = select(s + 1, &rdfs, NULL, NULL, &tv);
-                       if (ret < 0) {
-                               perror("select");
-                               exit(1);
-                       }
-
-                       if (FD_ISSET(s, &rdfs)) {
-                               have_rx = 1;
-                               ret = read(s, &frame, sizeof(struct can_frame));
-                               if (ret < 0) {
-                                       perror("read");
-                                       exit(1);
-                               }
-                               if ((frame.can_id & CAN_SFF_MASK) != ID) {
-                                       fprintf(stderr,
-                                               "received wrong can_id!\n");
-                                       exit(1);
-                               }
-                               if (frame.data[0] != testcase) {
-                                       fprintf(stderr,
-                                               "received wrong testcase!\n");
-                                       exit(1);
-                               }
-
-                               /* test & calc rxbits */
-                               rxbitval = 1 << ((frame.can_id &
-                                                (CAN_EFF_FLAG | CAN_RTR_FLAG |
-                                                 CAN_ERR_FLAG)) >> 28);
-
-                               /* only receive a rxbitval once */
-                               if ((rxbits & rxbitval) == rxbitval) {
-                                       fprintf(stderr,
-                                               "received rxbitval %d twice!\n",
-                                               rxbitval);
-                                       exit(1);
-                               }
-                               rxbits |= rxbitval;
-                               rx++;
-
-                               printf("testcase %2d rx : can_id = 0x%08X rx = "
-                                      "%d rxbits = %d\n", testcase,
-                                      frame.can_id, rx, rxbits);
-                       }
-               }
-               /* rx timed out -> check the received results */
-               if (rx_res[testcase] != rx) {
-                       fprintf(stderr,
-                               "wrong rx value in testcase %d : %d (expected "
-                               "%d)\n", testcase, rx, rx_res[testcase]);
-                       exit(1);
-               }
-               if (rxbits_res[testcase] != rxbits) {
-                       fprintf(stderr,
-                               "wrong rxbits value in testcase %d : %d "
-                               "(expected %d)\n", testcase, rxbits,
-                               rxbits_res[testcase]);
-                       exit(1);
-               }
-               printf("testcase %2d ok\n---\n", testcase);
-       }
-
-       close(s);
-
-       return 0;
-}
-
-#else
-
-int main(void)
-{
-       printf("The linux/can.h was missing upon compilation.\n");
-       return 0;
-}
-
-#endif /* HAVE_LINUX_CAN_H */
diff --git a/testcases/network/can/filter-tests/tst-rcv-own-msgs.c 
b/testcases/network/can/filter-tests/tst-rcv-own-msgs.c
deleted file mode 100644
index 233bd66..0000000
--- a/testcases/network/can/filter-tests/tst-rcv-own-msgs.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * tst-rcv-own-msgs.c
- *
- * Copyright (c) 2010 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-us...@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <net/if.h>
-#include "config.h"
-
-#ifdef HAVE_LINUX_CAN_H
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define max(a, b) ((a) > (b) ? (a) : (b))
-
-struct rxs {
-       int s;
-       int t;
-};
-
-struct rxs test_sockets(int s, int t, canid_t can_id)
-{
-       fd_set rdfs;
-       struct timeval tv;
-       int m = max(s, t) + 1;
-       int have_rx = 1;
-       struct can_frame frame;
-       struct rxs rx;
-       int ret;
-
-       frame.can_id = can_id;
-       frame.can_dlc = 0;
-       if (write(s, &frame, sizeof(frame)) < 0) {
-               perror("write");
-               exit(1);
-       }
-
-       rx.s = rx.t = 0;
-
-       while (have_rx) {
-
-               FD_ZERO(&rdfs);
-               FD_SET(s, &rdfs);
-               FD_SET(t, &rdfs);
-               tv.tv_sec = 0;
-               tv.tv_usec = 50000;     /* 50ms timeout */
-               have_rx = 0;
-
-               ret = select(m, &rdfs, NULL, NULL, &tv);
-               if (ret < 0) {
-                       perror("select");
-                       exit(1);
-               }
-
-               if (FD_ISSET(s, &rdfs)) {
-
-                       have_rx = 1;
-                       ret = read(s, &frame, sizeof(struct can_frame));
-                       if (ret < 0) {
-                               perror("read");
-                               exit(1);
-                       }
-                       if (frame.can_id != can_id) {
-                               fprintf(stderr, "received wrong can_id!\n");
-                               exit(1);
-                       }
-                       rx.s++;
-               }
-
-               if (FD_ISSET(t, &rdfs)) {
-
-                       have_rx = 1;
-                       ret = read(t, &frame, sizeof(struct can_frame));
-                       if (ret < 0) {
-                               perror("read");
-                               exit(1);
-                       }
-                       if (frame.can_id != can_id) {
-                               fprintf(stderr, "received wrong can_id!\n");
-                               exit(1);
-                       }
-                       rx.t++;
-               }
-       }
-
-       /* timeout */
-
-       return rx;
-}
-
-void setopts(int s, int loopback, int recv_own_msgs)
-{
-       setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback,
-                  sizeof(loopback));
-       setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, &recv_own_msgs,
-                  sizeof(recv_own_msgs));
-
-       printf("check loopback %d recv_own_msgs %d ... ", loopback,
-              recv_own_msgs);
-}
-
-int main(int argc, char **argv)
-{
-       int s, t;
-       struct sockaddr_can addr;
-       struct ifreq ifr;
-       struct rxs rx;
-
-       /* check command line options */
-       if (argc != 2) {
-               fprintf(stderr, "Usage: %s <device>\n", argv[0]);
-               return 1;
-       }
-
-       s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-       if (s < 0) {
-               perror("socket");
-               return 1;
-       }
-       t = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-       if (t < 0) {
-               perror("socket");
-               return 1;
-       }
-
-       strcpy(ifr.ifr_name, argv[1]);
-       if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-               perror("SIOCGIFINDEX");
-               return 1;
-       }
-       addr.can_ifindex = ifr.ifr_ifindex;
-       addr.can_family = AF_CAN;
-
-       if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-               perror("bind");
-               return 1;
-       }
-       if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-               perror("bind");
-               return 1;
-       }
-
-       printf("Starting PF_CAN frame flow test.\n");
-       printf("checking socket default settings ... ");
-       rx = test_sockets(s, t, 0x340);
-       if (rx.s == 0 && rx.t == 1)
-               printf("ok.\n");
-       else {
-               printf("failure!\n");
-               return 1;
-       }
-
-       /* check loopback 0 recv_own_msgs 0 */
-       setopts(s, 0, 0);
-       rx = test_sockets(s, t, 0x341);
-       if (rx.s == 0 && rx.t == 0)
-               printf("ok.\n");
-       else {
-               printf("failure!\n");
-               return 1;
-       }
-
-       /* check loopback 0 recv_own_msgs 1 */
-       setopts(s, 0, 1);
-       rx = test_sockets(s, t, 0x342);
-       if (rx.s == 0 && rx.t == 0)
-               printf("ok.\n");
-       else {
-               printf("failure!\n");
-               return 1;
-       }
-
-       /* check loopback 1 recv_own_msgs 0 */
-       setopts(s, 1, 0);
-       rx = test_sockets(s, t, 0x343);
-       if (rx.s == 0 && rx.t == 1)
-               printf("ok.\n");
-       else {
-               printf("failure!\n");
-               return 1;
-       }
-
-       /* check loopback 1 recv_own_msgs 1 */
-       setopts(s, 1, 1);
-       rx = test_sockets(s, t, 0x344);
-       if (rx.s == 1 && rx.t == 1)
-               printf("ok.\n");
-       else {
-               printf("failure!\n");
-               return 1;
-       }
-
-       printf("PF_CAN frame flow test was successful.\n");
-
-       close(s);
-       close(t);
-
-       return 0;
-}
-
-#else
-
-int main(void)
-{
-       printf("The linux/can.h was missing upon compilation.\n");
-       return 0;
-}
-
-#endif /* HAVE_LINUX_CAN_H */
-- 
1.9.3




------------------------------------------------------------------------------
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

Reply via email to