Commit d3fa12a7 authored by Reilly Grant's avatar Reilly Grant Committed by Chromium LUCI CQ

serial: Split up manual tests

The manual data transfer tests are known to work on all platforms while
the tests which generate error conditions do not. Break these up in
order to simplify regression testing.

Bug: 884928
Change-Id: I8b8e5559fe7babf21395b3c836ff8ff0f60be8b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2576080
Commit-Queue: James Hollyer <jameshollyer@chromium.org>
Reviewed-by: default avatarJames Hollyer <jameshollyer@chromium.org>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834357}
parent c113d3a1
...@@ -2186,6 +2186,8 @@ external/wpt/native-file-system/showSaveFilePicker-manual.https.html [ Skip ] ...@@ -2186,6 +2186,8 @@ external/wpt/native-file-system/showSaveFilePicker-manual.https.html [ Skip ]
external/wpt/webusb/usbDevice_claimInterface-manual.https.html [ Skip ] external/wpt/webusb/usbDevice_claimInterface-manual.https.html [ Skip ]
wpt_internal/hid/hidDevice_collections-manual.https.html [ Skip ] wpt_internal/hid/hidDevice_collections-manual.https.html [ Skip ]
external/wpt/serial/serialPort_loopback-manual.https.html [ Skip ] external/wpt/serial/serialPort_loopback-manual.https.html [ Skip ]
external/wpt/serial/serialPort_loopback_BreakError-manual.https.html [ Skip ]
external/wpt/serial/serialPort_loopback_BufferOverrunError-manual.https.html [ Skip ]
external/wpt/serial/serialPort_disconnect-manual.https.html [ Skip ] external/wpt/serial/serialPort_disconnect-manual.https.html [ Skip ]
# CPU test is enough for this one as there are gradient issues on the GPU # CPU test is enough for this one as there are gradient issues on the GPU
......
...@@ -92,90 +92,6 @@ ...@@ -92,90 +92,6 @@
await port.close(); await port.close();
}, 'Canceling the reader discards buffered data.'); }, 'Canceling the reader discards buffered data.');
manual_loopback_serial_test(async (t, port) => {
await port.open({baudRate: 115200, bufferSize: 1024});
// Create something much larger than bufferSize above.
const data = new Uint8Array(16 * 1024);
for (let i = 0; i < data.byteLength; ++i)
data[i] = (i / 1024) & 0xff;
// Completely write |data| to the port without waiting for it to be
// received.
const writer = port.writable.getWriter();
writer.write(data);
await writer.close();
const reader = port.readable.getReader();
const chunks = [];
let actualLength = 0;
while (true) {
try {
const {value, done} = await reader.read();
if (value) {
actualLength += value.byteLength;
chunks.push(value);
}
if (done) {
assert_unreached("Unexpected end of stream.");
break;
}
} catch (e) {
assert_equals(e.name, 'BufferOverrunError');
break;
}
}
reader.releaseLock();
const buffer = new Uint8Array(actualLength);
chunks.reduce((offset, chunk) => {
buffer.set(chunk, offset);
return offset + chunk.byteLength;
}, 0);
assert_greater_than(actualLength, 0);
compareArrays(buffer, data.slice(0, actualLength));
await port.close();
}, 'Overflowing the receive buffer triggers an error.');
manual_loopback_serial_test(async (t, port) => {
await port.open({baudRate: 115200, bufferSize: 1024});
let reader = port.readable.getReader();
let readPromise = (async () => {
// A single zero byte will be read before the break is detected.
const {value, done} = await reader.read();
compareArrays(value, new Uint8Array([0]));
assert_false(done);
try {
const {value, done} = await reader.read();
assert_unreached(`Expected break, got ${value.byteLength} bytes`);
} catch (e) {
assert_equals(e.constructor, DOMException);
assert_equals(e.name, 'BreakError');
}
})();
await port.setSignals({break: true});
await readPromise;
await port.setSignals({break: false});
const writer = port.writable.getWriter();
// |data| is small enough to be completely transmitted.
let data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
await writer.write(data);
writer.releaseLock();
reader = port.readable.getReader();
const buffer = await readWithLength(reader, data.byteLength);;
compareArrays(buffer, data);
reader.releaseLock();
await port.close();
}, 'Break is detected.');
</script> </script>
</body> </body>
</html> </html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/common.js"></script>
<script src="resources/manual.js"></script>
</head>
<body>
<p>
These tests require a connected serial device configured to act as a
"loopback" device, with the transmit and receive pins wired together.
</p>
<script>
manual_loopback_serial_test(async (t, port) => {
await port.open({baudRate: 115200, bufferSize: 1024});
let reader = port.readable.getReader();
let readPromise = (async () => {
// A single zero byte will be read before the break is detected.
const {value, done} = await reader.read();
compareArrays(value, new Uint8Array([0]));
assert_false(done);
try {
const {value, done} = await reader.read();
assert_unreached(`Expected break, got ${value.byteLength} bytes`);
} catch (e) {
assert_equals(e.constructor, DOMException);
assert_equals(e.name, 'BreakError');
}
})();
await port.setSignals({break: true});
await readPromise;
await port.setSignals({break: false});
const writer = port.writable.getWriter();
// |data| is small enough to be completely transmitted.
let data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
await writer.write(data);
writer.releaseLock();
reader = port.readable.getReader();
const buffer = await readWithLength(reader, data.byteLength);;
compareArrays(buffer, data);
reader.releaseLock();
await port.close();
}, 'Break is detected.');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/common.js"></script>
<script src="resources/manual.js"></script>
</head>
<body>
<p>
These tests require a connected serial device configured to act as a
"loopback" device, with the transmit and receive pins wired together.
</p>
<script>
manual_loopback_serial_test(async (t, port) => {
await port.open({baudRate: 115200, bufferSize: 1024});
// Create something much larger than bufferSize above.
const data = new Uint8Array(16 * 1024);
for (let i = 0; i < data.byteLength; ++i)
data[i] = (i / 1024) & 0xff;
// Completely write |data| to the port without waiting for it to be
// received.
const writer = port.writable.getWriter();
writer.write(data);
await writer.close();
const reader = port.readable.getReader();
const chunks = [];
let actualLength = 0;
while (true) {
try {
const {value, done} = await reader.read();
if (value) {
actualLength += value.byteLength;
chunks.push(value);
}
if (done) {
assert_unreached("Unexpected end of stream.");
break;
}
} catch (e) {
assert_equals(e.name, 'BufferOverrunError');
break;
}
}
reader.releaseLock();
const buffer = new Uint8Array(actualLength);
chunks.reduce((offset, chunk) => {
buffer.set(chunk, offset);
return offset + chunk.byteLength;
}, 0);
assert_greater_than(actualLength, 0);
compareArrays(buffer, data.slice(0, actualLength));
await port.close();
}, 'Overflowing the receive buffer triggers an error.');
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment