diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-11-08 09:07:58 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-11-08 09:07:58 +0100 |
commit | 26ffdb0ba4155bfc2469979a5c12034741684b5c (patch) | |
tree | 5084c3223d11be2f9564b434b576872c323a71fd /openpgp | |
parent | 54b6d890f369b77d10e2067d6d42c1e6a0b9d38e (diff) |
openpgp: Split long running test.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/parse/stream.rs | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs index 3f876b0e..88ab739a 100644 --- a/openpgp/src/parse/stream.rs +++ b/openpgp/src/parse/stream.rs @@ -1762,8 +1762,9 @@ mod test { assert!(v.message_processed()); } - #[test] - fn detached_verifier() { + // This test is relatively long running in debug mode. Split it + // up. + fn detached_verifier_read_size(l: usize) { use crate::conversions::Time; struct Test<'a> { @@ -1822,43 +1823,51 @@ mod test { let content = test.content; let reference = test.reference; - // Transformer::read_helper rounds up to 4 MB chunks try - // chunk sizes around that size. - for l in [ 4 * 1024 * 1024 - 1, - 4 * 1024 * 1024, - 4 * 1024 * 1024 + 1 - ].iter() { - let h = VHelper::new(0, 0, 0, 0, keys.clone()); - let mut v = DetachedVerifier::from_bytes( - sig, content, h, reference).unwrap(); - - let got = read_to_end(&mut v, l, &mut buffer); - assert!(v.message_processed()); - let got = &buffer[..got]; - assert_eq!(got.len(), content.len()); - assert_eq!(got, &content[..]); - - let h = v.into_helper(); - assert_eq!(h.good, 1); - assert_eq!(h.bad, 0); - - // Same, but with readers. - use std::io::Cursor; - let h = VHelper::new(0, 0, 0, 0, keys.clone()); - let mut v = DetachedVerifier::from_reader( - Cursor::new(sig), Cursor::new(content), - h, reference).unwrap(); - - let got = read_to_end(&mut v, l, &mut buffer); - let got = &buffer[..got]; - assert!(v.message_processed()); - assert_eq!(got.len(), content.len()); - assert_eq!(got, &content[..]); - } + let h = VHelper::new(0, 0, 0, 0, keys.clone()); + let mut v = DetachedVerifier::from_bytes( + sig, content, h, reference).unwrap(); + + let got = read_to_end(&mut v, l, &mut buffer); + assert!(v.message_processed()); + let got = &buffer[..got]; + assert_eq!(got.len(), content.len()); + assert_eq!(got, &content[..]); + + let h = v.into_helper(); + assert_eq!(h.good, 1); + assert_eq!(h.bad, 0); + + // Same, but with readers. + use std::io::Cursor; + let h = VHelper::new(0, 0, 0, 0, keys.clone()); + let mut v = DetachedVerifier::from_reader( + Cursor::new(sig), Cursor::new(content), + h, reference).unwrap(); + + let got = read_to_end(&mut v, l, &mut buffer); + let got = &buffer[..got]; + assert!(v.message_processed()); + assert_eq!(got.len(), content.len()); + assert_eq!(got, &content[..]); } } #[test] + fn detached_verifier1() { + // Transformer::read_helper rounds up to 4 MB chunks try + // chunk sizes around that size. + detached_verifier_read_size(4 * 1024 * 1024 - 1); + } + #[test] + fn detached_verifier2() { + detached_verifier_read_size(4 * 1024 * 1024); + } + #[test] + fn detached_verifier3() { + detached_verifier_read_size(4 * 1024 * 1024 + 1); + } + + #[test] fn verify_long_message() { use crate::tpk::{TPKBuilder, CipherSuite}; use crate::serialize::stream::{LiteralWriter, Signer, Message}; |