diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2019-10-09 00:10:09 +0300 |
---|---|---|
committer | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2019-10-09 00:10:09 +0300 |
commit | 9431d6afd2cc11f6f6920448e4715d89220ac331 (patch) | |
tree | 17c2512501794b2de07773bfff2728da08563807 /tests | |
parent | 5d5613b75dd628e95cd1b65961a3d094c80540c6 (diff) | |
download | gnutls-9431d6afd2cc11f6f6920448e4715d89220ac331.tar.gz |
tests/psk-file: fix heizenbug in last test
Currently last test case in psk-file expects that the server will
terminate connection with fatal error and close connection. Client will
receive GNUTLS_E_PUSH_ERROR error. However on slow boxes (or under qemu)
client is able to receive server's fatal alert thus returning unexpected
error. To make this behaviour predictable make server wait for client to
read all data and actually close connection on it's own.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/psk-file.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/psk-file.c b/tests/psk-file.c index 0a6eef4b87..22e744f1a7 100644 --- a/tests/psk-file.c +++ b/tests/psk-file.c @@ -215,7 +215,16 @@ static void server(int sd, const char *prio, const char *user, bool no_cred, gnutls_transport_set_int(session, sd); ret = gnutls_handshake(session); if (ret < 0) { + unsigned char seq[8], buf[16]; gnutls_alert_send_appropriate(session, ret); + + /* We have to make sure that we do not close connection till + * test client reads our fatal alert, otherwise it migh exit + * with GNUTLS_E_PUSH_ERROR instead */ + gnutls_session_force_valid(session); + while ((gnutls_record_recv_seq(session, buf, sizeof(buf), seq)) >= 0) + ; + if (expect_fail) { if (ret != expect_fail) { fail("expected error %d (%s), got %d (%s)\n", expect_fail, @@ -410,7 +419,7 @@ void doit(void) run_test2("NORMAL:-VERS-ALL:+VERS-TLS1.3:+DHE-PSK:-GROUP-ALL:+GROUP-FFDHE2048:+GROUP-FFDHE4096", "NORMAL:-VERS-ALL:+VERS-TLS1.3:+DHE-PSK:-GROUP-ALL:+GROUP-FFDHE4096", "jas", &key, 0, GNUTLS_KX_DHE_PSK, 0, 0); /* try without server credentials */ - run_test3("NORMAL:-VERS-ALL:+VERS-TLS1.3:+PSK:+DHE-PSK", NULL, "jas", &key, 1, 0, 0, GNUTLS_E_PUSH_ERROR, GNUTLS_E_INSUFFICIENT_CREDENTIALS); + run_test3("NORMAL:-VERS-ALL:+VERS-TLS1.3:+PSK:+DHE-PSK", NULL, "jas", &key, 1, 0, 0, GNUTLS_E_FATAL_ALERT_RECEIVED, GNUTLS_E_INSUFFICIENT_CREDENTIALS); } #endif /* _WIN32 */ |