linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth : Added more testing options to l2test
@ 2011-07-19 13:09 chen.ganir
  2011-07-19 14:34 ` Gustavo Padovan
  0 siblings, 1 reply; 3+ messages in thread
From: chen.ganir @ 2011-07-19 13:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Chen Ganir

From: Chen Ganir <chen.ganir@ti.com>

Added more options to allow passing ERTM L2CAP PTS tests. The 
options allow to delay between a connection is made and the 
first sent frame,a delay between the last sent frame and 
disocnnection,and the ability to run as "one-shot" instead of
listening for more connections.

Signed-off-by: Chen Ganir <chen.ganir@ti.com>
---
 test/l2test.c |   44 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index 3ac332f..965e3ce 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -98,6 +98,11 @@ static int count = 1;
 
 /* Default delay after sending count number of frames */
 static unsigned long delay = 0;
+static unsigned long delay_before_first_frame = 0;
+static unsigned long delay_after_last_frame = 0;
+
+/* Default operation mode */
+static int one_time = 0;
 
 static char *filename = NULL;
 
@@ -462,13 +467,19 @@ static void do_listen(void (*handler)(int sk))
 							strerror(errno), errno);
 			goto error;
 		}
-		if (fork()) {
-			/* Parent */
-			close(nsk);
-			continue;
+
+		if (one_time == 0) {
+			if (fork()) {
+				/* Parent */
+				close(nsk);
+				continue;
+			}
+			/* Child */
+			close(sk);
+		}
+		else {
+			close(sk);
 		}
-		/* Child */
-		close(sk);
 
 		/* Get current options */
 		memset(&opts, 0, sizeof(opts));
@@ -754,6 +765,7 @@ static void do_send(int sk)
 	}
 
 	seq = 0;
+	sleep(delay_before_first_frame);
 	while ((num_frames == -1) || (num_frames-- > 0)) {
 		*(uint32_t *) buf = htobl(seq);
 		*(uint16_t *) (buf + 4) = htobs(data_size);
@@ -778,6 +790,7 @@ static void do_send(int sk)
 		if (num_frames && delay && count && !(seq % count))
 			usleep(delay);
 	}
+	sleep(delay_after_last_frame);
 }
 
 static void send_mode(int sk)
@@ -1094,7 +1107,10 @@ static void usage(void)
 		"\t[-E] request encryption\n"
 		"\t[-S] secure connection\n"
 		"\t[-M] become master\n"
-		"\t[-T] enable timestamps\n");
+		"\t[-T] enable timestamps\n"
+		"\t[-H seconds] Delay before first sent frame (default = 0)\n"
+		"\t[-K seconds] Delay after last sent frame, before disconnection (default = 0)\n"
+		"\t[-Y] One time only (do not listen for more incoming connections)");
 }
 
 int main(int argc, char *argv[])
@@ -1104,7 +1120,7 @@ int main(int argc, char *argv[])
 
 	bacpy(&bdaddr, BDADDR_ANY);
 
-	while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:RUGAESMT")) != EOF) {
+	while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:H:K:RUGAESMTY")) != EOF) {
 		switch(opt) {
 		case 'r':
 			mode = RECV;
@@ -1174,6 +1190,14 @@ int main(int argc, char *argv[])
 			data_size = atoi(optarg);
 			break;
 
+		case 'H':
+			delay_before_first_frame = atoi(optarg);
+			break;
+
+		case 'K':
+			delay_after_last_frame = atoi(optarg);
+			break;
+
 		case 'i':
 			if (!strncasecmp(optarg, "hci", 3))
 				hci_devba(atoi(optarg + 3), &bdaddr);
@@ -1272,6 +1296,10 @@ int main(int argc, char *argv[])
 			cid = atoi(optarg);
 			break;
 
+		case 'Y':
+			one_time = 1;
+			break;
+
 		default:
 			usage();
 			exit(1);
-- 
1.7.4.1


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

* Re: [PATCH] Bluetooth : Added more testing options to l2test
  2011-07-19 13:09 [PATCH] Bluetooth : Added more testing options to l2test chen.ganir
@ 2011-07-19 14:34 ` Gustavo Padovan
  2011-07-20  5:03   ` Ganir, Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo Padovan @ 2011-07-19 14:34 UTC (permalink / raw)
  To: chen.ganir; +Cc: linux-bluetooth, Chen Ganir

Hi Chen,

* chen.ganir@gmail.com <chen.ganir@gmail.com> [2011-07-19 16:09:11 +0300]:

> From: Chen Ganir <chen.ganir@ti.com>
> 
> Added more options to allow passing ERTM L2CAP PTS tests. The 
> options allow to delay between a connection is made and the 
> first sent frame,a delay between the last sent frame and 
> disocnnection,and the ability to run as "one-shot" instead of
> listening for more connections.

I never needed such change to pass all ERTM PTS tests. Check if the -D and -C
options can help you.

	Gustavo

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

* RE: [PATCH] Bluetooth : Added more testing options to l2test
  2011-07-19 14:34 ` Gustavo Padovan
@ 2011-07-20  5:03   ` Ganir, Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Ganir, Chen @ 2011-07-20  5:03 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth@vger.kernel.org

Gustavo,


> -----Original Message-----
> From: Gustavo F. Padovan [mailto:pao@profusion.mobi] On Behalf Of
> Gustavo Padovan
> Sent: Tuesday, July 19, 2011 5:34 PM
> To: chen.ganir@gmail.com
> Cc: linux-bluetooth@vger.kernel.org; Ganir, Chen
> Subject: Re: [PATCH] Bluetooth : Added more testing options to l2test
> 
> Hi Chen,
> 
> * chen.ganir@gmail.com <chen.ganir@gmail.com> [2011-07-19 16:09:11
> +0300]:
> 
> > From: Chen Ganir <chen.ganir@ti.com>
> >
> > Added more options to allow passing ERTM L2CAP PTS tests. The
> > options allow to delay between a connection is made and the
> > first sent frame,a delay between the last sent frame and
> > disocnnection,and the ability to run as "one-shot" instead of
> > listening for more connections.
> 
> I never needed such change to pass all ERTM PTS tests. Check if the -D
> and -C
> options can help you.
> 
> 	Gustavo

The PTS expects the IUT to behave exactly as required by the test scenario.
This means that if doing something out of the ordinary, it will fail the test.

For example, if after the connection we start sending messages directly, it
will fail, because the script is not yet ready for incoming packets. If we 
disconnect the link too early, the test will also fail. If we keep listening
for more incoming connections, we will not close the channel correctly, and
the test will also fail.
To be more specific - for example, the following tests required the delay :
TC_ERM_BV_01_C
TC_ERM_BV_08_C
TC_ERM_BV_18_C
TC_ERM_BV_19_C
TC_ERM_BV_20_C
TC_ERM_BV_21_C
These tests required the IUT to start sending data after the connection was
established. Starting to send too early caused the tests to fail.

The one shot option was required to allow the IUT to disconnect the ACL at the 
end of the test (as required by the PTS tests TC_ERM_BV_11_C and TC_ERM_BV_12_C).
For this, I needed the l2test to exit upon completion, so I can disconnect the 
link using the hcitool (in a simple shell script).

If you have any other ideas or recommendation on how to pass these tests, I 
would be happy to hear.
 

Thanks,
Chen Ganir


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

end of thread, other threads:[~2011-07-20  5:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-19 13:09 [PATCH] Bluetooth : Added more testing options to l2test chen.ganir
2011-07-19 14:34 ` Gustavo Padovan
2011-07-20  5:03   ` Ganir, Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).