BuildCommDCB bug fix and conformance test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is the completed conformance test for the BuildCommDCB functions.
Relative to what I posted to the wine-devel list before this covers many
more cases and also tests the wide character versions of the functions.
I also added a \n to the end of all the ok() messages.

I have confirmed that this test runs correctly under Windows 95 and Windows 2000 as well as wine.

For the wide character tests I simply used the same test cases and call
MultiByteToWideChar first.  I am sure someone will let me know if this
is not a good way to do it.

While working on this test I discovered a couple more differences
between Win 9x and NT.  I also found one small bug in my previous patch
to the BuildCommDCB functions.  The attached patch also includes a fix
for this bug and some additional comments regarding the Win 9x/NT
differences.


Changelog: Kevin Groeneveld <kgroeneveld@mcmaster.ca> - Fix small bug with parsing of numbers in BuildCommDCB functions. - Add conformance test for BuildCommDCB functions.

diff -urN --exclude-from=ignore wine-20030911/dlls/kernel/comm.c wine-20030911.patched/dlls/kernel/comm.c
--- wine-20030911/dlls/kernel/comm.c	2003-09-11 20:26:15.000000000 -0400
+++ wine-20030911.patched/dlls/kernel/comm.c	2003-09-13 22:00:45.000000000 -0400
@@ -199,7 +199,7 @@
 static LPCSTR COMM_ParseNumber(LPCSTR ptr, LPDWORD lpnumber)
 {
 	if(*ptr < '0' || *ptr > '9') return NULL;
-	if(!sscanf(ptr, "%ld", lpnumber)) return NULL;
+	if(!sscanf(ptr, "%lu", lpnumber)) return NULL;
 	while(*ptr >= '0' && *ptr <= '9') ptr++;
 	return ptr;
 }
@@ -353,7 +353,9 @@
 		if(*device) last = toupper(*device++);
 		while(*device == ' ') device++;
 	}
-		
+
+	/* Win NT sets the flow control members based on (or lack of) the last
+	   parameter.  Win 9x does not set these members. */
 	switch(last)
 	{
 	case 0:
@@ -481,6 +483,8 @@
 			if(!(device = COMM_ParseOnOff(device + 5, &temp)))
 				return FALSE;
 
+			/* Win NT sets the fDsrSensitivity member based on the
+			   idsr parameter.  Win 9x sets fOutxDsrFlow instead. */
 			lpdcb->fDsrSensitivity = temp;
 		}
 		else
diff -urN --exclude-from=ignore wine-20030911/dlls/kernel/tests/Makefile.in wine-20030911.patched/dlls/kernel/tests/Makefile.in
--- wine-20030911/dlls/kernel/tests/Makefile.in	2003-05-13 00:46:54.000000000 -0400
+++ wine-20030911.patched/dlls/kernel/tests/Makefile.in	2003-09-12 23:27:59.000000000 -0400
@@ -9,6 +9,7 @@
 	alloc.c \
 	atom.c \
 	codepage.c \
+	comm.c \
 	console.c \
 	directory.c \
 	drive.c \
diff -urN --exclude-from=ignore wine-20030911/dlls/kernel/tests/comm.c wine-20030911.patched/dlls/kernel/tests/comm.c
--- wine-20030911/dlls/kernel/tests/comm.c	1969-12-31 19:00:00.000000000 -0500
+++ wine-20030911.patched/dlls/kernel/tests/comm.c	2003-09-13 23:03:43.000000000 -0400
@@ -0,0 +1,640 @@
+/* Unit test suite for comm functions
+ *
+ * Copyright 2003 Kevin Groeneveld
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdio.h>
+
+#include "wine/test.h"
+#include "winbase.h"
+#include "winnls.h"
+
+typedef struct
+{
+	char string[100];
+	BOOL result;
+	BOOL old_style;
+	DCB dcb1, dcb2;
+	COMMTIMEOUTS timeouts1, timeouts2;
+} TEST;
+
+static TEST test[] =
+{
+	{
+		"baud=9600 parity=e data=5 stop=1 xon=on odsr=off octs=off dtr=on rts=on idsr=on",
+		TRUE, FALSE,
+		{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x02, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x02, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"baud=0 parity=M data=6 stop=1.5 xon=off odsr=on octs=ON dtr=off rts=off idsr=OFF",
+		TRUE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x03, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00000000, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x03, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"BAUD=4000000000 parity=n data=7 stop=2 to=off",
+		TRUE, FALSE,
+		{ 0x00000000, 0xee6b2800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x00, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xee6b2800, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x00, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
+	},
+	{
+		"Baud=115200 Parity=O Data=8 To=On",
+		TRUE, FALSE,
+		{ 0x00000000, 0x0001c200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x01, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x0001c200, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x01, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
+	},
+	{
+		"PaRiTy=s           Data=7          DTR=on",
+		TRUE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x04, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x04, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"data=4",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"data=9",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"parity=no",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"stop=0",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"stop=1.501",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"stop=3",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"to=foobar",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		" baud=9600",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"baud= 9600",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"baud=9600,data=8",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"11,n,8,1",
+		TRUE, TRUE,
+		{ 0x00000000, 0x0000006e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x0000006e, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"30 ,E, 5,1.5",
+		TRUE, TRUE,
+		{ 0x00000000, 0x0000012c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x02, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x0000012c, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x02, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"60, m, 6, 2 ",
+		TRUE, TRUE,
+		{ 0x00000000, 0x00000258, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x03, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00000258, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x03, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"12 , o , 7 , 1",
+		TRUE, TRUE,
+		{ 0x00000000, 0x000004b0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x01, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x000004b0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x01, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"24,s,8,1.5",
+		TRUE, TRUE,
+		{ 0x00000000, 0x00000960, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x04, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00000960, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x04, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"48,n,8,1,p",
+		TRUE, TRUE,
+		{ 0x00000000, 0x000012c0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x000012c0, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,N,8,1 , x ",
+		TRUE, TRUE,
+		{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"19, e, 7, 1, x",
+		TRUE, TRUE,
+		{ 0x00000000, 0x00004b00, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x02, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00004b00, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x02, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"0,M,7,1,P",
+		TRUE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x03, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00000000, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x03, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"4000000000,O,7,1.5,X",
+		TRUE, TRUE,
+		{ 0x00000000, 0xee6b2800, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x01, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xee6b2800, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x01, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,N,8,1 to=on",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,NO,8,1",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,N,4,1",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,N,9,1",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,N,8,0",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,N,8,3",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"96,N,8,1,K",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COM0:baud=115200",
+		FALSE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COMx:baud=38400 data=8",
+		TRUE, FALSE,
+		{ 0x00000000, 0x00009600, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00009600, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COMx  :to=on stop=1.5",
+		TRUE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0x01, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
+	},
+	{
+		"COMx:               baud=12345     data=7",
+		TRUE, FALSE,
+		{ 0x00000000, 0x00003039, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00003039, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COMx : xon=on odsr=off",
+		TRUE, FALSE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COM0:9600,N,8,1",
+		FALSE, TRUE,
+		{ 0x00000000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0xffffffff, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COMx:9600,N,8,1",
+		TRUE, TRUE,
+		{ 0x00000000, 0x00002580, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x08, 0x00, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00002580, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x08, 0x00, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COMx:  11,E,7,2",
+		TRUE, TRUE,
+		{ 0x00000000, 0x0000006e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x07, 0x02, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x0000006e, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x07, 0x02, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COMx  :19,M,5,1",
+		TRUE, TRUE,
+		{ 0x00000000, 0x00004b00, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x05, 0x03, 0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x00004b00, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x05, 0x03, 0x00, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+	{
+		"COMx  :    57600,S,6,2,x",
+		TRUE, TRUE,
+		{ 0x00000000, 0x0000e100, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0x00000, 0x0000, 0x0000, 0x0000, 0x06, 0x04, 0x02, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 0x0000 },
+		{ 0xffffffff, 0x0000e100, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x1ffff, 0xffff, 0xffff, 0xffff, 0x06, 0x04, 0x02, (char)0xff, (char)0xff, (char)0xff, (char)0xff, (char)0xff, 0xffff },
+		{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+		{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+	},
+};
+
+#define TEST_COUNT (sizeof(test) / sizeof(TEST))
+
+/* This function can be useful if you are modifiying the test cases and want to
+   output the contents of a DCB structure. */
+/*static print_dcb(DCB *pdcb)
+{
+	printf("0x%08x, 0x%08x, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, 0x%05x, 0x%04x, 0x%04x, 0x%04x, 0x%02x, 0x%02x, 0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, (char)0x%02x, 0x%04x\n",
+		pdcb->DCBlength,
+		pdcb->BaudRate,
+		pdcb->fBinary,
+		pdcb->fParity,
+		pdcb->fOutxCtsFlow,
+		pdcb->fOutxDsrFlow,
+		pdcb->fDtrControl,
+		pdcb->fDsrSensitivity,
+		pdcb->fTXContinueOnXoff,
+		pdcb->fOutX,
+		pdcb->fInX,
+		pdcb->fErrorChar,
+		pdcb->fNull,
+		pdcb->fRtsControl,
+		pdcb->fAbortOnError,
+		pdcb->fDummy2,
+		pdcb->wReserved,
+		pdcb->XonLim,
+		pdcb->XoffLim,
+		pdcb->ByteSize,
+		pdcb->Parity,
+		pdcb->StopBits,
+		pdcb->XonChar & 0xff,
+		pdcb->XoffChar & 0xff,
+		pdcb->ErrorChar & 0xff,
+		pdcb->EofChar & 0xff,
+		pdcb->EvtChar & 0xff,
+		pdcb->wReserved1 & 0xffff );
+} */
+
+static void check_result(char *function, TEST *ptest, int initial_value, BOOL result)
+{
+	DWORD LastError = GetLastError();
+	DWORD CorrectError = (ptest->result ? 0xdeadbeef : ERROR_INVALID_PARAMETER);
+
+	ok(LastError == CorrectError, "%s(\"%s\"), 0x%02x: GetLastError() returned 0x%08lx, should be 0x%08lx\n", function, ptest->string, initial_value, LastError, CorrectError);
+	ok(result == ptest->result, "%s(\"%s\"), 0x%02x: return value should be %s\n", function, ptest->string, initial_value, ptest->result ? "TRUE" : "FALSE");
+}
+
+#define check_dcb_member(a,b) ok(pdcb1->a == pdcb2->a, "%s(\"%s\"), 0x%02x: "#a" is "b", should be "b"\n", function, ptest->string, initial_value, pdcb1->a, pdcb2->a)
+#define check_dcb_member2(a,c,b) if(pdcb2->a == c) { check_dcb_member(a,b); } else { ok(pdcb1->a == pdcb2->a || pdcb1->a == c, "%s(\"%s\"), 0x%02x: "#a" is "b", should be "b" or "b"\n", function, ptest->string, initial_value, pdcb1->a, pdcb2->a, c); }
+
+static void check_dcb(char *function, TEST *ptest, int initial_value, DCB *pdcb1, DCB *pdcb2)
+{
+	/* DCBlength is a special case since Win 9x sets it but NT does not.
+	   We will accept either as correct. */
+	check_dcb_member2(DCBlength, (DWORD)sizeof(DCB), "%lu");
+
+	/* For old style control strings Win 9x does not set the next five members, NT does. */
+	if(ptest->old_style && ptest->result)
+	{
+		check_dcb_member2(fOutxCtsFlow, ((unsigned int)initial_value & 1), "%u");
+		check_dcb_member2(fDtrControl, ((unsigned int)initial_value & 3), "%u");
+		check_dcb_member2(fOutX, ((unsigned int)initial_value & 1), "%u");
+		check_dcb_member2(fInX, ((unsigned)initial_value & 1), "%u");
+		check_dcb_member2(fRtsControl, ((unsigned)initial_value & 3), "%u");
+	}
+	else
+	{
+		check_dcb_member(fOutxCtsFlow, "%u");
+		check_dcb_member(fDtrControl, "%u");
+		check_dcb_member(fOutX, "%u");
+		check_dcb_member(fInX, "%u");
+		check_dcb_member(fRtsControl, "%u");
+	}
+
+	if(ptest->result)
+	{
+		/* For the idsr=xxx paramater, NT sets fDsrSensitivity, 9x sets
+		   fOutxDsrFlow. */
+		if(!ptest->old_style)
+		{
+			check_dcb_member2(fOutxDsrFlow, pdcb2->fDsrSensitivity, "%u");
+			check_dcb_member2(fDsrSensitivity, pdcb2->fOutxDsrFlow, "%u");
+		}
+		else
+		{
+			/* For old style control strings Win 9x does not set the
+			   fOutxDsrFlow member, NT does. */
+			check_dcb_member2(fOutxDsrFlow, ((unsigned int)initial_value & 1), "%u");
+			check_dcb_member(fDsrSensitivity, "%u");
+		}
+	}
+	else
+	{
+		check_dcb_member(fOutxDsrFlow, "%u");
+		check_dcb_member(fDsrSensitivity, "%u");
+	}
+
+	/* Check the result of the DCB members. */
+	check_dcb_member(BaudRate, "%lu");
+	check_dcb_member(fBinary, "%u");
+	check_dcb_member(fParity, "%u");
+	check_dcb_member(fTXContinueOnXoff, "%u");
+	check_dcb_member(fErrorChar, "%u");
+	check_dcb_member(fNull, "%u");
+	check_dcb_member(fAbortOnError, "%u");
+	check_dcb_member(fDummy2, "%u");
+	check_dcb_member(wReserved, "%u");
+	check_dcb_member(XonLim, "%u");
+	check_dcb_member(XoffLim, "%u");
+	check_dcb_member(ByteSize, "%u");
+	check_dcb_member(Parity, "%u");
+	check_dcb_member(StopBits, "%u");
+	check_dcb_member(XonChar, "%d");
+	check_dcb_member(XoffChar, "%d");
+	check_dcb_member(ErrorChar, "%d");
+	check_dcb_member(EofChar, "%d");
+	check_dcb_member(EvtChar, "%d");
+	check_dcb_member(wReserved1, "%u");
+}
+
+#define check_timeouts_member(a) ok(ptimeouts1->a == ptimeouts2->a, "%s(\"%s\"), 0x%02x: "#a" is %lu, should be %lu\n", function, ptest->string, initial_value, ptimeouts1->a, ptimeouts2->a);
+
+static void check_timeouts(char *function, TEST *ptest, int initial_value, COMMTIMEOUTS *ptimeouts1, COMMTIMEOUTS *ptimeouts2)
+{
+	check_timeouts_member(ReadIntervalTimeout);
+	check_timeouts_member(ReadTotalTimeoutMultiplier);
+	check_timeouts_member(ReadTotalTimeoutConstant);
+	check_timeouts_member(WriteTotalTimeoutMultiplier);
+	check_timeouts_member(WriteTotalTimeoutConstant);
+}
+
+static void test_BuildCommDCBA(TEST *ptest, int initial_value, DCB *pexpected_dcb)
+{
+	BOOL result;
+	DCB dcb;
+
+	/* set initial conditions */
+	memset(&dcb, initial_value, sizeof(DCB));
+	SetLastError(0xdeadbeef);
+
+	result = BuildCommDCBA(ptest->string, &dcb);
+
+	/* check results */
+	check_result("BuildCommDCBA", ptest, initial_value, result);
+	check_dcb("BuildCommDCBA", ptest, initial_value, &dcb, pexpected_dcb);
+}
+
+static void test_BuildCommDCBAndTimeoutsA(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
+{
+	BOOL result;
+	DCB dcb;
+	COMMTIMEOUTS timeouts;
+
+	/* set initial conditions */
+	memset(&dcb, initial_value, sizeof(DCB));
+	memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
+	SetLastError(0xdeadbeef);
+
+	result = BuildCommDCBAndTimeoutsA(ptest->string, &dcb, &timeouts);
+
+	/* check results */
+	check_result("BuildCommDCBAndTimeoutsA", ptest, initial_value, result);
+	check_dcb("BuildCommDCBAndTimeoutsA", ptest, initial_value, &dcb, pexpected_dcb);
+	check_timeouts("BuildCommDCBAndTimeoutsA", ptest, initial_value, &timeouts, pexpected_timeouts);
+}
+
+static void test_BuildCommDCBW(TEST *ptest, int initial_value, DCB *pexpected_dcb)
+{
+	BOOL result;
+	DCB dcb;
+	WCHAR wide_string[sizeof(ptest->string)];
+
+	MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
+
+	/* set initial conditions */
+	memset(&dcb, initial_value, sizeof(DCB));
+	SetLastError(0xdeadbeef);
+
+	result = BuildCommDCBW(wide_string, &dcb);
+
+	if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+		return;
+
+	/* check results */
+	check_result("BuildCommDCBW", ptest, initial_value, result);
+	check_dcb("BuildCommDCBW", ptest, initial_value, &dcb, pexpected_dcb);
+}
+
+static void test_BuildCommDCBAndTimeoutsW(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
+{
+	BOOL result;
+	DCB dcb;
+	COMMTIMEOUTS timeouts;
+	WCHAR wide_string[sizeof(ptest->string)];
+
+	MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
+
+	/* set initial conditions */
+	memset(&dcb, initial_value, sizeof(DCB));
+	memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
+	SetLastError(0xdeadbeef);
+
+	result = BuildCommDCBAndTimeoutsW(wide_string, &dcb, &timeouts);
+
+	if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+		return;
+
+	/* check results */
+	check_result("BuildCommDCBAndTimeoutsA", ptest, initial_value, result);
+	check_dcb("BuildCommDCBAndTimeoutsA", ptest, initial_value, &dcb, pexpected_dcb);
+	check_timeouts("BuildCommDCBAndTimeoutsA", ptest, initial_value, &timeouts, pexpected_timeouts);
+}
+
+static void test_BuildCommDCB(void)
+{
+	char port_name[] = "COMx";
+	char port = 0;
+	int i;
+	char *ptr;
+
+	/* Some of these tests require a valid COM port.  This loop will try to find
+	   a valid port. */
+	for(port_name[3] = '1'; port_name[3] <= '9'; port_name[3]++)
+	{
+		COMMCONFIG commconfig;
+		DWORD size = sizeof(COMMCONFIG);
+		
+		if(GetDefaultCommConfig(port_name, &commconfig, &size))
+		{
+			port = port_name[3];
+			break;
+		}
+	}
+
+	if(!port)
+		trace("Could not find a valid COM port.  Some tests will be skipped.\n");
+
+	for(i = 0; i < TEST_COUNT; i++)
+	{
+		/* Check if this test case needs a valid COM port. */
+		ptr = strstr(test[i].string, "COMx");
+		
+		/* If required, substitute valid port number into device control string. */
+		if(ptr)
+		{
+			if(port)
+				ptr[3] = port;
+			else
+				continue;
+		}
+
+		test_BuildCommDCBA(&test[i], 0x00, &test[i].dcb1);
+		test_BuildCommDCBA(&test[i], 0xff, &test[i].dcb2);
+		test_BuildCommDCBAndTimeoutsA(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
+		test_BuildCommDCBAndTimeoutsA(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
+
+		test_BuildCommDCBW(&test[i], 0x00, &test[i].dcb1);
+		test_BuildCommDCBW(&test[i], 0xff, &test[i].dcb2);
+		test_BuildCommDCBAndTimeoutsW(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
+		test_BuildCommDCBAndTimeoutsW(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
+	}
+}
+
+START_TEST(comm)
+{
+	test_BuildCommDCB();
+}


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux