()
| 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 | } |
nothing calls this directly
no test coverage detected