summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2016-01-09 21:20:00 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-01-10 08:19:32 +0100
commit5a9555214732375e5de78fb3bac78f6d90ec07ad (patch)
tree4f444800a260c70bf548590b6dd5adccd5c3ba6f
parent986ec42009ebaf2bccb376ed7741b98b0111716f (diff)
downloadgnutls-5a9555214732375e5de78fb3bac78f6d90ec07ad.tar.gz
tests: verify that the selected ALPN protocol is the first advertised
-rw-r--r--tests/mini-alpn.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/mini-alpn.c b/tests/mini-alpn.c
index 355141a771..049bf2e624 100644
--- a/tests/mini-alpn.c
+++ b/tests/mini-alpn.c
@@ -171,6 +171,7 @@ static void server(int fd, const char *protocol1, const char *protocol2)
gnutls_session_t session;
gnutls_anon_server_credentials_t anoncred;
gnutls_datum_t t[2];
+ gnutls_datum_t selected;
/* this must be called once in the program
*/
@@ -226,17 +227,22 @@ static void server(int fd, const char *protocol1, const char *protocol2)
gnutls_protocol_get_name
(gnutls_protocol_get_version(session)));
- ret = gnutls_alpn_get_selected_protocol(session, &t[0]);
+ ret = gnutls_alpn_get_selected_protocol(session, &selected);
if (ret < 0) {
gnutls_perror(ret);
exit(1);
}
#if 0
if (debug) {
- success("Protocol: %.*s\n", (int) t[0].size, t[0].data);
+ success("Protocol: %.*s\n", (int) selected.size, selected.data);
}
#endif
+ if (selected.size != strlen(protocol1) || memcmp(selected.data, protocol1, selected.size) != 0) {
+ fail("did not select the expected protocol (selected %.*s, expected %s)\n", selected.size, selected.data, protocol1);
+ exit(1);
+ }
+
/* do not wait for the peer to close the connection.
*/
gnutls_bye(session, GNUTLS_SHUT_WR);