MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / pl011_input

Function pl011_input

devices/src/legacy/uart_pl011.rs:539–564  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

537
538 #[test]
539 fn pl011_input() {
540 let intr_evt = EventFd::new(0).unwrap();
541 let pl011_out = SharedBuffer::new();
542 let mut pl011 = Pl011::new(
543 String::from(SERIAL_NAME),
544 Arc::new(TestInterrupt::new(intr_evt.try_clone().unwrap())),
545 Some(Box::new(pl011_out)),
546 Instant::now(),
547 None,
548 );
549
550 // write 1 to the interrupt event fd, so that read doesn't block in case the event fd
551 // counter doesn't change (for 0 it blocks)
552 intr_evt.write(1).unwrap();
553 pl011.queue_input_bytes(b"abc").unwrap();
554
555 assert_eq!(intr_evt.read().unwrap(), 2);
556
557 let mut data = [0u8];
558 pl011.read(0, UARTDR, &mut data);
559 assert_eq!(data[0], b'a');
560 pl011.read(0, UARTDR, &mut data);
561 assert_eq!(data[0], b'b');
562 pl011.read(0, UARTDR, &mut data);
563 assert_eq!(data[0], b'c');
564 }
565}

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
try_cloneMethod · 0.45
writeMethod · 0.45
queue_input_bytesMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected