diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-12-29 21:38:22 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-12-29 21:38:22 -0500 |
commit | f1779c4549c88e7996031b7211a556e8e4b54963 (patch) | |
tree | 414aebffb9bd5494abe2374f7c5d436e7b2150b9 /tests | |
parent | c9b4ff92040d02b3dd3d050c41e148b2fa8e6b60 (diff) | |
download | pty-process-f1779c4549c88e7996031b7211a556e8e4b54963.tar.gz pty-process-f1779c4549c88e7996031b7211a556e8e4b54963.zip |
i don't think we need to open pts multiple times?
Diffstat (limited to 'tests')
-rw-r--r-- | tests/multiple.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/multiple.rs b/tests/multiple.rs new file mode 100644 index 0000000..8d96050 --- /dev/null +++ b/tests/multiple.rs @@ -0,0 +1,27 @@ +#[test] +fn test_multiple() { + use std::io::Read as _; + + let mut pty = pty_process::blocking::Pty::new().unwrap(); + pty.resize(pty_process::Size::new(24, 80)).unwrap(); + + let mut child = pty_process::blocking::Command::new("echo") + .arg("foo") + .spawn(&pty) + .unwrap(); + let mut buf = [0u8; 1024]; + let bytes = pty.read(&mut buf).unwrap(); + assert_eq!(&buf[..bytes], b"foo\r\n"); + let status = child.wait().unwrap(); + assert_eq!(status.code().unwrap(), 0); + + let mut child = pty_process::blocking::Command::new("echo") + .arg("bar") + .spawn(&pty) + .unwrap(); + let mut buf = [0u8; 1024]; + let bytes = pty.read(&mut buf).unwrap(); + assert_eq!(&buf[..bytes], b"bar\r\n"); + let status = child.wait().unwrap(); + assert_eq!(status.code().unwrap(), 0); +} |