Fix travis test setup for DTLS

This commit is contained in:
Manuel Schölling 2015-03-11 14:08:48 +01:00
parent a47241c88f
commit 8a0e9d6cca
4 changed files with 39 additions and 24 deletions

View File

@ -5,10 +5,9 @@ os:
env: env:
global: global:
- secure: J4i75AV4KMrU/UQrLIzzIh35Xix40Ki0uWjm8j05oxlXVl5aPU2zB30AemDne2QXYzkN4kRG/iRnNORE/8D0lF7YipQNSNxgfiBVoOEfj/NSogvI2BftYX9vlLZJUvt+s/nbE3xa/Pyge1IPv7itDYGO7SMe8RTSqitgqyfE2Eg= - secure: J4i75AV4KMrU/UQrLIzzIh35Xix40Ki0uWjm8j05oxlXVl5aPU2zB30AemDne2QXYzkN4kRG/iRnNORE/8D0lF7YipQNSNxgfiBVoOEfj/NSogvI2BftYX9vlLZJUvt+s/nbE3xa/Pyge1IPv7itDYGO7SMe8RTSqitgqyfE2Eg=
- FEATURES="tlsv1_1 tlsv1_2 aes_xts npn" - FEATURES="tlsv1_1 tlsv1_2 dtlsv1 dtlsv1_2 aes_xts npn"
before_script: before_script:
- openssl s_server -accept 15418 -www -cert openssl/test/cert.pem -key openssl/test/key.pem >/dev/null 2>&1 & - ./openssl/tests/test.sh &
- openssl s_server -accept 15419 -www -cert openssl/test/cert.pem -key openssl/test/key.pem -nextprotoneg "http/1.1,spdy/3.1" >/dev/null 2>&1 &
script: script:
- (cd openssl && cargo test) - (cd openssl && cargo test)
- (test $TRAVIS_OS_NAME == "osx" || (cd openssl && cargo test --features "$FEATURES")) - (test $TRAVIS_OS_NAME == "osx" || (cd openssl && cargo test --features "$FEATURES"))

View File

@ -72,18 +72,6 @@ s_server` window. Those aren't anything to worry about. You can stop the server
using Control-C. using Control-C.
For DTLS testing each test requires its own instance of OpenSSL's s_server. On For DTLS testing each test requires its own instance of OpenSSL's s_server. On
Linux you can start them like this: Linux you can run the bash script in `openssl/tests/test.sh`.
for port in `seq 15410 15450`; do
echo hello | openssl s_server -accept $port -dtls1 -cert test/cert.pem \
-key test/key.pem -msg -debug & >/dev/null;
done
Note that the test ssl::tests::write::dtlsv1 should be started individually and
requires an interactive instance:
openssl s_server -accept 15411 -dtls1 -cert test/cert.pem -key test/key.pem
[1]: http://slproweb.com/products/Win32OpenSSL.html [1]: http://slproweb.com/products/Win32OpenSSL.html

View File

@ -58,8 +58,8 @@ macro_rules! run_test(
use std::net::UdpSocket; use std::net::UdpSocket;
use std::net::TcpStream; use std::net::TcpStream;
use ssl::SslMethod::Sslv23; use ssl::SslMethod::Sslv23;
#[cfg(feature="dtlsv1")]
use ssl; use ssl;
#[cfg(feature="dtlsv1")]
use ssl::SslMethod::Dtlsv1; use ssl::SslMethod::Dtlsv1;
use ssl::{SslContext, SslStream, VerifyCallback}; use ssl::{SslContext, SslStream, VerifyCallback};
use ssl::connected_socket::Connect; use ssl::connected_socket::Connect;
@ -288,13 +288,28 @@ run_test!(clear_ctx_options, |method, _| {
assert!(!opts.contains(ssl::SSL_OP_ALL)); assert!(!opts.contains(ssl::SSL_OP_ALL));
}); });
run_test!(write, |method, stream| { #[test]
let mut s = SslStream::new(&SslContext::new(method).unwrap(), stream).unwrap(); fn test_write() {
s.write_all("hello".as_bytes()).unwrap(); let stream = TcpStream::connect("127.0.0.1:15418").unwrap();
s.flush().unwrap(); let mut stream = SslStream::new(&SslContext::new(Sslv23).unwrap(), stream).unwrap();
s.write_all(" there".as_bytes()).unwrap(); stream.write_all("hello".as_bytes()).unwrap();
s.flush().unwrap(); stream.flush().unwrap();
}); stream.write_all(" there".as_bytes()).unwrap();
stream.flush().unwrap();
}
#[test]
#[cfg(feature = "dtlsv1")]
fn test_write_dtlsv1() {
let sock = UdpSocket::bind("127.0.0.1:0").unwrap();
let stream = sock.connect("127.0.0.1:15410").unwrap();
let mut stream = SslStream::new(&SslContext::new(Dtlsv1).unwrap(), stream).unwrap();
stream.write_all("hello".as_bytes()).unwrap();
stream.flush().unwrap();
stream.write_all(" there".as_bytes()).unwrap();
stream.flush().unwrap();
}
#[test] #[test]
fn test_read() { fn test_read() {

13
openssl/test/test.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
openssl s_server -accept 15418 -www -cert openssl/test/cert.pem -key openssl/test/key.pem >/dev/null 2>&1 &
for port in `seq 15411 15430`; do
echo hello | openssl s_server -accept $port -dtls1 -cert openssl/test/cert.pem \
-key openssl/test/key.pem 2>&1 >/dev/null &
done
# the server for the test ssl::tests::test_write_dtlsv1 must wait to receive
# data from the client
openssl s_server -accept 15410 -dtls1 -cert openssl/test/cert.pem \
-key openssl/test/key.pem 2>&1 >/dev/null