All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Convert CAN tests to new LTP API
@ 2021-01-19  9:31 ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp; +Cc: linux-can, Oliver Hartkopp, Richard Palethorpe

Hello,

This is an attempt to convert the CAN tests to the (modern) Linux Test
Project API and removes the wrapper script. To be clear, this is a
patch-set for the LTP *not* the kernel tree or can-utils.

I have tried to keep the core test behaviour the same, but (for
example) moving to the SAFE_ functions will naturally introduce some
changes in error checking. Deliberate behavioral changes have been
noted in the commit messages.

FYI, we appear to have 4 CAN tests in LTP including two tests for
SLCAN (pty03, pty04).

V2: Update e-mail addresses and resend

Richard Palethorpe (6):
  API: Add FILE_SCANF to new lib
  can: Add can_common.h for vcan device setup
  can_filter: Convert to new library
  can_recv_own_msgs: Convert to new library
  can: Remove obsolete test wrapper script
  can: Update contact details

 include/tst_safe_file_ops.h                   |   3 +
 testcases/network/can/Makefile                |   2 -
 .../can/filter-tests/00_Descriptions.txt      |   6 +-
 testcases/network/can/filter-tests/INSTALL    |   3 +-
 testcases/network/can/filter-tests/Makefile   |   4 -
 .../network/can/filter-tests/can_common.h     |  70 ++++
 .../network/can/filter-tests/can_filter.c     | 317 +++++++-----------
 .../can/filter-tests/can_rcv_own_msgs.c       | 273 +++++----------
 .../network/can/filter-tests/can_run_tests.sh | 106 ------
 9 files changed, 291 insertions(+), 493 deletions(-)
 create mode 100644 testcases/network/can/filter-tests/can_common.h
 delete mode 100755 testcases/network/can/filter-tests/can_run_tests.sh

-- 
2.29.2


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

* [LTP] [PATCH v2 0/6] Convert CAN tests to new LTP API
@ 2021-01-19  9:31 ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp

Hello,

This is an attempt to convert the CAN tests to the (modern) Linux Test
Project API and removes the wrapper script. To be clear, this is a
patch-set for the LTP *not* the kernel tree or can-utils.

I have tried to keep the core test behaviour the same, but (for
example) moving to the SAFE_ functions will naturally introduce some
changes in error checking. Deliberate behavioral changes have been
noted in the commit messages.

FYI, we appear to have 4 CAN tests in LTP including two tests for
SLCAN (pty03, pty04).

V2: Update e-mail addresses and resend

Richard Palethorpe (6):
  API: Add FILE_SCANF to new lib
  can: Add can_common.h for vcan device setup
  can_filter: Convert to new library
  can_recv_own_msgs: Convert to new library
  can: Remove obsolete test wrapper script
  can: Update contact details

 include/tst_safe_file_ops.h                   |   3 +
 testcases/network/can/Makefile                |   2 -
 .../can/filter-tests/00_Descriptions.txt      |   6 +-
 testcases/network/can/filter-tests/INSTALL    |   3 +-
 testcases/network/can/filter-tests/Makefile   |   4 -
 .../network/can/filter-tests/can_common.h     |  70 ++++
 .../network/can/filter-tests/can_filter.c     | 317 +++++++-----------
 .../can/filter-tests/can_rcv_own_msgs.c       | 273 +++++----------
 .../network/can/filter-tests/can_run_tests.sh | 106 ------
 9 files changed, 291 insertions(+), 493 deletions(-)
 create mode 100644 testcases/network/can/filter-tests/can_common.h
 delete mode 100755 testcases/network/can/filter-tests/can_run_tests.sh

-- 
2.29.2


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

* [PATCH v2 1/6] API: Add FILE_SCANF to new lib
  2021-01-19  9:31 ` [LTP] " Richard Palethorpe
@ 2021-01-19  9:31   ` Richard Palethorpe
  -1 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp; +Cc: linux-can, Oliver Hartkopp, Richard Palethorpe

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 include/tst_safe_file_ops.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/tst_safe_file_ops.h b/include/tst_safe_file_ops.h
index 894c16123..ea8f89263 100644
--- a/include/tst_safe_file_ops.h
+++ b/include/tst_safe_file_ops.h
@@ -7,6 +7,9 @@
 
 #include "safe_file_ops_fn.h"
 
+#define FILE_SCANF(path, fmt, ...) \
+	file_scanf(__FILE__, __LINE__, (path), (fmt), ## __VA_ARGS__)
+
 #define SAFE_FILE_SCANF(path, fmt, ...) \
 	safe_file_scanf(__FILE__, __LINE__, NULL, \
 	                (path), (fmt), ## __VA_ARGS__)
-- 
2.29.2


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

* [LTP] [PATCH v2 1/6] API: Add FILE_SCANF to new lib
@ 2021-01-19  9:31   ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 include/tst_safe_file_ops.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/tst_safe_file_ops.h b/include/tst_safe_file_ops.h
index 894c16123..ea8f89263 100644
--- a/include/tst_safe_file_ops.h
+++ b/include/tst_safe_file_ops.h
@@ -7,6 +7,9 @@
 
 #include "safe_file_ops_fn.h"
 
+#define FILE_SCANF(path, fmt, ...) \
+	file_scanf(__FILE__, __LINE__, (path), (fmt), ## __VA_ARGS__)
+
 #define SAFE_FILE_SCANF(path, fmt, ...) \
 	safe_file_scanf(__FILE__, __LINE__, NULL, \
 	                (path), (fmt), ## __VA_ARGS__)
-- 
2.29.2


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

* [PATCH v2 2/6] can: Add can_common.h for vcan device setup
  2021-01-19  9:31 ` [LTP] " Richard Palethorpe
@ 2021-01-19  9:31   ` Richard Palethorpe
  -1 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp; +Cc: linux-can, Oliver Hartkopp, Richard Palethorpe

Note that we call modprobe to set echo=1. However this does seem to be
necessary for the current tests on 5.10. It has been kept to avoid
changing the test behavior unnecessarily, but can most likely be
safely removed if it causes problems.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../network/can/filter-tests/can_common.h     | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 testcases/network/can/filter-tests/can_common.h

diff --git a/testcases/network/can/filter-tests/can_common.h b/testcases/network/can/filter-tests/can_common.h
new file mode 100644
index 000000000..d01694b80
--- /dev/null
+++ b/testcases/network/can/filter-tests/can_common.h
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 SUSE LLC
+ */
+
+#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 "tst_cmd.h"
+#include "tst_safe_stdio.h"
+#include "tst_safe_file_ops.h"
+
+#include <linux/if.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+static char *can_dev_name;
+static int can_created_dev;
+
+static void can_cmd(const char *const argv[])
+{
+	tst_cmd(argv, NULL, NULL, TST_CMD_TCONF_ON_MISSING);
+}
+
+#define CAN_CMD(...) can_cmd((const char *const[]){ __VA_ARGS__, NULL })
+
+static void can_setup_vcan(void)
+{
+	unsigned int flags;
+	char *path;
+
+	if (can_dev_name)
+		goto check_echo;
+
+	can_dev_name = "vcan0";
+
+	tst_res(TINFO, "Creating vcan0 device; use -D option to avoid this");
+
+	CAN_CMD("modprobe", "-r", "vcan");
+	CAN_CMD("modprobe", "vcan", "echo=1");
+
+	can_created_dev = 1;
+
+	CAN_CMD("ip", "link", "add", "dev", "vcan0", "type", "vcan");
+	CAN_CMD("ip", "link", "set", "dev", "vcan0", "up");
+
+check_echo:
+	/* Precondition for the frame flow test? */
+	SAFE_ASPRINTF(&path, "/sys/class/net/%s/flags", can_dev_name);
+	if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
+		tst_res(TWARN, "Could not determine if ECHO is set on vcan0");
+}
+
+static void can_cleanup_vcan(void)
+{
+	if (!can_created_dev)
+		return;
+
+	CAN_CMD("ip", "link", "set", "dev", "vcan0", "down");
+	CAN_CMD("ip", "link", "del", "dev", "vcan0");
+	CAN_CMD("modprobe", "-r", "vcan");
+}
-- 
2.29.2


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

* [LTP] [PATCH v2 2/6] can: Add can_common.h for vcan device setup
@ 2021-01-19  9:31   ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp

Note that we call modprobe to set echo=1. However this does seem to be
necessary for the current tests on 5.10. It has been kept to avoid
changing the test behavior unnecessarily, but can most likely be
safely removed if it causes problems.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../network/can/filter-tests/can_common.h     | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 testcases/network/can/filter-tests/can_common.h

diff --git a/testcases/network/can/filter-tests/can_common.h b/testcases/network/can/filter-tests/can_common.h
new file mode 100644
index 000000000..d01694b80
--- /dev/null
+++ b/testcases/network/can/filter-tests/can_common.h
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 SUSE LLC
+ */
+
+#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 "tst_cmd.h"
+#include "tst_safe_stdio.h"
+#include "tst_safe_file_ops.h"
+
+#include <linux/if.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+static char *can_dev_name;
+static int can_created_dev;
+
+static void can_cmd(const char *const argv[])
+{
+	tst_cmd(argv, NULL, NULL, TST_CMD_TCONF_ON_MISSING);
+}
+
+#define CAN_CMD(...) can_cmd((const char *const[]){ __VA_ARGS__, NULL })
+
+static void can_setup_vcan(void)
+{
+	unsigned int flags;
+	char *path;
+
+	if (can_dev_name)
+		goto check_echo;
+
+	can_dev_name = "vcan0";
+
+	tst_res(TINFO, "Creating vcan0 device; use -D option to avoid this");
+
+	CAN_CMD("modprobe", "-r", "vcan");
+	CAN_CMD("modprobe", "vcan", "echo=1");
+
+	can_created_dev = 1;
+
+	CAN_CMD("ip", "link", "add", "dev", "vcan0", "type", "vcan");
+	CAN_CMD("ip", "link", "set", "dev", "vcan0", "up");
+
+check_echo:
+	/* Precondition for the frame flow test? */
+	SAFE_ASPRINTF(&path, "/sys/class/net/%s/flags", can_dev_name);
+	if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
+		tst_res(TWARN, "Could not determine if ECHO is set on vcan0");
+}
+
+static void can_cleanup_vcan(void)
+{
+	if (!can_created_dev)
+		return;
+
+	CAN_CMD("ip", "link", "set", "dev", "vcan0", "down");
+	CAN_CMD("ip", "link", "del", "dev", "vcan0");
+	CAN_CMD("modprobe", "-r", "vcan");
+}
-- 
2.29.2


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

* [PATCH v2 3/6] can_filter: Convert to new library
  2021-01-19  9:31 ` [LTP] " Richard Palethorpe
@ 2021-01-19  9:31   ` Richard Palethorpe
  -1 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp; +Cc: linux-can, Oliver Hartkopp, Richard Palethorpe

Behavior is mostly the same, but on some errors we print fail and
continue instead of exiting immediately. It appears this would result
in more information being printed if there is a failure.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../network/can/filter-tests/can_filter.c     | 317 +++++++-----------
 1 file changed, 124 insertions(+), 193 deletions(-)

diff --git a/testcases/network/can/filter-tests/can_filter.c b/testcases/network/can/filter-tests/can_filter.c
index db017451a..d14e42fac 100644
--- a/testcases/network/can/filter-tests/can_filter.c
+++ b/testcases/network/can/filter-tests/can_filter.c
@@ -1,63 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * 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-users@lists.berlios.de>
- *
+ * Copyright (c) 2021 SUSE LLC
  */
 
-#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"
-#include "tst_res_flags.h"
+#include "tst_test.h"
 
 #ifdef HAVE_LINUX_CAN_H
 
-#include <linux/can.h>
-#include <linux/can/raw.h>
+#include "can_common.h"
 
 #define ID 0x123
 #define TC 18			/* # of testcases */
@@ -66,7 +18,9 @@ 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)
+static int s;
+
+static canid_t calc_id(int testcase)
 {
 	canid_t id = ID;
 
@@ -78,7 +32,7 @@ canid_t calc_id(int testcase)
 	return id;
 }
 
-canid_t calc_mask(int testcase)
+static canid_t calc_mask(int testcase)
 {
 	canid_t mask = CAN_SFF_MASK;
 
@@ -93,174 +47,151 @@ canid_t calc_mask(int testcase)
 	return mask;
 }
 
-int main(int argc, char **argv)
+static void setup(void)
 {
-	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;
+	int recv_own_msgs = 1;
 
-	/* check command line options */
-	if (argc != 2) {
-		fprintf(stderr, "Usage: %s <device>\n", argv[0]);
-		return TFAIL;
-	}
+	can_setup_vcan();
 
-	s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-	if (s < 0) {
-		perror("socket");
-		return TFAIL;
-	}
+	s = SAFE_SOCKET(PF_CAN, SOCK_RAW, CAN_RAW);
+
+	strcpy(ifr.ifr_name, can_dev_name);
+	SAFE_IOCTL(s, SIOCGIFINDEX, &ifr);
 
-	strcpy(ifr.ifr_name, argv[1]);
-	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-		perror("SIOCGIFINDEX");
-		return TFAIL;
-	}
 	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));
+	SAFE_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 TFAIL;
-	}
+	SAFE_BIND(s, (struct sockaddr *)&addr, sizeof(addr));
+}
 
-	printf("---\n");
+static void cleanup(void)
+{
+	if (s)
+		SAFE_CLOSE(s);
 
-	for (testcase = 0; testcase < TC; testcase++) {
+	can_cleanup_vcan();
+}
 
-		rfilter.can_id = calc_id(testcase);
-		rfilter.can_mask = calc_mask(testcase);
-		setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER,
-			   &rfilter, sizeof(rfilter));
+static void run(unsigned int n)
+{
+	fd_set rdfs;
+	struct timeval tv;
+	struct can_frame frame;
+	static struct can_filter rfilter;
+	int testcase = n;
+	int have_rx = 1;
+	int rx = 0;
+	int rxbits = 0, rxbitval;
 
-		printf("testcase %2d filters : can_id = 0x%08X can_mask = "
-		       "0x%08X\n", testcase, rfilter.can_id, rfilter.can_mask);
+	rfilter.can_id = calc_id(testcase);
+	rfilter.can_mask = calc_mask(testcase);
+	SAFE_SETSOCKOPT(s, SOL_CAN_RAW, CAN_RAW_FILTER,
+			&rfilter, sizeof(rfilter));
 
-		printf("testcase %2d sending patterns ... ", testcase);
+	tst_res(TINFO, "testcase %2d filters : can_id = 0x%08X can_mask = "
+	       "0x%08X", testcase, rfilter.can_id, rfilter.can_mask);
 
-		frame.can_dlc = 1;
-		frame.data[0] = testcase;
+	tst_res(TINFO, "testcase %2d sending patterns ... ", 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);
-		}
+	frame.can_dlc = 1;
+	frame.data[0] = testcase;
 
-		printf("ok\n");
+	frame.can_id = ID;
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-		have_rx = 1;
-		rx = 0;
-		rxbits = 0;
+	frame.can_id = (ID | CAN_RTR_FLAG);
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-		while (have_rx) {
+	frame.can_id = (ID | CAN_EFF_FLAG);
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-			have_rx = 0;
-			FD_ZERO(&rdfs);
-			FD_SET(s, &rdfs);
-			tv.tv_sec = 0;
-			tv.tv_usec = 50000;	/* 50ms timeout */
+	frame.can_id = (ID | CAN_EFF_FLAG | CAN_RTR_FLAG);
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-			ret = select(s + 1, &rdfs, NULL, NULL, &tv);
-			if (ret < 0) {
-				perror("select");
-				exit(1);
-			}
+	tst_res(TPASS, "testcase %2d Sent patterns", testcase);
+
+	while (have_rx) {
+
+		have_rx = 0;
+		FD_ZERO(&rdfs);
+		FD_SET(s, &rdfs);
+		tv.tv_sec = 0;
+		tv.tv_usec = 50000;	/* 50ms timeout */
+
+		if (select(s + 1, &rdfs, NULL, NULL, &tv) < 0)
+			tst_brk(TBROK | TERRNO, "select");
 
-			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);
+		if (FD_ISSET(s, &rdfs)) {
+			have_rx = 1;
+			SAFE_READ(1, s, &frame, sizeof(struct can_frame));
+
+			if ((frame.can_id & CAN_SFF_MASK) != ID)
+				tst_res(TFAIL, "received wrong can_id!");
+
+			if (frame.data[0] != testcase)
+				tst_res(TFAIL, "received wrong testcase!");
+
+			/* 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) {
+				tst_res(TFAIL, "received rxbitval %d twice!",
+					rxbitval);
 			}
+			rxbits |= rxbitval;
+			rx++;
+
+			tst_res(TINFO, "testcase %2d rx : can_id = 0x%08X rx = "
+			       "%d rxbits = %d", 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 TPASS;
+	/* rx timed out -> check the received results */
+	if (rx_res[testcase] != rx) {
+		tst_brk(TBROK,
+			"wrong rx value in testcase %d : %d (expected "
+			"%d)", testcase, rx, rx_res[testcase]);
+	}
+	if (rxbits_res[testcase] != rxbits) {
+		tst_brk(TBROK,
+			"wrong rxbits value in testcase %d : %d "
+			"(expected %d)", testcase, rxbits,
+			rxbits_res[testcase]);
+	}
+	tst_res(TPASS, "testcase %2d ok", testcase);
 }
 
+static struct tst_test test = {
+	.tcnt = TC,
+	.options = (struct tst_option[]) {
+		{"D:", &can_dev_name, "-D <device>	CAN device name"},
+		{}
+	},
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = run,
+	.caps = (struct tst_cap []) {
+		TST_CAP(TST_CAP_REQ, CAP_NET_RAW),
+		TST_CAP(TST_CAP_DROP, CAP_SYS_ADMIN),
+		{}
+	},
+	.needs_drivers = (const char *const[]) {
+		"vcan",
+		"can-raw",
+		NULL
+	}
+};
+
 #else
 
-int main(void)
-{
-	printf("The linux/can.h was missing upon compilation.\n");
-	return TCONF;
-}
+TST_TEST_TCONF("The linux/can.h was missing upon compilation");
 
 #endif /* HAVE_LINUX_CAN_H */
-- 
2.29.2


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

* [LTP] [PATCH v2 3/6] can_filter: Convert to new library
@ 2021-01-19  9:31   ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp

Behavior is mostly the same, but on some errors we print fail and
continue instead of exiting immediately. It appears this would result
in more information being printed if there is a failure.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../network/can/filter-tests/can_filter.c     | 317 +++++++-----------
 1 file changed, 124 insertions(+), 193 deletions(-)

diff --git a/testcases/network/can/filter-tests/can_filter.c b/testcases/network/can/filter-tests/can_filter.c
index db017451a..d14e42fac 100644
--- a/testcases/network/can/filter-tests/can_filter.c
+++ b/testcases/network/can/filter-tests/can_filter.c
@@ -1,63 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * 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-users@lists.berlios.de>
- *
+ * Copyright (c) 2021 SUSE LLC
  */
 
-#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"
-#include "tst_res_flags.h"
+#include "tst_test.h"
 
 #ifdef HAVE_LINUX_CAN_H
 
-#include <linux/can.h>
-#include <linux/can/raw.h>
+#include "can_common.h"
 
 #define ID 0x123
 #define TC 18			/* # of testcases */
@@ -66,7 +18,9 @@ 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)
+static int s;
+
+static canid_t calc_id(int testcase)
 {
 	canid_t id = ID;
 
@@ -78,7 +32,7 @@ canid_t calc_id(int testcase)
 	return id;
 }
 
-canid_t calc_mask(int testcase)
+static canid_t calc_mask(int testcase)
 {
 	canid_t mask = CAN_SFF_MASK;
 
@@ -93,174 +47,151 @@ canid_t calc_mask(int testcase)
 	return mask;
 }
 
-int main(int argc, char **argv)
+static void setup(void)
 {
-	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;
+	int recv_own_msgs = 1;
 
-	/* check command line options */
-	if (argc != 2) {
-		fprintf(stderr, "Usage: %s <device>\n", argv[0]);
-		return TFAIL;
-	}
+	can_setup_vcan();
 
-	s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-	if (s < 0) {
-		perror("socket");
-		return TFAIL;
-	}
+	s = SAFE_SOCKET(PF_CAN, SOCK_RAW, CAN_RAW);
+
+	strcpy(ifr.ifr_name, can_dev_name);
+	SAFE_IOCTL(s, SIOCGIFINDEX, &ifr);
 
-	strcpy(ifr.ifr_name, argv[1]);
-	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-		perror("SIOCGIFINDEX");
-		return TFAIL;
-	}
 	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));
+	SAFE_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 TFAIL;
-	}
+	SAFE_BIND(s, (struct sockaddr *)&addr, sizeof(addr));
+}
 
-	printf("---\n");
+static void cleanup(void)
+{
+	if (s)
+		SAFE_CLOSE(s);
 
-	for (testcase = 0; testcase < TC; testcase++) {
+	can_cleanup_vcan();
+}
 
-		rfilter.can_id = calc_id(testcase);
-		rfilter.can_mask = calc_mask(testcase);
-		setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER,
-			   &rfilter, sizeof(rfilter));
+static void run(unsigned int n)
+{
+	fd_set rdfs;
+	struct timeval tv;
+	struct can_frame frame;
+	static struct can_filter rfilter;
+	int testcase = n;
+	int have_rx = 1;
+	int rx = 0;
+	int rxbits = 0, rxbitval;
 
-		printf("testcase %2d filters : can_id = 0x%08X can_mask = "
-		       "0x%08X\n", testcase, rfilter.can_id, rfilter.can_mask);
+	rfilter.can_id = calc_id(testcase);
+	rfilter.can_mask = calc_mask(testcase);
+	SAFE_SETSOCKOPT(s, SOL_CAN_RAW, CAN_RAW_FILTER,
+			&rfilter, sizeof(rfilter));
 
-		printf("testcase %2d sending patterns ... ", testcase);
+	tst_res(TINFO, "testcase %2d filters : can_id = 0x%08X can_mask = "
+	       "0x%08X", testcase, rfilter.can_id, rfilter.can_mask);
 
-		frame.can_dlc = 1;
-		frame.data[0] = testcase;
+	tst_res(TINFO, "testcase %2d sending patterns ... ", 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);
-		}
+	frame.can_dlc = 1;
+	frame.data[0] = testcase;
 
-		printf("ok\n");
+	frame.can_id = ID;
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-		have_rx = 1;
-		rx = 0;
-		rxbits = 0;
+	frame.can_id = (ID | CAN_RTR_FLAG);
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-		while (have_rx) {
+	frame.can_id = (ID | CAN_EFF_FLAG);
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-			have_rx = 0;
-			FD_ZERO(&rdfs);
-			FD_SET(s, &rdfs);
-			tv.tv_sec = 0;
-			tv.tv_usec = 50000;	/* 50ms timeout */
+	frame.can_id = (ID | CAN_EFF_FLAG | CAN_RTR_FLAG);
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
-			ret = select(s + 1, &rdfs, NULL, NULL, &tv);
-			if (ret < 0) {
-				perror("select");
-				exit(1);
-			}
+	tst_res(TPASS, "testcase %2d Sent patterns", testcase);
+
+	while (have_rx) {
+
+		have_rx = 0;
+		FD_ZERO(&rdfs);
+		FD_SET(s, &rdfs);
+		tv.tv_sec = 0;
+		tv.tv_usec = 50000;	/* 50ms timeout */
+
+		if (select(s + 1, &rdfs, NULL, NULL, &tv) < 0)
+			tst_brk(TBROK | TERRNO, "select");
 
-			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);
+		if (FD_ISSET(s, &rdfs)) {
+			have_rx = 1;
+			SAFE_READ(1, s, &frame, sizeof(struct can_frame));
+
+			if ((frame.can_id & CAN_SFF_MASK) != ID)
+				tst_res(TFAIL, "received wrong can_id!");
+
+			if (frame.data[0] != testcase)
+				tst_res(TFAIL, "received wrong testcase!");
+
+			/* 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) {
+				tst_res(TFAIL, "received rxbitval %d twice!",
+					rxbitval);
 			}
+			rxbits |= rxbitval;
+			rx++;
+
+			tst_res(TINFO, "testcase %2d rx : can_id = 0x%08X rx = "
+			       "%d rxbits = %d", 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 TPASS;
+	/* rx timed out -> check the received results */
+	if (rx_res[testcase] != rx) {
+		tst_brk(TBROK,
+			"wrong rx value in testcase %d : %d (expected "
+			"%d)", testcase, rx, rx_res[testcase]);
+	}
+	if (rxbits_res[testcase] != rxbits) {
+		tst_brk(TBROK,
+			"wrong rxbits value in testcase %d : %d "
+			"(expected %d)", testcase, rxbits,
+			rxbits_res[testcase]);
+	}
+	tst_res(TPASS, "testcase %2d ok", testcase);
 }
 
+static struct tst_test test = {
+	.tcnt = TC,
+	.options = (struct tst_option[]) {
+		{"D:", &can_dev_name, "-D <device>	CAN device name"},
+		{}
+	},
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = run,
+	.caps = (struct tst_cap []) {
+		TST_CAP(TST_CAP_REQ, CAP_NET_RAW),
+		TST_CAP(TST_CAP_DROP, CAP_SYS_ADMIN),
+		{}
+	},
+	.needs_drivers = (const char *const[]) {
+		"vcan",
+		"can-raw",
+		NULL
+	}
+};
+
 #else
 
-int main(void)
-{
-	printf("The linux/can.h was missing upon compilation.\n");
-	return TCONF;
-}
+TST_TEST_TCONF("The linux/can.h was missing upon compilation");
 
 #endif /* HAVE_LINUX_CAN_H */
-- 
2.29.2


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

* [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
  2021-01-19  9:31 ` [LTP] " Richard Palethorpe
@ 2021-01-19  9:31   ` Richard Palethorpe
  -1 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp; +Cc: linux-can, Oliver Hartkopp, Richard Palethorpe

Behavior is approximately the same except for the following:

* Test will continue after non-fatal errors.
* We now check the return value of `setsocketopt` and that I/O
  completed the specified number of bytes.
* The command line arg, device name, must be prepended with `-D`

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../can/filter-tests/can_rcv_own_msgs.c       | 273 ++++++------------
 1 file changed, 88 insertions(+), 185 deletions(-)

diff --git a/testcases/network/can/filter-tests/can_rcv_own_msgs.c b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
index 8ad51d298..3726dd6f7 100644
--- a/testcases/network/can/filter-tests/can_rcv_own_msgs.c
+++ b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
@@ -1,88 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * 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-users@lists.berlios.de>
- *
+ * Copyright (c) 2011 Volkswagen Group Electronic Research
+ * Copyright (c) 2021 SUSE LLC
  */
 
-#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"
-#include "tst_res_flags.h"
-#include "tst_minmax.h"
+#include "tst_test.h"
 
 #ifdef HAVE_LINUX_CAN_H
 
-#include <linux/can.h>
-#include <linux/can/raw.h>
+#include "can_common.h"
+#include "tst_minmax.h"
 
-struct rxs {
-	int s;
-	int t;
-};
+static int s, t;
 
-struct rxs test_sockets(int s, int t, canid_t can_id)
+void test_sockets(canid_t can_id, int expect_rxs, int expect_rxt)
 {
 	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;
+	int rxs = 0, rxt = 0;
 
 	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;
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
 	while (have_rx) {
 
@@ -93,164 +36,124 @@ struct rxs test_sockets(int s, int t, canid_t can_id)
 		tv.tv_usec = 50000;	/* 50ms timeout */
 		have_rx = 0;
 
-		ret = select(m, &rdfs, NULL, NULL, &tv);
-		if (ret < 0) {
-			perror("select");
-			exit(1);
-		}
+		if (select(m, &rdfs, NULL, NULL, &tv) < 0)
+			tst_brk(TBROK | TERRNO, "select");
 
 		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++;
+			SAFE_READ(1, s, &frame, sizeof(struct can_frame));
+
+			if (frame.can_id != can_id)
+				tst_res(TFAIL, "received wrong can_id!");
+
+			rxs++;
 		}
 
 		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++;
+			SAFE_READ(1, t, &frame, sizeof(struct can_frame));
+
+			if (frame.can_id != can_id)
+				tst_res(TFAIL, "received wrong can_id!");
+
+			rxt++;
 		}
 	}
 
 	/* timeout */
 
-	return rx;
+	tst_res(rxs == expect_rxs && rxt == expect_rxt ? TPASS : TFAIL,
+		"s received %d of %d, t received %d of %d",
+		rxs, expect_rxs, rxt, expect_rxt);
 }
 
-void setopts(int s, int loopback, int recv_own_msgs)
+static void setopts(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));
+	SAFE_SETSOCKOPT(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback,
+			sizeof(loopback));
+	SAFE_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);
+	tst_res(TINFO, "set loopback = %d, recv_own_msgs = %d",
+		loopback, recv_own_msgs);
 }
 
-int main(int argc, char **argv)
+static void setup(void)
 {
-	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 TFAIL;
-	}
+	can_setup_vcan();
 
-	s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-	if (s < 0) {
-		perror("socket");
-		return TFAIL;
-	}
-	t = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-	if (t < 0) {
-		perror("socket");
-		return TFAIL;
-	}
+	s = SAFE_SOCKET(PF_CAN, SOCK_RAW, CAN_RAW);
+	t = SAFE_SOCKET(PF_CAN, SOCK_RAW, CAN_RAW);
+
+	strcpy(ifr.ifr_name, can_dev_name);
+	SAFE_IOCTL(s, SIOCGIFINDEX, &ifr);
 
-	strcpy(ifr.ifr_name, argv[1]);
-	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-		perror("SIOCGIFINDEX");
-		return TFAIL;
-	}
 	addr.can_ifindex = ifr.ifr_ifindex;
 	addr.can_family = AF_CAN;
 
-	if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		perror("bind");
-		return TFAIL;
-	}
-	if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		perror("bind");
-		return TFAIL;
-	}
+	SAFE_BIND(s, (struct sockaddr *)&addr, sizeof(addr));
+	SAFE_BIND(t, (struct sockaddr *)&addr, sizeof(addr));
+}
 
-	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 TFAIL;
-	}
+static void cleanup(void)
+{
+	if (s)
+		SAFE_CLOSE(s);
+	if (t)
+		SAFE_CLOSE(t);
 
-	/* 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 TFAIL;
-	}
+	can_cleanup_vcan();
+}
 
-	/* 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 TFAIL;
-	}
+static void run(void)
+{
+	tst_res(TINFO, "Starting PF_CAN frame flow test.");
+	tst_res(TINFO, "checking socket default settings");
+	test_sockets(0x340, 0, 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 TFAIL;
-	}
+	setopts(0, 0);
+	test_sockets(0x341, 0, 0);
 
-	/* 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 TFAIL;
-	}
+	setopts(0, 1);
+	test_sockets(0x342, 0, 0);
 
-	printf("PF_CAN frame flow test was successful.\n");
+	setopts(1, 0);
+	test_sockets(0x343, 0, 1);
 
-	close(s);
-	close(t);
+	setopts(1, 1);
+	test_sockets(0x344, 1, 1);
 
-	return TPASS;
+	/* Return to defaults for when -i is used */
+	setopts(1, 0);
 }
 
+static struct tst_test test = {
+	.options = (struct tst_option[]) {
+		{"D:", &can_dev_name, "-D <device>	CAN device name"},
+		{}
+	},
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.caps = (struct tst_cap []) {
+		TST_CAP(TST_CAP_REQ, CAP_NET_RAW),
+		TST_CAP(TST_CAP_DROP, CAP_SYS_ADMIN),
+		{}
+	},
+	.needs_drivers = (const char *const[]) {
+		"vcan",
+		"can-raw",
+		NULL
+	}
+};
+
 #else
 
-int main(void)
-{
-	printf("The linux/can.h was missing upon compilation.\n");
-	return TCONF;
-}
+TST_TEST_TCONF("The linux/can.h was missing upon compilation");
 
 #endif /* HAVE_LINUX_CAN_H */
-- 
2.29.2


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

* [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
@ 2021-01-19  9:31   ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp

Behavior is approximately the same except for the following:

* Test will continue after non-fatal errors.
* We now check the return value of `setsocketopt` and that I/O
  completed the specified number of bytes.
* The command line arg, device name, must be prepended with `-D`

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../can/filter-tests/can_rcv_own_msgs.c       | 273 ++++++------------
 1 file changed, 88 insertions(+), 185 deletions(-)

diff --git a/testcases/network/can/filter-tests/can_rcv_own_msgs.c b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
index 8ad51d298..3726dd6f7 100644
--- a/testcases/network/can/filter-tests/can_rcv_own_msgs.c
+++ b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
@@ -1,88 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * 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-users@lists.berlios.de>
- *
+ * Copyright (c) 2011 Volkswagen Group Electronic Research
+ * Copyright (c) 2021 SUSE LLC
  */
 
-#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"
-#include "tst_res_flags.h"
-#include "tst_minmax.h"
+#include "tst_test.h"
 
 #ifdef HAVE_LINUX_CAN_H
 
-#include <linux/can.h>
-#include <linux/can/raw.h>
+#include "can_common.h"
+#include "tst_minmax.h"
 
-struct rxs {
-	int s;
-	int t;
-};
+static int s, t;
 
-struct rxs test_sockets(int s, int t, canid_t can_id)
+void test_sockets(canid_t can_id, int expect_rxs, int expect_rxt)
 {
 	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;
+	int rxs = 0, rxt = 0;
 
 	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;
+	SAFE_WRITE(1, s, &frame, sizeof(frame));
 
 	while (have_rx) {
 
@@ -93,164 +36,124 @@ struct rxs test_sockets(int s, int t, canid_t can_id)
 		tv.tv_usec = 50000;	/* 50ms timeout */
 		have_rx = 0;
 
-		ret = select(m, &rdfs, NULL, NULL, &tv);
-		if (ret < 0) {
-			perror("select");
-			exit(1);
-		}
+		if (select(m, &rdfs, NULL, NULL, &tv) < 0)
+			tst_brk(TBROK | TERRNO, "select");
 
 		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++;
+			SAFE_READ(1, s, &frame, sizeof(struct can_frame));
+
+			if (frame.can_id != can_id)
+				tst_res(TFAIL, "received wrong can_id!");
+
+			rxs++;
 		}
 
 		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++;
+			SAFE_READ(1, t, &frame, sizeof(struct can_frame));
+
+			if (frame.can_id != can_id)
+				tst_res(TFAIL, "received wrong can_id!");
+
+			rxt++;
 		}
 	}
 
 	/* timeout */
 
-	return rx;
+	tst_res(rxs == expect_rxs && rxt == expect_rxt ? TPASS : TFAIL,
+		"s received %d of %d, t received %d of %d",
+		rxs, expect_rxs, rxt, expect_rxt);
 }
 
-void setopts(int s, int loopback, int recv_own_msgs)
+static void setopts(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));
+	SAFE_SETSOCKOPT(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback,
+			sizeof(loopback));
+	SAFE_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);
+	tst_res(TINFO, "set loopback = %d, recv_own_msgs = %d",
+		loopback, recv_own_msgs);
 }
 
-int main(int argc, char **argv)
+static void setup(void)
 {
-	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 TFAIL;
-	}
+	can_setup_vcan();
 
-	s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-	if (s < 0) {
-		perror("socket");
-		return TFAIL;
-	}
-	t = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-	if (t < 0) {
-		perror("socket");
-		return TFAIL;
-	}
+	s = SAFE_SOCKET(PF_CAN, SOCK_RAW, CAN_RAW);
+	t = SAFE_SOCKET(PF_CAN, SOCK_RAW, CAN_RAW);
+
+	strcpy(ifr.ifr_name, can_dev_name);
+	SAFE_IOCTL(s, SIOCGIFINDEX, &ifr);
 
-	strcpy(ifr.ifr_name, argv[1]);
-	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-		perror("SIOCGIFINDEX");
-		return TFAIL;
-	}
 	addr.can_ifindex = ifr.ifr_ifindex;
 	addr.can_family = AF_CAN;
 
-	if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		perror("bind");
-		return TFAIL;
-	}
-	if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		perror("bind");
-		return TFAIL;
-	}
+	SAFE_BIND(s, (struct sockaddr *)&addr, sizeof(addr));
+	SAFE_BIND(t, (struct sockaddr *)&addr, sizeof(addr));
+}
 
-	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 TFAIL;
-	}
+static void cleanup(void)
+{
+	if (s)
+		SAFE_CLOSE(s);
+	if (t)
+		SAFE_CLOSE(t);
 
-	/* 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 TFAIL;
-	}
+	can_cleanup_vcan();
+}
 
-	/* 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 TFAIL;
-	}
+static void run(void)
+{
+	tst_res(TINFO, "Starting PF_CAN frame flow test.");
+	tst_res(TINFO, "checking socket default settings");
+	test_sockets(0x340, 0, 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 TFAIL;
-	}
+	setopts(0, 0);
+	test_sockets(0x341, 0, 0);
 
-	/* 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 TFAIL;
-	}
+	setopts(0, 1);
+	test_sockets(0x342, 0, 0);
 
-	printf("PF_CAN frame flow test was successful.\n");
+	setopts(1, 0);
+	test_sockets(0x343, 0, 1);
 
-	close(s);
-	close(t);
+	setopts(1, 1);
+	test_sockets(0x344, 1, 1);
 
-	return TPASS;
+	/* Return to defaults for when -i is used */
+	setopts(1, 0);
 }
 
+static struct tst_test test = {
+	.options = (struct tst_option[]) {
+		{"D:", &can_dev_name, "-D <device>	CAN device name"},
+		{}
+	},
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.caps = (struct tst_cap []) {
+		TST_CAP(TST_CAP_REQ, CAP_NET_RAW),
+		TST_CAP(TST_CAP_DROP, CAP_SYS_ADMIN),
+		{}
+	},
+	.needs_drivers = (const char *const[]) {
+		"vcan",
+		"can-raw",
+		NULL
+	}
+};
+
 #else
 
-int main(void)
-{
-	printf("The linux/can.h was missing upon compilation.\n");
-	return TCONF;
-}
+TST_TEST_TCONF("The linux/can.h was missing upon compilation");
 
 #endif /* HAVE_LINUX_CAN_H */
-- 
2.29.2


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

* [PATCH v2 5/6] can: Remove obsolete test wrapper script
  2021-01-19  9:31 ` [LTP] " Richard Palethorpe
@ 2021-01-19  9:31   ` Richard Palethorpe
  -1 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp; +Cc: linux-can, Oliver Hartkopp, Richard Palethorpe

Functionality moved into can_common.h and the test executables.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 testcases/network/can/Makefile                |   2 -
 .../can/filter-tests/00_Descriptions.txt      |   1 +
 testcases/network/can/filter-tests/INSTALL    |   3 +-
 testcases/network/can/filter-tests/Makefile   |   2 -
 .../network/can/filter-tests/can_run_tests.sh | 106 ------------------
 5 files changed, 3 insertions(+), 111 deletions(-)
 delete mode 100755 testcases/network/can/filter-tests/can_run_tests.sh

diff --git a/testcases/network/can/Makefile b/testcases/network/can/Makefile
index 31744534a..a69f6be87 100644
--- a/testcases/network/can/Makefile
+++ b/testcases/network/can/Makefile
@@ -22,6 +22,4 @@ top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= *.sh
-
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/can/filter-tests/00_Descriptions.txt b/testcases/network/can/filter-tests/00_Descriptions.txt
index 89610982c..55d213456 100644
--- a/testcases/network/can/filter-tests/00_Descriptions.txt
+++ b/testcases/network/can/filter-tests/00_Descriptions.txt
@@ -5,5 +5,6 @@ information on the CAN network protocol family PF_CAN is contained in
 <Kernel/Documentation/networking/can.txt>.
 
 For any issue(s) with CAN tests please write to:
+<ltp@lists.linux.it>
 <socketcan-users@lists.berlios.de>,
 Oliver Hartkopp <oliver.hartkopp@volkswagen.de>,
diff --git a/testcases/network/can/filter-tests/INSTALL b/testcases/network/can/filter-tests/INSTALL
index e549aed0f..7d62d65fe 100644
--- a/testcases/network/can/filter-tests/INSTALL
+++ b/testcases/network/can/filter-tests/INSTALL
@@ -12,7 +12,8 @@ enable CAN protocol, please see ltp/README file.
 $ make
 
 2) To Run the tests from this directory, do:
-$ ./run_ltp-can_tests.sh
+$ ./can_filter
+$ ./can_rcv_own_msgs
 
 3) To let LTP run the tests from $LTPROOT, execute:
 $ ./runltp -f can
diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
index 6a9474164..29aaa3240 100644
--- a/testcases/network/can/filter-tests/Makefile
+++ b/testcases/network/can/filter-tests/Makefile
@@ -23,6 +23,4 @@ include $(top_srcdir)/include/mk/testcases.mk
 
 CPPFLAGS		+= -DETH_P_CAN=0x000C -DPF_CAN=29 -DAF_CAN=PF_CAN
 
-INSTALL_TARGETS		:= *.sh
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/can/filter-tests/can_run_tests.sh b/testcases/network/can/filter-tests/can_run_tests.sh
deleted file mode 100755
index 762d90eca..000000000
--- a/testcases/network/can/filter-tests/can_run_tests.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/sh
-################################################################################
-## Copyright (c) Oliver Hartkopp <oliver.hartkopp@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=$?
-case "$ret" in
-0)	tst_resm TPASS "Test $1 PASS";;
-1)	tst_resm TFAIL "Test $1 FAIL";;
-32)	tst_resm TCONF "$1 is not appropriate for configuration flag";;
-*)	tst_resm TBROK "Invalid resm type $ret";;
-esac
-
-tst_exit
-- 
2.29.2


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

* [LTP] [PATCH v2 5/6] can: Remove obsolete test wrapper script
@ 2021-01-19  9:31   ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp

Functionality moved into can_common.h and the test executables.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 testcases/network/can/Makefile                |   2 -
 .../can/filter-tests/00_Descriptions.txt      |   1 +
 testcases/network/can/filter-tests/INSTALL    |   3 +-
 testcases/network/can/filter-tests/Makefile   |   2 -
 .../network/can/filter-tests/can_run_tests.sh | 106 ------------------
 5 files changed, 3 insertions(+), 111 deletions(-)
 delete mode 100755 testcases/network/can/filter-tests/can_run_tests.sh

diff --git a/testcases/network/can/Makefile b/testcases/network/can/Makefile
index 31744534a..a69f6be87 100644
--- a/testcases/network/can/Makefile
+++ b/testcases/network/can/Makefile
@@ -22,6 +22,4 @@ top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= *.sh
-
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/can/filter-tests/00_Descriptions.txt b/testcases/network/can/filter-tests/00_Descriptions.txt
index 89610982c..55d213456 100644
--- a/testcases/network/can/filter-tests/00_Descriptions.txt
+++ b/testcases/network/can/filter-tests/00_Descriptions.txt
@@ -5,5 +5,6 @@ information on the CAN network protocol family PF_CAN is contained in
 <Kernel/Documentation/networking/can.txt>.
 
 For any issue(s) with CAN tests please write to:
+<ltp@lists.linux.it>
 <socketcan-users@lists.berlios.de>,
 Oliver Hartkopp <oliver.hartkopp@volkswagen.de>,
diff --git a/testcases/network/can/filter-tests/INSTALL b/testcases/network/can/filter-tests/INSTALL
index e549aed0f..7d62d65fe 100644
--- a/testcases/network/can/filter-tests/INSTALL
+++ b/testcases/network/can/filter-tests/INSTALL
@@ -12,7 +12,8 @@ enable CAN protocol, please see ltp/README file.
 $ make
 
 2) To Run the tests from this directory, do:
-$ ./run_ltp-can_tests.sh
+$ ./can_filter
+$ ./can_rcv_own_msgs
 
 3) To let LTP run the tests from $LTPROOT, execute:
 $ ./runltp -f can
diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
index 6a9474164..29aaa3240 100644
--- a/testcases/network/can/filter-tests/Makefile
+++ b/testcases/network/can/filter-tests/Makefile
@@ -23,6 +23,4 @@ include $(top_srcdir)/include/mk/testcases.mk
 
 CPPFLAGS		+= -DETH_P_CAN=0x000C -DPF_CAN=29 -DAF_CAN=PF_CAN
 
-INSTALL_TARGETS		:= *.sh
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/can/filter-tests/can_run_tests.sh b/testcases/network/can/filter-tests/can_run_tests.sh
deleted file mode 100755
index 762d90eca..000000000
--- a/testcases/network/can/filter-tests/can_run_tests.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/sh
-################################################################################
-## Copyright (c) Oliver Hartkopp <oliver.hartkopp@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=$?
-case "$ret" in
-0)	tst_resm TPASS "Test $1 PASS";;
-1)	tst_resm TFAIL "Test $1 FAIL";;
-32)	tst_resm TCONF "$1 is not appropriate for configuration flag";;
-*)	tst_resm TBROK "Invalid resm type $ret";;
-esac
-
-tst_exit
-- 
2.29.2


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

* [PATCH v2 6/6] can: Update contact details
  2021-01-19  9:31 ` [LTP] " Richard Palethorpe
@ 2021-01-19  9:31   ` Richard Palethorpe
  -1 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp; +Cc: linux-can, Oliver Hartkopp, Richard Palethorpe

socketcan-users appears to be no more.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 testcases/network/can/filter-tests/00_Descriptions.txt | 5 +++--
 testcases/network/can/filter-tests/Makefile            | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/testcases/network/can/filter-tests/00_Descriptions.txt b/testcases/network/can/filter-tests/00_Descriptions.txt
index 55d213456..9623d29a0 100644
--- a/testcases/network/can/filter-tests/00_Descriptions.txt
+++ b/testcases/network/can/filter-tests/00_Descriptions.txt
@@ -6,5 +6,6 @@ information on the CAN network protocol family PF_CAN is contained in
 
 For any issue(s) with CAN tests please write to:
 <ltp@lists.linux.it>
-<socketcan-users@lists.berlios.de>,
-Oliver Hartkopp <oliver.hartkopp@volkswagen.de>,
+Oliver Hartkopp <socketcan@hartkopp.net>
+Linux-CAN ML <linux-can@vger.kernel.org>
+
diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
index 29aaa3240..bd57c7fff 100644
--- a/testcases/network/can/filter-tests/Makefile
+++ b/testcases/network/can/filter-tests/Makefile
@@ -14,8 +14,6 @@
 #    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>
 
 top_srcdir		?= ../../../..
 
-- 
2.29.2


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

* [LTP] [PATCH v2 6/6] can: Update contact details
@ 2021-01-19  9:31   ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19  9:31 UTC (permalink / raw)
  To: ltp

socketcan-users appears to be no more.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 testcases/network/can/filter-tests/00_Descriptions.txt | 5 +++--
 testcases/network/can/filter-tests/Makefile            | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/testcases/network/can/filter-tests/00_Descriptions.txt b/testcases/network/can/filter-tests/00_Descriptions.txt
index 55d213456..9623d29a0 100644
--- a/testcases/network/can/filter-tests/00_Descriptions.txt
+++ b/testcases/network/can/filter-tests/00_Descriptions.txt
@@ -6,5 +6,6 @@ information on the CAN network protocol family PF_CAN is contained in
 
 For any issue(s) with CAN tests please write to:
 <ltp@lists.linux.it>
-<socketcan-users@lists.berlios.de>,
-Oliver Hartkopp <oliver.hartkopp@volkswagen.de>,
+Oliver Hartkopp <socketcan@hartkopp.net>
+Linux-CAN ML <linux-can@vger.kernel.org>
+
diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
index 29aaa3240..bd57c7fff 100644
--- a/testcases/network/can/filter-tests/Makefile
+++ b/testcases/network/can/filter-tests/Makefile
@@ -14,8 +14,6 @@
 #    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>
 
 top_srcdir		?= ../../../..
 
-- 
2.29.2


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

* Re: [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
  2021-01-19  9:31   ` [LTP] " Richard Palethorpe
@ 2021-01-19 14:53     ` Marc Kleine-Budde
  -1 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2021-01-19 14:53 UTC (permalink / raw)
  To: Richard Palethorpe, ltp; +Cc: linux-can, Oliver Hartkopp


[-- Attachment #1.1: Type: text/plain, Size: 2518 bytes --]

On 1/19/21 10:31 AM, Richard Palethorpe wrote:
> Behavior is approximately the same except for the following:
> 
> * Test will continue after non-fatal errors.
> * We now check the return value of `setsocketopt` and that I/O
>   completed the specified number of bytes.
> * The command line arg, device name, must be prepended with `-D`
> 
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> ---
>  .../can/filter-tests/can_rcv_own_msgs.c       | 273 ++++++------------
>  1 file changed, 88 insertions(+), 185 deletions(-)
> 
> diff --git a/testcases/network/can/filter-tests/can_rcv_own_msgs.c b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
> index 8ad51d298..3726dd6f7 100644
> --- a/testcases/network/can/filter-tests/can_rcv_own_msgs.c
> +++ b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
> @@ -1,88 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
                               ^^^^^^^^^^^^^^^^
>  /*
> - * 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.

IANAL, I think you're missing this license. Is looks like some sort of BSD to me.

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

It doesn't say "or later".

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
@ 2021-01-19 14:53     ` Marc Kleine-Budde
  0 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2021-01-19 14:53 UTC (permalink / raw)
  To: ltp

On 1/19/21 10:31 AM, Richard Palethorpe wrote:
> Behavior is approximately the same except for the following:
> 
> * Test will continue after non-fatal errors.
> * We now check the return value of `setsocketopt` and that I/O
>   completed the specified number of bytes.
> * The command line arg, device name, must be prepended with `-D`
> 
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> ---
>  .../can/filter-tests/can_rcv_own_msgs.c       | 273 ++++++------------
>  1 file changed, 88 insertions(+), 185 deletions(-)
> 
> diff --git a/testcases/network/can/filter-tests/can_rcv_own_msgs.c b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
> index 8ad51d298..3726dd6f7 100644
> --- a/testcases/network/can/filter-tests/can_rcv_own_msgs.c
> +++ b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
> @@ -1,88 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
                               ^^^^^^^^^^^^^^^^
>  /*
> - * 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.

IANAL, I think you're missing this license. Is looks like some sort of BSD to me.

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

It doesn't say "or later".

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210119/7ae824d6/attachment.sig>

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

* Re: [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
  2021-01-19 14:53     ` [LTP] " Marc Kleine-Budde
@ 2021-01-19 15:06       ` Cyril Hrubis
  -1 siblings, 0 replies; 28+ messages in thread
From: Cyril Hrubis @ 2021-01-19 15:06 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Richard Palethorpe, ltp, Oliver Hartkopp, linux-can

Hi!
> >  /*
> > - * 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.
> 
> IANAL, I think you're missing this license. Is looks like some sort of BSD to me.
> 
> > - *
> > - * 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.
> 
> It doesn't say "or later".

Looks like we cannot just remove this license. So what about moving this
text into a separate COPYING file and changing the SPDX to GPL-v2.0?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
@ 2021-01-19 15:06       ` Cyril Hrubis
  0 siblings, 0 replies; 28+ messages in thread
From: Cyril Hrubis @ 2021-01-19 15:06 UTC (permalink / raw)
  To: ltp

Hi!
> >  /*
> > - * 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.
> 
> IANAL, I think you're missing this license. Is looks like some sort of BSD to me.
> 
> > - *
> > - * 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.
> 
> It doesn't say "or later".

Looks like we cannot just remove this license. So what about moving this
text into a separate COPYING file and changing the SPDX to GPL-v2.0?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* Re: [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
  2021-01-19 15:06       ` Cyril Hrubis
@ 2021-01-19 15:09         ` Marc Kleine-Budde
  -1 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2021-01-19 15:09 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp, Oliver Hartkopp, linux-can


[-- Attachment #1.1: Type: text/plain, Size: 1888 bytes --]

On 1/19/21 4:06 PM, Cyril Hrubis wrote:
> Hi!
>>>  /*
>>> - * 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.
>>
>> IANAL, I think you're missing this license. Is looks like some sort of BSD to me.
>>
>>> - *
>>> - * 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.
>>
>> It doesn't say "or later".
> 
> Looks like we cannot just remove this license. So what about moving this
> text into a separate COPYING file and changing the SPDX to GPL-v2.0?

This file is dual licensed, better keep it dual licensed.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
@ 2021-01-19 15:09         ` Marc Kleine-Budde
  0 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2021-01-19 15:09 UTC (permalink / raw)
  To: ltp

On 1/19/21 4:06 PM, Cyril Hrubis wrote:
> Hi!
>>>  /*
>>> - * 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.
>>
>> IANAL, I think you're missing this license. Is looks like some sort of BSD to me.
>>
>>> - *
>>> - * 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.
>>
>> It doesn't say "or later".
> 
> Looks like we cannot just remove this license. So what about moving this
> text into a separate COPYING file and changing the SPDX to GPL-v2.0?

This file is dual licensed, better keep it dual licensed.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210119/0c0de741/attachment.sig>

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

* Re: [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
  2021-01-19 15:09         ` Marc Kleine-Budde
@ 2021-01-19 16:34           ` Richard Palethorpe
  -1 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19 16:34 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Cyril Hrubis, ltp, Oliver Hartkopp, linux-can

Hello All,

Marc Kleine-Budde <mkl@pengutronix.de> writes:

> On 1/19/21 4:06 PM, Cyril Hrubis wrote:
>> Hi!
>>>>  /*
>>>> - * 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.
>>>
>>> IANAL, I think you're missing this license. Is looks like some sort
>>> of BSD to me.

Ufff, thanks, I should pay more attention when it is a test imported
from elsewhere.

>>>
>>>> - *
>>>> - * 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.
>>>
>>> It doesn't say "or later".
>> 
>> Looks like we cannot just remove this license. So what about moving this
>> text into a separate COPYING file and changing the SPDX to GPL-v2.0?
>
> This file is dual licensed, better keep it dual licensed.
>
> regards,
> Marc

HHmm, this appears to be the BSD-3-Clause license with the following
text inserted in the middle:

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

I don't see any corresponding SPDX identifier or exception for this. It
is probably easiest and safest just to keep it as-is.

-- 
Thank you,
Richard.

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

* [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
@ 2021-01-19 16:34           ` Richard Palethorpe
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Palethorpe @ 2021-01-19 16:34 UTC (permalink / raw)
  To: ltp

Hello All,

Marc Kleine-Budde <mkl@pengutronix.de> writes:

> On 1/19/21 4:06 PM, Cyril Hrubis wrote:
>> Hi!
>>>>  /*
>>>> - * 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.
>>>
>>> IANAL, I think you're missing this license. Is looks like some sort
>>> of BSD to me.

Ufff, thanks, I should pay more attention when it is a test imported
from elsewhere.

>>>
>>>> - *
>>>> - * 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.
>>>
>>> It doesn't say "or later".
>> 
>> Looks like we cannot just remove this license. So what about moving this
>> text into a separate COPYING file and changing the SPDX to GPL-v2.0?
>
> This file is dual licensed, better keep it dual licensed.
>
> regards,
> Marc

HHmm, this appears to be the BSD-3-Clause license with the following
text inserted in the middle:

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

I don't see any corresponding SPDX identifier or exception for this. It
is probably easiest and safest just to keep it as-is.

-- 
Thank you,
Richard.

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

* Re: [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
  2021-01-19 16:34           ` Richard Palethorpe
@ 2021-01-19 16:39             ` Marc Kleine-Budde
  -1 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2021-01-19 16:39 UTC (permalink / raw)
  To: rpalethorpe; +Cc: Cyril Hrubis, ltp, Oliver Hartkopp, linux-can


[-- Attachment #1.1: Type: text/plain, Size: 3079 bytes --]

On 1/19/21 5:34 PM, Richard Palethorpe wrote:
> Hello All,
> 
> Marc Kleine-Budde <mkl@pengutronix.de> writes:
> 
>> On 1/19/21 4:06 PM, Cyril Hrubis wrote:
>>> Hi!
>>>>>  /*
>>>>> - * 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.
>>>>
>>>> IANAL, I think you're missing this license. Is looks like some sort
>>>> of BSD to me.
> 
> Ufff, thanks, I should pay more attention when it is a test imported
> from elsewhere.
> 
>>>>
>>>>> - *
>>>>> - * 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.
>>>>
>>>> It doesn't say "or later".
>>>
>>> Looks like we cannot just remove this license. So what about moving this
>>> text into a separate COPYING file and changing the SPDX to GPL-v2.0?
>>
>> This file is dual licensed, better keep it dual licensed.
>>
>> regards,
>> Marc
> 
> HHmm, this appears to be the BSD-3-Clause license with the following
> text inserted in the middle:
> 
>  * 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.
> 
> I don't see any corresponding SPDX identifier or exception for this. It
> is probably easiest and safest just to keep it as-is.

I think the Linux kernel uses:

/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR
BSD-3-Clause) */

e.g.:

https://elixir.bootlin.com/linux/v5.10/source/include/uapi/linux/can/gw.h

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
@ 2021-01-19 16:39             ` Marc Kleine-Budde
  0 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2021-01-19 16:39 UTC (permalink / raw)
  To: ltp

On 1/19/21 5:34 PM, Richard Palethorpe wrote:
> Hello All,
> 
> Marc Kleine-Budde <mkl@pengutronix.de> writes:
> 
>> On 1/19/21 4:06 PM, Cyril Hrubis wrote:
>>> Hi!
>>>>>  /*
>>>>> - * 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.
>>>>
>>>> IANAL, I think you're missing this license. Is looks like some sort
>>>> of BSD to me.
> 
> Ufff, thanks, I should pay more attention when it is a test imported
> from elsewhere.
> 
>>>>
>>>>> - *
>>>>> - * 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.
>>>>
>>>> It doesn't say "or later".
>>>
>>> Looks like we cannot just remove this license. So what about moving this
>>> text into a separate COPYING file and changing the SPDX to GPL-v2.0?
>>
>> This file is dual licensed, better keep it dual licensed.
>>
>> regards,
>> Marc
> 
> HHmm, this appears to be the BSD-3-Clause license with the following
> text inserted in the middle:
> 
>  * 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.
> 
> I don't see any corresponding SPDX identifier or exception for this. It
> is probably easiest and safest just to keep it as-is.

I think the Linux kernel uses:

/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR
BSD-3-Clause) */

e.g.:

https://elixir.bootlin.com/linux/v5.10/source/include/uapi/linux/can/gw.h

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210119/f1239299/attachment.sig>

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

* Re: [LTP] [PATCH v2 2/6] can: Add can_common.h for vcan device setup
  2021-01-19  9:31   ` [LTP] " Richard Palethorpe
@ 2021-01-19 18:05     ` Petr Vorel
  -1 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2021-01-19 18:05 UTC (permalink / raw)
  To: Richard Palethorpe; +Cc: ltp, Oliver Hartkopp, linux-can

Hi Richie,

...
> +#include <linux/if.h>
...
> +static void can_setup_vcan(void)
> +{
...
> +check_echo:
> +	/* Precondition for the frame flow test? */
> +	SAFE_ASPRINTF(&path, "/sys/class/net/%s/flags", can_dev_name);
> +	if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
FYI IFF_ECHO is not defined on some older toolchains (aarch64).
It'd be good to add lapi/if.h, where it'd be defined.
But it can be added later.

In file included from can_common.h:21,
                 from can_filter.c:12:
can_common.h: In function ‘can_setup_vcan’:
can_common.h:58:50: error: ‘IFF_ECHO’ undeclared (first use in this function); did you mean ‘IFF_DEBUG’?
  if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
                                                  ^~~~~~~~
can_common.h:58:50: note: each undeclared identifier is reported only once for each function it appears in
In file included from can_common.h:21,
                 from can_rcv_own_msgs.c:12:
can_common.h: In function ‘can_setup_vcan’:
can_common.h:58:50: error: ‘IFF_ECHO’ undeclared (first use in this function); did you mean ‘IFF_DEBUG’?
  if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
                                                  ^~~~~~~~

Also there are other problems on toolchains with older linux headers
- bug in using <net/if.h> with <linux/if.h>. Can't we just use <linux/if.h>?
https://travis-ci.org/github/pevik/ltp/jobs/755163076

In file included from /usr/src/ltp/testcases/network/can/filter-tests/can_common.h:15:0,
                 from /usr/src/ltp/testcases/network/can/filter-tests/can_filter.c:12:
/usr/include/linux/if.h:71:2: error: redeclaration of enumerator 'IFF_UP'
  IFF_UP    = 1<<0,  /* sysfs */
  ^
/usr/include/net/if.h:44:5: note: previous definition of 'IFF_UP' was here
     IFF_UP = 0x1,  /* Interface is up.  */
     ^
/usr/include/linux/if.h:72:2: error: redeclaration of enumerator 'IFF_BROADCAST'
  IFF_BROADCAST   = 1<<1,  /* __volatile__ */
  ^
/usr/include/net/if.h:46:5: note: previous definition of 'IFF_BROADCAST' was here
     IFF_BROADCAST = 0x2, /* Broadcast address valid.  */
     ^
/usr/include/linux/if.h:73:2: error: redeclaration of enumerator 'IFF_DEBUG'
  IFF_DEBUG   = 1<<2,  /* sysfs */
  ^
/usr/include/net/if.h:48:5: note: previous definition of 'IFF_DEBUG' was here
     IFF_DEBUG = 0x4,  /* Turn on debugging.  */
     ^
/usr/include/linux/if.h:74:2: error: redeclaration of enumerator 'IFF_LOOPBACK'
  IFF_LOOPBACK   = 1<<3,  /* __volatile__ */
  ^
/usr/include/net/if.h:50:5: note: previous definition of 'IFF_LOOPBACK' was here
     IFF_LOOPBACK = 0x8,  /* Is a loopback net.  */
     ^
/usr/include/linux/if.h:75:2: error: redeclaration of enumerator 'IFF_POINTOPOINT'
  IFF_POINTOPOINT   = 1<<4,  /* __volatile__ */
  ^
/usr/include/net/if.h:52:5: note: previous definition of 'IFF_POINTOPOINT' was here
     IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link.  */
     ^
/usr/include/linux/if.h:76:2: error: redeclaration of enumerator 'IFF_NOTRAILERS'
  IFF_NOTRAILERS   = 1<<5,  /* sysfs */
  ^
/usr/include/net/if.h:54:5: note: previous definition of 'IFF_NOTRAILERS' was here
     IFF_NOTRAILERS = 0x20, /* Avoid use of trailers.  */
     ^
/usr/include/linux/if.h:77:2: error: redeclaration of enumerator 'IFF_RUNNING'
  IFF_RUNNING   = 1<<6,  /* __volatile__ */

Also it fails to run docparse:
invalid character encountered while parsing JSON string, at character offset 133249 (before "\tCAN device name"\n...") at /usr/src/ltp/docparse/testinfo.pl line 398.
make[1]: *** [/usr/src/ltp/docparse/Makefile:60: txt] Error 255
I'll have look into this one.

Kind regards,
Petr

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

* [LTP] [PATCH v2 2/6] can: Add can_common.h for vcan device setup
@ 2021-01-19 18:05     ` Petr Vorel
  0 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2021-01-19 18:05 UTC (permalink / raw)
  To: ltp

Hi Richie,

...
> +#include <linux/if.h>
...
> +static void can_setup_vcan(void)
> +{
...
> +check_echo:
> +	/* Precondition for the frame flow test? */
> +	SAFE_ASPRINTF(&path, "/sys/class/net/%s/flags", can_dev_name);
> +	if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
FYI IFF_ECHO is not defined on some older toolchains (aarch64).
It'd be good to add lapi/if.h, where it'd be defined.
But it can be added later.

In file included from can_common.h:21,
                 from can_filter.c:12:
can_common.h: In function ?can_setup_vcan?:
can_common.h:58:50: error: ?IFF_ECHO? undeclared (first use in this function); did you mean ?IFF_DEBUG??
  if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
                                                  ^~~~~~~~
can_common.h:58:50: note: each undeclared identifier is reported only once for each function it appears in
In file included from can_common.h:21,
                 from can_rcv_own_msgs.c:12:
can_common.h: In function ?can_setup_vcan?:
can_common.h:58:50: error: ?IFF_ECHO? undeclared (first use in this function); did you mean ?IFF_DEBUG??
  if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO))
                                                  ^~~~~~~~

Also there are other problems on toolchains with older linux headers
- bug in using <net/if.h> with <linux/if.h>. Can't we just use <linux/if.h>?
https://travis-ci.org/github/pevik/ltp/jobs/755163076

In file included from /usr/src/ltp/testcases/network/can/filter-tests/can_common.h:15:0,
                 from /usr/src/ltp/testcases/network/can/filter-tests/can_filter.c:12:
/usr/include/linux/if.h:71:2: error: redeclaration of enumerator 'IFF_UP'
  IFF_UP    = 1<<0,  /* sysfs */
  ^
/usr/include/net/if.h:44:5: note: previous definition of 'IFF_UP' was here
     IFF_UP = 0x1,  /* Interface is up.  */
     ^
/usr/include/linux/if.h:72:2: error: redeclaration of enumerator 'IFF_BROADCAST'
  IFF_BROADCAST   = 1<<1,  /* __volatile__ */
  ^
/usr/include/net/if.h:46:5: note: previous definition of 'IFF_BROADCAST' was here
     IFF_BROADCAST = 0x2, /* Broadcast address valid.  */
     ^
/usr/include/linux/if.h:73:2: error: redeclaration of enumerator 'IFF_DEBUG'
  IFF_DEBUG   = 1<<2,  /* sysfs */
  ^
/usr/include/net/if.h:48:5: note: previous definition of 'IFF_DEBUG' was here
     IFF_DEBUG = 0x4,  /* Turn on debugging.  */
     ^
/usr/include/linux/if.h:74:2: error: redeclaration of enumerator 'IFF_LOOPBACK'
  IFF_LOOPBACK   = 1<<3,  /* __volatile__ */
  ^
/usr/include/net/if.h:50:5: note: previous definition of 'IFF_LOOPBACK' was here
     IFF_LOOPBACK = 0x8,  /* Is a loopback net.  */
     ^
/usr/include/linux/if.h:75:2: error: redeclaration of enumerator 'IFF_POINTOPOINT'
  IFF_POINTOPOINT   = 1<<4,  /* __volatile__ */
  ^
/usr/include/net/if.h:52:5: note: previous definition of 'IFF_POINTOPOINT' was here
     IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link.  */
     ^
/usr/include/linux/if.h:76:2: error: redeclaration of enumerator 'IFF_NOTRAILERS'
  IFF_NOTRAILERS   = 1<<5,  /* sysfs */
  ^
/usr/include/net/if.h:54:5: note: previous definition of 'IFF_NOTRAILERS' was here
     IFF_NOTRAILERS = 0x20, /* Avoid use of trailers.  */
     ^
/usr/include/linux/if.h:77:2: error: redeclaration of enumerator 'IFF_RUNNING'
  IFF_RUNNING   = 1<<6,  /* __volatile__ */

Also it fails to run docparse:
invalid character encountered while parsing JSON string, at character offset 133249 (before "\tCAN device name"\n...")@/usr/src/ltp/docparse/testinfo.pl line 398.
make[1]: *** [/usr/src/ltp/docparse/Makefile:60: txt] Error 255
I'll have look into this one.

Kind regards,
Petr

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

* Re: [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
  2021-01-19 16:39             ` Marc Kleine-Budde
@ 2021-01-19 21:34               ` Oliver Hartkopp
  -1 siblings, 0 replies; 28+ messages in thread
From: Oliver Hartkopp @ 2021-01-19 21:34 UTC (permalink / raw)
  To: Marc Kleine-Budde, rpalethorpe; +Cc: Cyril Hrubis, ltp, linux-can



On 19.01.21 17:39, Marc Kleine-Budde wrote:
> On 1/19/21 5:34 PM, Richard Palethorpe wrote:
>> Hello All,
>>
>> Marc Kleine-Budde <mkl@pengutronix.de> writes:
>>
>>> On 1/19/21 4:06 PM, Cyril Hrubis wrote:
>>>> Hi!
>>>>>>   /*
>>>>>> - * 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.
>>>>>
>>>>> IANAL, I think you're missing this license. Is looks like some sort
>>>>> of BSD to me.
>>
>> Ufff, thanks, I should pay more attention when it is a test imported
>> from elsewhere.
>>
>>>>>
>>>>>> - *
>>>>>> - * 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.
>>>>>
>>>>> It doesn't say "or later".
>>>>
>>>> Looks like we cannot just remove this license. So what about moving this
>>>> text into a separate COPYING file and changing the SPDX to GPL-v2.0?
>>>
>>> This file is dual licensed, better keep it dual licensed.
>>>
>>> regards,
>>> Marc
>>
>> HHmm, this appears to be the BSD-3-Clause license with the following
>> text inserted in the middle:
>>
>>   * 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.
>>
>> I don't see any corresponding SPDX identifier or exception for this. It
>> is probably easiest and safest just to keep it as-is.
> 
> I think the Linux kernel uses:
> 
> /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR
> BSD-3-Clause) */
> 
> e.g.:
> 
> https://elixir.bootlin.com/linux/v5.10/source/include/uapi/linux/can/gw.h
> 

Thanks Marc!

Yes, indeed it is a GPLv2 / BSD3 dual license to use it in both 
environments.

Regards,
Oliver

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

* [LTP] [PATCH v2 4/6] can_recv_own_msgs: Convert to new library
@ 2021-01-19 21:34               ` Oliver Hartkopp
  0 siblings, 0 replies; 28+ messages in thread
From: Oliver Hartkopp @ 2021-01-19 21:34 UTC (permalink / raw)
  To: ltp



On 19.01.21 17:39, Marc Kleine-Budde wrote:
> On 1/19/21 5:34 PM, Richard Palethorpe wrote:
>> Hello All,
>>
>> Marc Kleine-Budde <mkl@pengutronix.de> writes:
>>
>>> On 1/19/21 4:06 PM, Cyril Hrubis wrote:
>>>> Hi!
>>>>>>   /*
>>>>>> - * 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.
>>>>>
>>>>> IANAL, I think you're missing this license. Is looks like some sort
>>>>> of BSD to me.
>>
>> Ufff, thanks, I should pay more attention when it is a test imported
>> from elsewhere.
>>
>>>>>
>>>>>> - *
>>>>>> - * 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.
>>>>>
>>>>> It doesn't say "or later".
>>>>
>>>> Looks like we cannot just remove this license. So what about moving this
>>>> text into a separate COPYING file and changing the SPDX to GPL-v2.0?
>>>
>>> This file is dual licensed, better keep it dual licensed.
>>>
>>> regards,
>>> Marc
>>
>> HHmm, this appears to be the BSD-3-Clause license with the following
>> text inserted in the middle:
>>
>>   * 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.
>>
>> I don't see any corresponding SPDX identifier or exception for this. It
>> is probably easiest and safest just to keep it as-is.
> 
> I think the Linux kernel uses:
> 
> /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR
> BSD-3-Clause) */
> 
> e.g.:
> 
> https://elixir.bootlin.com/linux/v5.10/source/include/uapi/linux/can/gw.h
> 

Thanks Marc!

Yes, indeed it is a GPLv2 / BSD3 dual license to use it in both 
environments.

Regards,
Oliver

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

end of thread, other threads:[~2021-01-19 21:51 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19  9:31 [PATCH v2 0/6] Convert CAN tests to new LTP API Richard Palethorpe
2021-01-19  9:31 ` [LTP] " Richard Palethorpe
2021-01-19  9:31 ` [PATCH v2 1/6] API: Add FILE_SCANF to new lib Richard Palethorpe
2021-01-19  9:31   ` [LTP] " Richard Palethorpe
2021-01-19  9:31 ` [PATCH v2 2/6] can: Add can_common.h for vcan device setup Richard Palethorpe
2021-01-19  9:31   ` [LTP] " Richard Palethorpe
2021-01-19 18:05   ` Petr Vorel
2021-01-19 18:05     ` Petr Vorel
2021-01-19  9:31 ` [PATCH v2 3/6] can_filter: Convert to new library Richard Palethorpe
2021-01-19  9:31   ` [LTP] " Richard Palethorpe
2021-01-19  9:31 ` [PATCH v2 4/6] can_recv_own_msgs: " Richard Palethorpe
2021-01-19  9:31   ` [LTP] " Richard Palethorpe
2021-01-19 14:53   ` Marc Kleine-Budde
2021-01-19 14:53     ` [LTP] " Marc Kleine-Budde
2021-01-19 15:06     ` Cyril Hrubis
2021-01-19 15:06       ` Cyril Hrubis
2021-01-19 15:09       ` Marc Kleine-Budde
2021-01-19 15:09         ` Marc Kleine-Budde
2021-01-19 16:34         ` Richard Palethorpe
2021-01-19 16:34           ` Richard Palethorpe
2021-01-19 16:39           ` Marc Kleine-Budde
2021-01-19 16:39             ` Marc Kleine-Budde
2021-01-19 21:34             ` Oliver Hartkopp
2021-01-19 21:34               ` Oliver Hartkopp
2021-01-19  9:31 ` [PATCH v2 5/6] can: Remove obsolete test wrapper script Richard Palethorpe
2021-01-19  9:31   ` [LTP] " Richard Palethorpe
2021-01-19  9:31 ` [PATCH v2 6/6] can: Update contact details Richard Palethorpe
2021-01-19  9:31   ` [LTP] " Richard Palethorpe

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.