1 /* Unit test suite for comm functions
3 * Copyright 2003 Kevin Groeneveld
4 * Copyright 2005 Uwe Bonnes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
27 #define TIMEOUT 1000 /* one second for Timeouts*/
29 #define FASTBAUD 115200
30 #define TIMEDELTA 150 /* 150 ms uncertainty allowed */
32 /* Define the appropriate LOOPBACK(s) TRUE if you have a Loopback cable with
33 * the mentioned shorts connected to your Serial port
35 #define LOOPBACK_TXD_RXD FALSE /* Sub-D 9: Short 2-3 */
36 #define LOOPBACK_CTS_RTS FALSE /* Sub-D 9: Short 7-8 */
37 #define LOOPBACK_DTR_DSR FALSE /* Sub-D 9: Short 4-6 */
38 #define LOOPBACK_DTR_RING FALSE /* Sub-D 9: Short 4-9 */
39 #define LOOPBACK_DTR_DCD FALSE /* Sub-D 9: Short 4-1 */
40 /* Many Linux serial drivers have the TIOCM_LOOP flag in the TIOCM_SET ioctl
41 * available. For the 8250 this is equivalent to TXD->RXD, OUT2->DCD,
42 * OUT1->RI, RTS->CTS and DTR->DSR
51 COMMTIMEOUTS timeouts1, timeouts2;
57 "baud=9600 parity=e data=5 stop=1 xon=on odsr=off octs=off dtr=on rts=on idsr=on",
59 { 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 },
60 { 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 },
61 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
62 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
65 "baud=0 parity=M data=6 stop=1.5 xon=off odsr=on octs=ON dtr=off rts=off idsr=OFF",
67 { 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 },
68 { 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 },
69 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
70 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
73 "BAUD=4000000000 parity=n data=7 stop=2 to=off",
75 { 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 },
76 { 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 },
77 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
78 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
81 "Baud=115200 Parity=O Data=8 To=On",
83 { 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 },
84 { 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 },
85 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
86 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
89 "PaRiTy=s Data=7 DTR=on",
91 { 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 },
92 { 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 },
93 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
94 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
99 { 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 },
100 { 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 },
101 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
102 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
107 { 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 },
108 { 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 },
109 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
110 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
115 { 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 },
116 { 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 },
117 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
118 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
123 { 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 },
124 { 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 },
125 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
126 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
131 { 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 },
132 { 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 },
133 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
134 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
139 { 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 },
140 { 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 },
141 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
142 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
147 { 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 },
148 { 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 },
149 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
150 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
155 { 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 },
156 { 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 },
157 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
158 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
163 { 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 },
164 { 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 },
165 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
166 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
171 { 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 },
172 { 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 },
173 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
174 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
179 { 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 },
180 { 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 },
181 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
182 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
187 { 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 },
188 { 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 },
189 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
190 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
195 { 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 },
196 { 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 },
197 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
198 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
203 { 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 },
204 { 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 },
205 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
206 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
211 { 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 },
212 { 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 },
213 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
214 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
219 { 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 },
220 { 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 },
221 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
222 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
227 { 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 },
228 { 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 },
229 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
230 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
235 { 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 },
236 { 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 },
237 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
238 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
243 { 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 },
244 { 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 },
245 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
246 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
249 "4000000000,O,7,1.5,X",
251 { 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 },
252 { 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 },
253 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
254 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
259 { 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 },
260 { 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 },
261 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
262 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
267 { 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 },
268 { 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 },
269 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
270 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
275 { 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 },
276 { 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 },
277 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
278 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
283 { 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 },
284 { 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 },
285 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
286 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
291 { 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 },
292 { 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 },
293 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
294 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
299 { 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 },
300 { 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 },
301 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
302 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
307 { 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 },
308 { 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 },
309 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
310 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
315 { 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 },
316 { 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 },
317 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
318 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
321 "COMx:baud=38400 data=8",
323 { 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 },
324 { 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 },
325 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
326 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
329 "COMx :to=on stop=1.5",
331 { 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 },
332 { 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 },
333 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 },
334 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000EA60 }
337 "COMx: baud=12345 data=7",
339 { 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 },
340 { 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 },
341 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
342 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
345 "COMx : xon=on odsr=off",
347 { 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 },
348 { 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 },
349 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
350 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
355 { 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 },
356 { 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 },
357 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
358 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
363 { 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 },
364 { 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 },
365 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
366 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
371 { 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 },
372 { 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 },
373 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
374 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
379 { 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 },
380 { 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 },
381 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
382 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
385 "COMx : 57600,S,6,2,x",
387 { 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 },
388 { 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 },
389 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
390 { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
394 #define TEST_COUNT (sizeof(test) / sizeof(TEST))
396 /* This function can be useful if you are modifying the test cases and want to
397 output the contents of a DCB structure. */
398 /*static print_dcb(DCB *pdcb)
400 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",
408 pdcb->fDsrSensitivity,
409 pdcb->fTXContinueOnXoff,
423 pdcb->XonChar & 0xff,
424 pdcb->XoffChar & 0xff,
425 pdcb->ErrorChar & 0xff,
426 pdcb->EofChar & 0xff,
427 pdcb->EvtChar & 0xff,
428 pdcb->wReserved1 & 0xffff );
431 static void check_result(const char *function, TEST *ptest, int initial_value, BOOL result)
433 DWORD LastError = GetLastError();
434 DWORD CorrectError = (ptest->result ? 0xdeadbeef : ERROR_INVALID_PARAMETER);
436 ok(LastError == CorrectError, "%s(\"%s\"), 0x%02x: GetLastError() returned %d, should be %d\n", function, ptest->string, initial_value, LastError, CorrectError);
437 ok(result == ptest->result, "%s(\"%s\"), 0x%02x: return value should be %s\n", function, ptest->string, initial_value, ptest->result ? "TRUE" : "FALSE");
440 #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)
441 #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); }
443 static void check_dcb(const char *function, TEST *ptest, int initial_value, DCB *pdcb1, DCB *pdcb2)
445 /* DCBlength is a special case since Win 9x sets it but NT does not.
446 We will accept either as correct. */
447 check_dcb_member2(DCBlength, (DWORD)sizeof(DCB), "%u");
449 /* For old style control strings Win 9x does not set the next five members, NT does. */
450 if(ptest->old_style && ptest->result)
452 check_dcb_member2(fOutxCtsFlow, ((unsigned int)initial_value & 1), "%u");
453 check_dcb_member2(fDtrControl, ((unsigned int)initial_value & 3), "%u");
454 check_dcb_member2(fOutX, ((unsigned int)initial_value & 1), "%u");
455 check_dcb_member2(fInX, ((unsigned)initial_value & 1), "%u");
456 check_dcb_member2(fRtsControl, ((unsigned)initial_value & 3), "%u");
460 check_dcb_member(fOutxCtsFlow, "%u");
461 check_dcb_member(fDtrControl, "%u");
462 check_dcb_member(fOutX, "%u");
463 check_dcb_member(fInX, "%u");
464 check_dcb_member(fRtsControl, "%u");
469 /* For the idsr=xxx parameter, NT sets fDsrSensitivity, 9x sets
471 if(!ptest->old_style)
473 check_dcb_member2(fOutxDsrFlow, pdcb2->fDsrSensitivity, "%u");
474 check_dcb_member2(fDsrSensitivity, pdcb2->fOutxDsrFlow, "%u");
478 /* For old style control strings Win 9x does not set the
479 fOutxDsrFlow member, NT does. */
480 check_dcb_member2(fOutxDsrFlow, ((unsigned int)initial_value & 1), "%u");
481 check_dcb_member(fDsrSensitivity, "%u");
486 check_dcb_member(fOutxDsrFlow, "%u");
487 check_dcb_member(fDsrSensitivity, "%u");
490 /* Check the result of the DCB members. */
491 check_dcb_member(BaudRate, "%u");
492 check_dcb_member(fBinary, "%u");
493 check_dcb_member(fParity, "%u");
494 check_dcb_member(fTXContinueOnXoff, "%u");
495 check_dcb_member(fErrorChar, "%u");
496 check_dcb_member(fNull, "%u");
497 check_dcb_member(fAbortOnError, "%u");
498 check_dcb_member(fDummy2, "%u");
499 check_dcb_member(wReserved, "%u");
500 check_dcb_member(XonLim, "%u");
501 check_dcb_member(XoffLim, "%u");
502 check_dcb_member(ByteSize, "%u");
503 check_dcb_member(Parity, "%u");
504 check_dcb_member(StopBits, "%u");
505 check_dcb_member(XonChar, "%d");
506 check_dcb_member(XoffChar, "%d");
507 check_dcb_member(ErrorChar, "%d");
508 check_dcb_member(EofChar, "%d");
509 check_dcb_member(EvtChar, "%d");
510 check_dcb_member(wReserved1, "%u");
513 #define check_timeouts_member(a) ok(ptimeouts1->a == ptimeouts2->a, "%s(\"%s\"), 0x%02x: "#a" is %u, should be %u\n", function, ptest->string, initial_value, ptimeouts1->a, ptimeouts2->a);
515 static void check_timeouts(const char *function, TEST *ptest, int initial_value, COMMTIMEOUTS *ptimeouts1, COMMTIMEOUTS *ptimeouts2)
517 check_timeouts_member(ReadIntervalTimeout);
518 check_timeouts_member(ReadTotalTimeoutMultiplier);
519 check_timeouts_member(ReadTotalTimeoutConstant);
520 check_timeouts_member(WriteTotalTimeoutMultiplier);
521 check_timeouts_member(WriteTotalTimeoutConstant);
524 static void test_BuildCommDCBA(TEST *ptest, int initial_value, DCB *pexpected_dcb)
529 /* set initial conditions */
530 memset(&dcb, initial_value, sizeof(DCB));
531 SetLastError(0xdeadbeef);
533 result = BuildCommDCBA(ptest->string, &dcb);
536 check_result("BuildCommDCBA", ptest, initial_value, result);
537 check_dcb("BuildCommDCBA", ptest, initial_value, &dcb, pexpected_dcb);
540 static void test_BuildCommDCBAndTimeoutsA(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
544 COMMTIMEOUTS timeouts;
546 /* set initial conditions */
547 memset(&dcb, initial_value, sizeof(DCB));
548 memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
549 SetLastError(0xdeadbeef);
551 result = BuildCommDCBAndTimeoutsA(ptest->string, &dcb, &timeouts);
554 check_result("BuildCommDCBAndTimeoutsA", ptest, initial_value, result);
555 check_dcb("BuildCommDCBAndTimeoutsA", ptest, initial_value, &dcb, pexpected_dcb);
556 check_timeouts("BuildCommDCBAndTimeoutsA", ptest, initial_value, &timeouts, pexpected_timeouts);
559 static void test_BuildCommDCBW(TEST *ptest, int initial_value, DCB *pexpected_dcb)
563 WCHAR wide_string[sizeof(ptest->string)];
564 static int reportedDCBW = 0;
566 MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
568 /* set initial conditions */
569 memset(&dcb, initial_value, sizeof(DCB));
570 SetLastError(0xdeadbeef);
572 result = BuildCommDCBW(wide_string, &dcb);
574 if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
577 win_skip("BuildCommDCBW is not implemented\n");
582 check_result("BuildCommDCBW", ptest, initial_value, result);
583 check_dcb("BuildCommDCBW", ptest, initial_value, &dcb, pexpected_dcb);
586 static void test_BuildCommDCBAndTimeoutsW(TEST *ptest, int initial_value, DCB *pexpected_dcb, COMMTIMEOUTS *pexpected_timeouts)
590 COMMTIMEOUTS timeouts;
591 WCHAR wide_string[sizeof(ptest->string)];
592 static int reportedDCBAndTW = 0;
594 MultiByteToWideChar(CP_ACP, 0, ptest->string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR));
596 /* set initial conditions */
597 memset(&dcb, initial_value, sizeof(DCB));
598 memset(&timeouts, initial_value, sizeof(COMMTIMEOUTS));
599 SetLastError(0xdeadbeef);
601 result = BuildCommDCBAndTimeoutsW(wide_string, &dcb, &timeouts);
603 if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
605 if(!reportedDCBAndTW++)
606 win_skip("BuildCommDCBAndTimeoutsW is not implemented\n");
611 check_result("BuildCommDCBAndTimeoutsW", ptest, initial_value, result);
612 check_dcb("BuildCommDCBAndTimeoutsW", ptest, initial_value, &dcb, pexpected_dcb);
613 check_timeouts("BuildCommDCBAndTimeoutsW", ptest, initial_value, &timeouts, pexpected_timeouts);
616 static void test_BuildCommDCB(void)
618 char port_name[] = "COMx";
623 /* Some of these tests require a valid COM port. This loop will try to find
625 for(port_name[3] = '1'; port_name[3] <= '9'; port_name[3]++)
627 COMMCONFIG commconfig;
628 DWORD size = sizeof(COMMCONFIG);
630 if(GetDefaultCommConfig(port_name, &commconfig, &size))
638 trace("Could not find a valid COM port. Some tests will be skipped.\n");
640 for(i = 0; i < TEST_COUNT; i++)
642 /* Check if this test case needs a valid COM port. */
643 ptr = strstr(test[i].string, "COMx");
645 /* If required, substitute valid port number into device control string. */
654 test_BuildCommDCBA(&test[i], 0x00, &test[i].dcb1);
655 test_BuildCommDCBA(&test[i], 0xff, &test[i].dcb2);
656 test_BuildCommDCBAndTimeoutsA(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
657 test_BuildCommDCBAndTimeoutsA(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
659 test_BuildCommDCBW(&test[i], 0x00, &test[i].dcb1);
660 test_BuildCommDCBW(&test[i], 0xff, &test[i].dcb2);
661 test_BuildCommDCBAndTimeoutsW(&test[i], 0x00, &test[i].dcb1, &test[i].timeouts1);
662 test_BuildCommDCBAndTimeoutsW(&test[i], 0xff, &test[i].dcb2, &test[i].timeouts2);
666 static HANDLE test_OpenComm(BOOL doOverlap)
668 HANDLE hcom = INVALID_HANDLE_VALUE;
669 char port_name[] = "COMx";
670 static BOOL shown = FALSE;
674 /* Try to find a port */
675 for(port_name[3] = '1'; port_name[3] <= '9'; port_name[3]++)
677 hcom = CreateFile( port_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
678 (doOverlap)?FILE_FLAG_OVERLAPPED:0, NULL );
679 if (hcom != INVALID_HANDLE_VALUE)
684 if (hcom == INVALID_HANDLE_VALUE)
685 trace("Could not find a valid COM port. Skipping test_ReadTimeOut\n");
687 trace("Found Com port %s. Connected devices may disturbe results\n", port_name);
690 if (hcom != INVALID_HANDLE_VALUE)
694 ret = ClearCommError(hcom, &errors, &comstat);
695 if (!ret && GetLastError() == ERROR_NOT_READY)
697 trace("%s doesn't respond, skipping the test\n", port_name);
699 return INVALID_HANDLE_VALUE;
702 ok(ret, "Unexpected error %u on open\n", GetLastError());
703 ok(comstat.cbInQue == 0, "Unexpected %d chars in InQueue\n",comstat.cbInQue);
704 ok(comstat.cbOutQue == 0, "Still pending %d charcters in OutQueue\n", comstat.cbOutQue);
705 ok(errors == 0, "Unexpected errors 0x%08x\n", errors);
710 static void test_GetModemStatus(HANDLE hcom)
714 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
715 trace("GetCommModemStatus returned 0x%08x->%s%s%s%s\n", ModemStat,
716 (ModemStat &MS_RLSD_ON)?"MS_RLSD_ON ":"",
717 (ModemStat &MS_RING_ON)?"MS_RING_ON ":"",
718 (ModemStat &MS_DSR_ON)?"MS_DSR_ON ":"",
719 (ModemStat &MS_CTS_ON)?"MS_CTS_ON ":"");
722 /* When we don't write anything, Read should time out even on a loopbacked port */
723 static void test_ReadTimeOut(HANDLE hcom)
726 COMMTIMEOUTS timeouts;
728 DWORD before, after, read, timediff, LastError;
731 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
732 dcb.BaudRate = FASTBAUD;
734 dcb.Parity = NOPARITY;
735 dcb.fRtsControl=RTS_CONTROL_ENABLE;
736 dcb.fDtrControl=DTR_CONTROL_ENABLE;
737 dcb.StopBits = ONESTOPBIT;
738 ok(SetCommState(hcom, &dcb), "SetCommState failed\n");
740 ZeroMemory( &timeouts, sizeof(timeouts));
741 timeouts.ReadTotalTimeoutConstant = TIMEOUT;
742 ok(SetCommTimeouts(hcom, &timeouts),"SetCommTimeouts failed\n");
744 before = GetTickCount();
745 SetLastError(0xdeadbeef);
746 res = ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL);
747 LastError = GetLastError();
748 after = GetTickCount();
749 ok( res == TRUE, "A timed-out read should return TRUE\n");
750 ok( LastError == 0xdeadbeef, "err=%d\n", LastError);
751 timediff = after - before;
752 ok( timediff > TIMEOUT>>2 && timediff < TIMEOUT *2,
753 "Unexpected TimeOut %d, expected %d\n", timediff, TIMEOUT);
756 static void test_waittxempty(HANDLE hcom)
759 COMMTIMEOUTS timeouts;
760 char tbuf[]="test_waittxempty";
761 DWORD before, after, written, timediff, evtmask = 0;
763 DWORD baud = SLOWBAUD;
765 trace("test_waittxempty\n");
766 /* set a low baud rate to have ample time*/
767 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
770 dcb.Parity = NOPARITY;
771 dcb.fRtsControl=RTS_CONTROL_ENABLE;
772 dcb.fDtrControl=DTR_CONTROL_ENABLE;
773 dcb.StopBits = ONESTOPBIT;
774 ok(SetCommState(hcom, &dcb), "SetCommState failed\n");
776 ZeroMemory( &timeouts, sizeof(timeouts));
777 timeouts.ReadTotalTimeoutConstant = TIMEOUT;
778 ok(SetCommTimeouts(hcom, &timeouts),"SetCommTimeouts failed\n");
780 ok(SetupComm(hcom,1024,1024),"SetUpComm failed\n");
781 ok(SetCommMask(hcom, EV_TXEMPTY), "SetCommMask failed\n");
783 before = GetTickCount();
784 res_write=WriteFile(hcom, tbuf, sizeof(tbuf), &written, NULL);
785 after = GetTickCount();
786 ok(res_write == TRUE, "WriteFile failed\n");
787 ok(written == sizeof(tbuf),
788 "WriteFile: Unexpected write_size %d\n", written);
790 trace("WriteFile succeeded, took %d ms to write %d Bytes at %d Baud\n",
791 after - before, written, baud);
793 before = GetTickCount();
794 res = WaitCommEvent(hcom, &evtmask, NULL);
795 after = GetTickCount();
797 ok(res == TRUE, "WaitCommEvent failed\n");
798 ok((evtmask & EV_TXEMPTY),
799 "WaitCommEvent: Unexpected EvtMask 0x%08x, expected 0x%08x\n",
800 evtmask, EV_TXEMPTY);
802 timediff = after - before;
804 trace("WaitCommEvent for EV_TXEMPTY took %d ms\n", timediff);
805 /* 050604: This shows a difference between XP (tested with mingw compiled crosstest):
806 XP returns Writefile only after everything went out of the Serial port,
807 while wine returns immedate.
808 Thus on XP, WaintCommEvent after setting the CommMask for EV_TXEMPTY
809 nearly return immediate,
810 while on wine the most time is spent here
814 /* A new open handle should not return error or have bytes in the Queues */
815 static void test_ClearCommErrors(HANDLE hcom)
820 ok(ClearCommError(hcom, &errors, &lpStat), "ClearCommError failed\n");
821 ok(lpStat.cbInQue == 0, "Unexpected %d chars in InQueue\n", lpStat.cbInQue);
822 ok(lpStat.cbOutQue == 0, "Unexpected %d chars in OutQueue\n", lpStat.cbOutQue);
823 ok(errors == 0, "ClearCommErrors: Unexpected error 0x%08x\n", errors);
824 trace("test_ClearCommErrors done\n");
827 static void test_non_pending_errors(HANDLE hcom)
832 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
833 dcb.ByteSize = 255; /* likely bogus */
834 ok(!SetCommState(hcom, &dcb), "SetCommState should have failed\n");
835 ok(ClearCommError(hcom, &err, NULL), "ClearCommError should succeed\n");
836 ok(!(err & CE_MODE), "ClearCommError shouldn't set CE_MODE byte in this case (%x)\n", err);
840 static void test_LoopbackRead(HANDLE hcom)
843 COMMTIMEOUTS timeouts;
845 DWORD before, after, diff, read, read1, written, evtmask=0, i;
847 char tbuf[]="test_LoopbackRead";
849 trace("Starting test_LoopbackRead\n");
850 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
851 dcb.BaudRate = FASTBAUD;
853 dcb.Parity = NOPARITY;
854 dcb.fRtsControl=RTS_CONTROL_ENABLE;
855 dcb.fDtrControl=DTR_CONTROL_ENABLE;
856 dcb.StopBits = ONESTOPBIT;
857 ok(SetCommState(hcom, &dcb), "SetCommState failed\n");
859 ZeroMemory( &timeouts, sizeof(timeouts));
860 timeouts.ReadTotalTimeoutConstant = TIMEOUT;
861 ok(SetCommTimeouts(hcom, &timeouts),"SetCommTimeouts failed\n");
863 ok(SetCommMask(hcom, EV_TXEMPTY), "SetCommMask failed\n");
865 before = GetTickCount();
866 ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
867 after = GetTickCount();
868 ok(written == sizeof(tbuf),"WriteFile %d bytes written\n", written);
869 diff = after -before;
871 /* make sure all bytes are written, so Readfile will succeed in one call*/
872 ok(WaitCommEvent(hcom, &evtmask, NULL), "WaitCommEvent failed\n");
873 before = GetTickCount();
874 ok(evtmask == EV_TXEMPTY,
875 "WaitCommEvent: Unexpected EvtMask 0x%08x, expected 0x%08x\n",
876 evtmask, EV_TXEMPTY);
877 trace("Write %d ms WaitCommEvent EV_TXEMPTY %d ms\n", diff, before- after);
880 ok(ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL), "Readfile failed\n");
881 ok(read == sizeof(tbuf),"ReadFile read %d bytes, expected \"%s\"\n", read,rbuf);
883 /* Now do the same with a slower Baud rate.
884 As we request more characters then written, we will hit the timeout
887 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
890 dcb.Parity = NOPARITY;
891 dcb.fRtsControl=RTS_CONTROL_ENABLE;
892 dcb.fDtrControl=DTR_CONTROL_ENABLE;
893 dcb.StopBits = ONESTOPBIT;
894 ok(SetCommState(hcom, &dcb), "SetCommState failed\n");
896 ok(SetCommMask(hcom, EV_RXCHAR), "SetCommMask failed\n");
897 ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
898 ok(written == sizeof(tbuf),"WriteFile %d bytes written\n", written);
900 trace("WaitCommEventEV_RXCHAR\n");
901 ok(WaitCommEvent(hcom, &evtmask, NULL), "WaitCommEvent failed\n");
902 ok(evtmask == EV_RXCHAR, "WaitCommEvent: Unexpected EvtMask 0x%08x, expected 0x%08x\n",
905 before = GetTickCount();
906 res = ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL);
907 after = GetTickCount();
908 ok(res, "Readfile failed\n");
909 ok(read == sizeof(tbuf),"ReadFile read %d bytes\n", read);
910 diff = after - before;
911 trace("Readfile for %d chars took %d ms\n", read, diff);
912 ok( (diff > TIMEOUT - TIMEDELTA) && (diff < TIMEOUT + TIMEDELTA),
913 "Timedout Wait took %d ms, expected around %d\n", diff, TIMEOUT);
915 /* now do a plain read with slow speed
916 * This will result in several low level reads and a timeout to happen
918 dcb.BaudRate = SLOWBAUD;
919 ok(SetCommState(hcom, &dcb), "SetCommState failed\n");
920 ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
921 before = GetTickCount();
927 res = ReadFile(hcom, rbuf+read, sizeof(rbuf-read), &read1, NULL);
928 ok(res, "Readfile failed\n");
932 while ((read < sizeof(tbuf)) && (i <10));
933 after = GetTickCount();
934 ok( read == sizeof(tbuf),"ReadFile read %d bytes\n", read);
935 trace("Plain Read for %d char at %d baud took %d ms\n", read, SLOWBAUD, after-before);
938 static void test_LoopbackCtsRts(HANDLE hcom)
940 DWORD ModemStat = 0, defaultStat = 0;
943 memset (&dcb, 0, sizeof (dcb));
944 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
945 if (dcb.fRtsControl == RTS_CONTROL_HANDSHAKE)
947 trace("RTS_CONTROL_HANDSHAKE is set, so don't manipulate RTS\n");
950 ok(GetCommModemStatus(hcom, &defaultStat), "GetCommModemStatus failed\n");
951 /* XP returns some values in the low nibble, so mask them out*/
952 defaultStat &= MS_CTS_ON|MS_DSR_ON|MS_RING_ON|MS_RLSD_ON;
953 if(defaultStat & MS_CTS_ON)
955 ok(EscapeCommFunction(hcom, CLRRTS), "EscapeCommFunction failed to clear RTS\n");
956 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
957 ok ((ModemStat & MS_CTS_ON) == 0, "CTS didn't react: 0x%04x, expected 0x%04x\n",
958 ModemStat, (defaultStat & ~MS_CTS_ON));
959 ok(EscapeCommFunction(hcom, SETRTS), "EscapeCommFunction failed to clear RTS\n");
960 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
961 ok (ModemStat == defaultStat, "Failed to restore CTS: 0x%04x, expected 0x%04x\n",
962 ModemStat, defaultStat);
966 ok(EscapeCommFunction(hcom, SETRTS), "EscapeCommFunction failed to set RTS\n");
967 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
968 ok ((ModemStat & MS_CTS_ON) == MS_CTS_ON,
969 "CTS didn't react: 0x%04x, expected 0x%04x\n",
970 ModemStat, (defaultStat | MS_CTS_ON));
971 ok(EscapeCommFunction(hcom, CLRRTS), "EscapeCommFunction failed to clear RTS\n");
972 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
973 ok (ModemStat == defaultStat, "Failed to restore CTS: 0x%04x, expected 0x%04x\n",
974 ModemStat, defaultStat);
978 static void test_LoopbackDtrDcd(HANDLE hcom)
980 DWORD ModemStat = 0, defaultStat = 0;
983 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
984 if (dcb.fDtrControl == DTR_CONTROL_HANDSHAKE)
986 trace("DTR_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
989 ok(GetCommModemStatus(hcom, &defaultStat), "GetCommModemStatus failed\n");
990 /* XP returns some values in the low nibble, so mask them out*/
991 defaultStat &= MS_CTS_ON|MS_DSR_ON|MS_RING_ON|MS_RLSD_ON;
992 if(defaultStat & MS_RLSD_ON)
994 ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
995 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
996 ok ((ModemStat & MS_RLSD_ON) == 0, "RLSD didn't react: 0x%04x, expected 0x%04x\n",
997 ModemStat, (defaultStat & ~MS_RLSD_ON));
998 ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
999 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1000 ok (ModemStat == defaultStat, "Failed to restore RLSD: 0x%04x, expected 0x%04x\n",
1001 ModemStat, defaultStat);
1005 ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
1006 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1007 ok ((ModemStat & MS_RLSD_ON) == MS_RLSD_ON,
1008 "RLSD didn't react: 0x%04x, expected 0x%04x\n",
1009 ModemStat, (defaultStat | MS_RLSD_ON));
1010 ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
1011 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1012 ok (ModemStat == defaultStat, "Failed to restore RLSD: 0x%04x, expected 0x%04x\n",
1013 ModemStat, defaultStat);
1017 static void test_LoopbackDtrDsr(HANDLE hcom)
1019 DWORD ModemStat = 0, defaultStat = 0;
1022 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
1023 if (dcb.fDtrControl == DTR_CONTROL_DISABLE)
1025 trace("DTR_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
1028 ok(GetCommModemStatus(hcom, &defaultStat), "GetCommModemStatus failed\n");
1029 /* XP returns some values in the low nibble, so mask them out*/
1030 defaultStat &= MS_CTS_ON|MS_DSR_ON|MS_RING_ON|MS_RLSD_ON;
1031 if(defaultStat & MS_DSR_ON)
1033 ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
1034 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1035 ok ((ModemStat & MS_DSR_ON) == 0, "CTS didn't react: 0x%04x, expected 0x%04x\n",
1036 ModemStat, (defaultStat & ~MS_DSR_ON));
1037 ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to clear DTR\n");
1038 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1039 ok (ModemStat == defaultStat, "Failed to restore DSR: 0x%04x, expected 0x%04x\n",
1040 ModemStat, defaultStat);
1044 ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
1045 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1046 ok ((ModemStat & MS_DSR_ON) == MS_DSR_ON,
1047 "CTS didn't react: 0x%04x,expected 0x%04x\n",
1048 ModemStat, (defaultStat | MS_DSR_ON));
1049 ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
1050 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1051 ok (ModemStat == defaultStat, "Failed to restore DSR: 0x%04x, expected 0x%04x\n",
1052 ModemStat, defaultStat);
1056 static void test_LoopbackDtrRing(HANDLE hcom)
1058 DWORD ModemStat = 0, defaultStat = 0;
1061 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
1062 if (dcb.fDtrControl == DTR_CONTROL_HANDSHAKE)
1064 trace("DTR_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
1067 ok(GetCommModemStatus(hcom, &defaultStat), "GetCommModemStatus failed\n");
1068 /* XP returns some values in the low nibble, so mask them out*/
1069 defaultStat &= MS_CTS_ON|MS_DSR_ON|MS_RING_ON|MS_RLSD_ON;
1070 if(defaultStat & MS_RING_ON)
1072 ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
1073 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1074 ok ((ModemStat & MS_RING_ON) == 0, "RING didn't react: 0x%04x, expected 0x%04x\n",
1075 ModemStat, (defaultStat & ~MS_RING_ON));
1076 ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
1077 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1078 ok (ModemStat == defaultStat, "Failed to restore RING: 0x%04x, expected 0x%04x\n",
1079 ModemStat, defaultStat);
1083 ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
1084 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1085 ok ((ModemStat & MS_RING_ON) == MS_RING_ON,
1086 "RING didn't react: 0x%04x,expected 0x%04x\n",
1087 ModemStat, (defaultStat | MS_RING_ON));
1088 ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
1089 ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
1090 ok (ModemStat == defaultStat, "Failed to restore RING: 0x%04x, expected 0x%04x\n",
1091 ModemStat, defaultStat);
1096 * Set up a WaitCommEvent for anything in the receive buffer,
1097 * then write to TX to put a character
1098 * into the RX buffer
1099 * Need Loopback TX->RX
1102 static void test_WaitRx(HANDLE hcom)
1104 OVERLAPPED overlapped, overlapped_w;
1105 HANDLE hComPortEvent, hComWriteEvent;
1106 DWORD before, after, after1, diff, success_wait = FALSE, success_write;
1107 DWORD err_wait, err_write, written, evtmask=0;
1109 ok(SetCommMask(hcom, EV_RXCHAR), "SetCommMask failed\n");
1110 hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
1111 ok(hComPortEvent != 0, "CreateEvent failed\n");
1112 ZeroMemory( &overlapped, sizeof(overlapped));
1113 overlapped.hEvent = hComPortEvent;
1115 ok((hComWriteEvent = CreateEvent( NULL, TRUE, FALSE, NULL )) !=0,
1116 "CreateEvent res %d\n",
1118 ZeroMemory( &overlapped_w, sizeof(overlapped_w));
1119 overlapped_w.hEvent = hComWriteEvent;
1121 before = GetTickCount();
1122 {success_wait = WaitCommEvent(hcom, &evtmask, &overlapped);}
1123 err_wait = GetLastError();
1124 after = GetTickCount();
1125 trace("Success 0x%08x err %d evtmask 0x%08x\n", success_wait, err_wait, evtmask);
1126 ok(success_wait || err_wait == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
1127 trace("overlapped WriteCommEvent returned.\n");
1129 success_write= WriteFile(hcom, "X", 1, &written, &overlapped_w);
1130 err_write = GetLastError();
1131 ok(success_write || err_write == ERROR_IO_PENDING,
1132 "overlapped WriteFile failed, err %d\n",
1135 if (!success_write && (err_write == ERROR_IO_PENDING)) {
1136 success_write = WaitForSingleObjectEx(hComWriteEvent, TIMEOUT, TRUE);
1137 err_write = GetLastError();
1138 ok(success_write == WAIT_OBJECT_0, "WaitForSingleObjectEx, res %d, err %d\n",
1139 success_write, err_write);
1142 success_write = GetOverlappedResult(hcom, &overlapped_w, &written, FALSE);
1143 err_write = GetLastError();
1145 trace("Write after Wait res 0x%08x err %d\n",success_write, err_write);
1146 ok(success_write && written ==1, "Write after Wait res 0x%08x err %d\n",
1147 success_write, err_write);
1149 if (!success_wait && (err_wait == ERROR_IO_PENDING)) {
1150 success_wait = WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE);
1151 err_wait = GetLastError();
1152 ok(success_wait == WAIT_OBJECT_0, "wait hComPortEvent, res 0x%08x, err %d\n",
1153 success_wait, err_wait);
1155 success_wait = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
1156 err_wait = GetLastError();
1157 after1 = GetTickCount();
1158 trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
1159 success_wait, err_wait, evtmask, after-before, after1-before);
1161 ok(evtmask & EV_RXCHAR, "Detect EV_RXCHAR: 0x%08x, expected 0x%08x\n",
1162 evtmask, EV_RXCHAR);
1163 diff = after1 - before;
1164 ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
1165 "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
1169 /* Change the controling line after the given timeout to the given state
1170 By the loopback, this should trigger the WaitCommEvent
1172 static DWORD CALLBACK toggle_ctlLine(LPVOID arg)
1174 DWORD_PTR *args = arg;
1175 DWORD timeout = args[0];
1176 DWORD ctl = args[1];
1177 HANDLE hcom = (HANDLE) args[2];
1178 HANDLE hComPortEvent = (HANDLE) args[3];
1181 trace("toggle_ctlLine timeout %d ctl 0x%08x handle %p\n", timeout, ctl, hcom );
1183 ok(EscapeCommFunction(hcom, ctl),"EscapeCommFunction 0x%08x failed\n", ctl);
1184 trace("toggle_ctline done\n");
1185 success = WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE);
1186 err = GetLastError();
1187 trace("toggle_ctline WaitForSingleObjectEx res 0x%08x err %d\n",
1193 * Wait for a change in CTS
1194 * Needs Loopback from DTR to CTS
1196 static void test_WaitCts(HANDLE hcom)
1199 OVERLAPPED overlapped;
1200 HANDLE hComPortEvent;
1203 DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat = 0;
1205 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
1206 dcb.fRtsControl=RTS_CONTROL_ENABLE;
1207 dcb.fDtrControl=DTR_CONTROL_ENABLE;
1208 ok(SetCommState(hcom, &dcb), "SetCommState failed\n");
1209 if (dcb.fDtrControl == RTS_CONTROL_DISABLE)
1211 trace("RTS_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
1214 args[0]= TIMEOUT >>1;
1215 ok(GetCommModemStatus(hcom, &defaultStat), "GetCommModemStatus failed\n");
1216 if(defaultStat & MS_CTS_ON)
1220 args[2]=(DWORD_PTR)hcom;
1222 trace("test_WaitCts timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
1224 ok(SetCommMask(hcom, EV_CTS), "SetCommMask failed\n");
1225 hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
1226 ok(hComPortEvent != 0, "CreateEvent failed\n");
1227 args[3] = (DWORD_PTR)hComPortEvent;
1228 alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
1229 /* Wait a minimum to let the thread start up */
1231 trace("Thread created\n");
1232 ok(alarmThread !=0 , "CreateThread Failed\n");
1234 ZeroMemory( &overlapped, sizeof(overlapped));
1235 overlapped.hEvent = hComPortEvent;
1236 before = GetTickCount();
1237 success = WaitCommEvent(hcom, &evtmask, &overlapped);
1238 err = GetLastError();
1239 after = GetTickCount();
1241 trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
1242 ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
1243 trace("overlapped WriteCommEvent returned.\n");
1244 if (!success && (err == ERROR_IO_PENDING))
1245 ok(WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE) == 0,
1246 "WaitCts hComPortEvent failed\n");
1247 success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
1248 err = GetLastError();
1249 after1 = GetTickCount();
1250 trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
1251 success, err, evtmask, after-before, after1-before);
1253 ok(evtmask & EV_CTS, "Failed to detect EV_CTS: 0x%08x, expected 0x%08x\n",
1255 ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
1256 if(defaultStat & MS_CTS_ON)
1257 ok((evtmask & MS_CTS_ON) == 0,"CTS didn't change state!\n");
1259 ok((evtmask & MS_CTS_ON), "CTS didn't change state!\n");
1261 diff = after1 - before;
1262 ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
1263 "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
1265 /*restore RTS Settings*/
1266 if(defaultStat & MS_CTS_ON)
1272 /* Change the Comm Mask while a Wait is going on
1273 WaitCommevent should return with a EVTMASK set to zero
1275 static DWORD CALLBACK reset_CommMask(LPVOID arg)
1277 DWORD_PTR *args = arg;
1278 DWORD timeout = args[0];
1279 HANDLE hcom = (HANDLE) args[1];
1281 trace(" Changing CommMask on the fly for handle %p after timeout %d\n",
1284 ok(SetCommMask(hcom, 0),"SetCommMask %p failed\n", hcom);
1285 trace("SetCommMask changed\n");
1289 /* Set up a Wait for a change on CTS. We don't toggle any line, but we
1290 reset the CommMask and expect the wait to return with a mask of 0
1291 No special port connections needed
1293 static void test_AbortWaitCts(HANDLE hcom)
1296 OVERLAPPED overlapped;
1297 HANDLE hComPortEvent;
1300 DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
1302 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
1303 if (dcb.fDtrControl == RTS_CONTROL_DISABLE)
1305 trace("RTS_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
1308 args[0]= TIMEOUT >>1;
1309 args[1]= (DWORD_PTR)hcom;
1311 trace("test_AbortWaitCts timeout %ld handle %p\n",args[0], hcom);
1313 ok(SetCommMask(hcom, EV_CTS), "SetCommMask failed\n");
1314 hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
1315 ok(hComPortEvent != 0, "CreateEvent failed\n");
1316 alarmThread = CreateThread(NULL, 0, reset_CommMask, args, 0, &alarmThreadId);
1317 /* Wait a minimum to let the thread start up */
1319 trace("Thread created\n");
1320 ok(alarmThread !=0 , "CreateThread Failed\n");
1322 ZeroMemory( &overlapped, sizeof(overlapped));
1323 overlapped.hEvent = hComPortEvent;
1324 before = GetTickCount();
1325 success = WaitCommEvent(hcom, &evtmask, &overlapped);
1326 err = GetLastError();
1327 after = GetTickCount();
1329 trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
1330 ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
1331 trace("overlapped WriteCommEvent returned.\n");
1332 if (!success && (err == ERROR_IO_PENDING))
1333 ok(WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE) == 0,
1334 "AbortWaitCts hComPortEvent failed\n");
1335 success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
1336 err = GetLastError();
1337 after1 = GetTickCount();
1338 trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
1339 success, err, evtmask, after-before, after1-before);
1341 ok(evtmask == 0, "Incorect EventMask 0x%08x returned on Wait aborted bu SetCommMask, expected 0x%08x\n",
1343 ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
1344 diff = after1 - before;
1345 ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
1346 "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
1351 * Wait for a change in DSR
1352 * Needs Loopback from DTR to DSR
1354 static void test_WaitDsr(HANDLE hcom)
1357 OVERLAPPED overlapped;
1358 HANDLE hComPortEvent;
1361 DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat = 0;
1363 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
1364 if (dcb.fDtrControl == DTR_CONTROL_DISABLE)
1366 trace("DTR_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
1369 args[0]= TIMEOUT >>1;
1370 ok(GetCommModemStatus(hcom, &defaultStat), "GetCommModemStatus failed\n");
1371 if(defaultStat & MS_DSR_ON)
1375 args[2]= (DWORD_PTR)hcom;
1377 trace("test_WaitDsr timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
1379 ok(SetCommMask(hcom, EV_DSR), "SetCommMask failed\n");
1380 hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
1381 ok(hComPortEvent != 0, "CreateEvent failed\n");
1382 alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
1383 ok(alarmThread !=0 , "CreateThread Failed\n");
1385 ZeroMemory( &overlapped, sizeof(overlapped));
1386 overlapped.hEvent = hComPortEvent;
1387 before = GetTickCount();
1388 success = WaitCommEvent(hcom, &evtmask, &overlapped);
1389 err = GetLastError();
1390 after = GetTickCount();
1392 trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
1393 ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
1394 trace("overlapped WriteCommEvent returned.\n");
1395 if (!success && (err == ERROR_IO_PENDING))
1396 ok(WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE) == 0,
1397 "wait hComPortEvent failed\n");
1398 success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
1399 err = GetLastError();
1400 after1 = GetTickCount();
1401 trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
1402 success, err, evtmask, after-before, after1-before);
1404 ok(evtmask & EV_DSR, "Failed to detect EV_DSR: 0x%08x, expected 0x%08x\n",
1406 ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
1407 if(defaultStat & MS_DSR_ON)
1408 ok((evtmask & MS_DSR_ON) == 0,"DTR didn't change state!\n");
1410 ok((evtmask & MS_DSR_ON), "DTR didn't change state!\n");
1412 diff = after1 - before;
1413 ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
1414 "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
1416 /*restore RTS Settings*/
1417 if(defaultStat & MS_DSR_ON)
1425 * Needs Loopback from DTR to RING
1427 static void test_WaitRing(HANDLE hcom)
1430 OVERLAPPED overlapped;
1431 HANDLE hComPortEvent;
1434 DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat;
1437 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
1438 if (dcb.fDtrControl == DTR_CONTROL_DISABLE)
1440 trace("DTR_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
1443 args[0]= TIMEOUT >>1;
1444 ok((ret = GetCommModemStatus(hcom, &defaultStat)), "GetCommModemStatus failed\n");
1446 skip("modem status failed -> skip.\n");
1449 if(defaultStat & MS_RING_ON)
1453 args[2]=(DWORD_PTR) hcom;
1455 trace("test_WaitRing timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
1457 ok(SetCommMask(hcom, EV_RING), "SetCommMask failed\n");
1458 hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
1459 ok(hComPortEvent != 0, "CreateEvent failed\n");
1460 alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
1461 ok(alarmThread !=0 , "CreateThread Failed\n");
1463 ZeroMemory( &overlapped, sizeof(overlapped));
1464 overlapped.hEvent = hComPortEvent;
1465 before = GetTickCount();
1466 success = WaitCommEvent(hcom, &evtmask, &overlapped);
1467 err = GetLastError();
1468 after = GetTickCount();
1470 trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
1471 ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
1472 trace("overlapped WriteCommEvent returned.\n");
1473 if (!success && (err == ERROR_IO_PENDING))
1474 ok(WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE) == 0,
1475 "wait hComPortEvent failed\n");
1476 success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
1477 err = GetLastError();
1478 after1 = GetTickCount();
1479 trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
1480 success, err, evtmask, after-before, after1-before);
1482 ok(evtmask & EV_RING, "Failed to detect EV_RING: 0x%08x, expected 0x%08x\n",
1484 ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
1485 if(defaultStat & MS_RING_ON)
1486 ok((evtmask & MS_RING_ON) == 0,"DTR didn't change state!\n");
1488 ok((evtmask & MS_RING_ON), "DTR didn't change state!\n");
1490 diff = after1 - before;
1491 ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
1492 "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
1494 /*restore RTS Settings*/
1495 if(defaultStat & MS_RING_ON)
1501 * Wait for a change in DCD
1502 * Needs Loopback from DTR to DCD
1504 static void test_WaitDcd(HANDLE hcom)
1507 OVERLAPPED overlapped;
1508 HANDLE hComPortEvent;
1511 DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat = 0;
1513 ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
1514 if (dcb.fDtrControl == DTR_CONTROL_DISABLE)
1516 trace("DTR_CONTROL_HANDSHAKE is set, so don't manipulate DTR\n");
1519 args[0]= TIMEOUT >>1;
1520 ok(GetCommModemStatus(hcom, &defaultStat), "GetCommModemStatus failed\n");
1521 if(defaultStat & MS_RLSD_ON)
1525 args[2]= (DWORD_PTR)hcom;
1527 trace("test_WaitDcd timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
1529 ok(SetCommMask(hcom, EV_RLSD), "SetCommMask failed\n");
1530 hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
1531 ok(hComPortEvent != 0, "CreateEvent failed\n");
1532 alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
1533 ok(alarmThread !=0 , "CreateThread Failed\n");
1535 ZeroMemory( &overlapped, sizeof(overlapped));
1536 overlapped.hEvent = hComPortEvent;
1537 before = GetTickCount();
1538 success = WaitCommEvent(hcom, &evtmask, &overlapped);
1539 err = GetLastError();
1540 after = GetTickCount();
1542 trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
1543 ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
1544 trace("overlapped WriteCommEvent returned.\n");
1545 if (!success && (err == ERROR_IO_PENDING))
1546 ok(WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE) == 0,
1547 "wait hComPortEvent failed\n");
1548 success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
1549 err = GetLastError();
1550 after1 = GetTickCount();
1551 trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
1552 success, err, evtmask, after-before, after1-before);
1554 ok(evtmask & EV_RLSD, "Failed to detect EV_RLSD: 0x%08x, expected 0x%08x\n",
1556 ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
1557 if(defaultStat & MS_RLSD_ON)
1558 ok((evtmask & MS_RLSD_ON) == 0,"DTR didn't change state!\n");
1560 ok((evtmask & MS_RLSD_ON), "DTR didn't change state!\n");
1562 diff = after1 - before;
1563 ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
1564 "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
1566 /*restore RTS Settings*/
1567 if(defaultStat & MS_RLSD_ON)
1574 Set Break after timeout
1576 static DWORD CALLBACK set_CommBreak(LPVOID arg)
1578 DWORD_PTR *args = arg;
1579 DWORD timeout = args[0];
1580 HANDLE hcom = (HANDLE) args[1];
1582 trace("SetCommBreak for handle %p after timeout %d\n",
1585 ok(SetCommBreak(hcom),"SetCommBreak %p failed\n", hcom);
1586 trace("SetCommBreak done\n");
1591 Wait for the Break condition (TX resp. RX active)
1592 Needs Loopback TX-RX
1594 static void test_WaitBreak(HANDLE hcom)
1596 OVERLAPPED overlapped;
1597 HANDLE hComPortEvent;
1600 DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
1602 ok(SetCommMask(hcom, EV_BREAK), "SetCommMask failed\n");
1603 hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
1604 ok(hComPortEvent != 0, "CreateEvent failed\n");
1606 trace("test_WaitBreak\n");
1607 args[0]= TIMEOUT >>1;
1608 args[1]= (DWORD_PTR)hcom;
1609 alarmThread = CreateThread(NULL, 0, set_CommBreak, args, 0, &alarmThreadId);
1610 /* Wait a minimum to let the thread start up */
1612 trace("Thread created\n");
1613 ok(alarmThread !=0 , "CreateThread Failed\n");
1615 ZeroMemory( &overlapped, sizeof(overlapped));
1616 overlapped.hEvent = hComPortEvent;
1617 before = GetTickCount();
1618 success = WaitCommEvent(hcom, &evtmask, &overlapped);
1619 err = GetLastError();
1620 after = GetTickCount();
1622 trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
1623 ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
1624 trace("overlapped WriteCommEvent returned.\n");
1626 if (!success && (err == ERROR_IO_PENDING))
1627 ok(WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE) == 0,
1628 "wait hComPortEvent res %d\n", GetLastError());
1629 success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
1630 err = GetLastError();
1631 after1 = GetTickCount();
1632 trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
1633 success, err, evtmask, after-before, after1-before);
1635 ok(evtmask & EV_BREAK, "Failed to detect EV_BREAK: 0x%08x, expected 0x%08x\n",
1637 ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
1639 diff = after1 - before;
1640 ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
1641 "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
1643 ok(ClearCommBreak(hcom), "ClearCommBreak failed\n");
1646 static void test_stdio(void)
1650 /* cygwin tries this to determine the stdin handle type */
1651 ok( !GetCommState( GetStdHandle(STD_INPUT_HANDLE), &dcb ), "GetCommState succeeded on stdin\n" );
1652 ok( GetLastError() == ERROR_INVALID_HANDLE, "got error %u\n", GetLastError() );
1658 /* use variables and not #define to compile the code */
1659 BOOL loopback_txd_rxd = LOOPBACK_TXD_RXD;
1660 BOOL loopback_rts_cts = LOOPBACK_CTS_RTS;
1661 BOOL loopback_dtr_dsr = LOOPBACK_DTR_DSR;
1662 BOOL loopback_dtr_ring = LOOPBACK_DTR_RING;
1663 BOOL loopback_dtr_dcd = LOOPBACK_DTR_DCD;
1665 test_BuildCommDCB();
1666 hcom = test_OpenComm(FALSE);
1667 if (hcom != INVALID_HANDLE_VALUE)
1669 test_GetModemStatus(hcom);
1670 test_ReadTimeOut(hcom);
1671 test_waittxempty(hcom);
1674 hcom = test_OpenComm(FALSE);
1675 if (hcom != INVALID_HANDLE_VALUE)
1677 Sleep(200); /* Give the laster character of test_waittxempty to drop into the receiver */
1678 test_ClearCommErrors(hcom);
1681 hcom = test_OpenComm(FALSE);
1682 if (hcom != INVALID_HANDLE_VALUE)
1684 test_non_pending_errors(hcom);
1687 if((loopback_txd_rxd) && ((hcom = test_OpenComm(FALSE))!=INVALID_HANDLE_VALUE))
1689 test_LoopbackRead(hcom);
1692 if((loopback_rts_cts) && ((hcom = test_OpenComm(FALSE))!=INVALID_HANDLE_VALUE))
1694 test_LoopbackCtsRts(hcom);
1697 if((loopback_dtr_dsr) && ((hcom = test_OpenComm(FALSE))!=INVALID_HANDLE_VALUE))
1699 test_LoopbackDtrDsr(hcom);
1702 if((loopback_dtr_ring) && ((hcom = test_OpenComm(FALSE))!=INVALID_HANDLE_VALUE))
1704 test_LoopbackDtrRing(hcom);
1707 if((loopback_dtr_dcd) && ((hcom = test_OpenComm(FALSE))!=INVALID_HANDLE_VALUE))
1709 test_LoopbackDtrDcd(hcom);
1712 if((loopback_txd_rxd) && ((hcom = test_OpenComm(TRUE))!=INVALID_HANDLE_VALUE))
1717 if((loopback_rts_cts) && ((hcom = test_OpenComm(TRUE))!=INVALID_HANDLE_VALUE))
1722 if((hcom = test_OpenComm(TRUE))!=INVALID_HANDLE_VALUE)
1724 test_AbortWaitCts(hcom);
1727 if((loopback_dtr_dsr) && ((hcom = test_OpenComm(TRUE))!=INVALID_HANDLE_VALUE))
1732 if((loopback_dtr_ring) && ((hcom = test_OpenComm(TRUE))!=INVALID_HANDLE_VALUE))
1734 test_WaitRing(hcom);
1737 if((loopback_dtr_dcd) && ((hcom = test_OpenComm(TRUE))!=INVALID_HANDLE_VALUE))
1742 if(loopback_txd_rxd && (hcom = test_OpenComm(TRUE))!=INVALID_HANDLE_VALUE)
1744 test_WaitBreak(hcom);