Fix various no-*s.

Reviewed-by: Rich Salz <rsalz@openssl.org>
diff --git a/test/handshake_helper.c b/test/handshake_helper.c
index eecc6f7..c7023fe 100644
--- a/test/handshake_helper.c
+++ b/test/handshake_helper.c
@@ -164,6 +164,7 @@
     return 0;
 }
 
+#ifndef OPENSSL_NO_NEXTPROTONEG
 /* Parse the comma-separated list into TLS format. */
 static void parse_protos(const char *protos, unsigned char **out, size_t *outlen)
 {
@@ -260,7 +261,7 @@
     return ret == OPENSSL_NPN_NEGOTIATED ? SSL_TLSEXT_ERR_OK
         : SSL_TLSEXT_ERR_NOACK;
 }
-
+#endif
 
 /*
  * Configure callbacks and other properties that can't be set directly
@@ -315,6 +316,7 @@
     if (test_ctx->session_ticket_expected == SSL_TEST_SESSION_TICKET_BROKEN) {
         SSL_CTX_set_tlsext_ticket_key_cb(server_ctx, broken_session_ticket_cb);
     }
+#ifndef OPENSSL_NO_NEXTPROTONEG
     if (test_ctx->server_npn_protocols != NULL) {
         parse_protos(test_ctx->server_npn_protocols,
                      &server_ctx_data->npn_protocols,
@@ -360,6 +362,7 @@
                                                alpn_protos_len) == 0);
         OPENSSL_free(alpn_protos);
     }
+#endif
     /*
      * Use fixed session ticket keys so that we can decrypt a ticket created with
      * one CTX in another CTX. Don't address server2 for the moment.
@@ -496,6 +499,7 @@
     return INTERNAL_ERROR;
 }
 
+#ifndef OPENSSL_NO_NEXTPROTONEG
 /* Convert unsigned char buf's that shouldn't contain any NUL-bytes to char. */
 static char *dup_str(const unsigned char *in, size_t len)
 {
@@ -510,6 +514,7 @@
     OPENSSL_assert(ret != NULL);
     return ret;
 }
+#endif
 
 static HANDSHAKE_RESULT *do_handshake_internal(
     SSL_CTX *server_ctx, SSL_CTX *server2_ctx, SSL_CTX *client_ctx,
@@ -527,9 +532,11 @@
     unsigned char* tick = NULL;
     size_t tick_len = 0;
     SSL_SESSION* sess = NULL;
+#ifndef OPENSSL_NO_NEXTPROTONEG
     const unsigned char *proto = NULL;
     /* API dictates unsigned int rather than size_t. */
     unsigned int proto_len = 0;
+#endif
 
     memset(&server_ctx_data, 0, sizeof(server_ctx_data));
     memset(&server2_ctx_data, 0, sizeof(server2_ctx_data));
@@ -644,6 +651,7 @@
         ret->session_ticket = SSL_TEST_SESSION_TICKET_YES;
     ret->session_ticket_do_not_call = server_ex_data.session_ticket_do_not_call;
 
+#ifndef OPENSSL_NO_NEXTPROTONEG
     SSL_get0_next_proto_negotiated(client, &proto, &proto_len);
     ret->client_npn_negotiated = dup_str(proto, proto_len);
 
@@ -655,6 +663,7 @@
 
     SSL_get0_alpn_selected(server, &proto, &proto_len);
     ret->server_alpn_negotiated = dup_str(proto, proto_len);
+#endif
 
     ret->client_resumed = SSL_session_reused(client);
     ret->server_resumed = SSL_session_reused(server);
diff --git a/test/ssl_test.c b/test/ssl_test.c
index b28d308..48846ae 100644
--- a/test/ssl_test.c
+++ b/test/ssl_test.c
@@ -150,6 +150,7 @@
     return 1;
 }
 
+#ifndef OPENSSL_NO_NEXTPROTONEG
 static int check_npn(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
 {
     int ret = 1;
@@ -173,6 +174,7 @@
                          result->client_alpn_negotiated);
     return ret;
 }
+#endif
 
 static int check_resumption(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
 {
@@ -204,8 +206,10 @@
         ret &= check_servername(result, test_ctx);
         ret &= check_session_ticket(result, test_ctx);
         ret &= (result->session_ticket_do_not_call == 0);
+#ifndef OPENSSL_NO_NEXTPROTONEG
         ret &= check_npn(result, test_ctx);
         ret &= check_alpn(result, test_ctx);
+#endif
         ret &= check_resumption(result, test_ctx);
     }
     return ret;
diff --git a/test/ssl_test_ctx.c b/test/ssl_test_ctx.c
index 084cf15..24b11e5 100644
--- a/test/ssl_test_ctx.c
+++ b/test/ssl_test_ctx.c
@@ -295,6 +295,7 @@
 /* NPN and ALPN options             */
 /************************************/
 
+#ifndef OPENSSL_NO_NEXTPROTONEG
 IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(client_npn_protocols)
 IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server_npn_protocols)
 IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server2_npn_protocols)
@@ -303,6 +304,7 @@
 IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server_alpn_protocols)
 IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server2_alpn_protocols)
 IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(expected_alpn_protocol)
+#endif
 
 /***********************/
 /* Handshake mode      */
@@ -372,6 +374,7 @@
     { "ServerNameCallback", &parse_servername_callback },
     { "SessionTicketExpected", &parse_session_ticket },
     { "Method", &parse_test_method },
+#ifndef OPENSSL_NO_NEXTPROTONEG
     { "ClientNPNProtocols", &parse_client_npn_protocols },
     { "ServerNPNProtocols", &parse_server_npn_protocols },
     { "Server2NPNProtocols", &parse_server2_npn_protocols },
@@ -380,6 +383,7 @@
     { "ServerALPNProtocols", &parse_server_alpn_protocols },
     { "Server2ALPNProtocols", &parse_server2_alpn_protocols },
     { "ExpectedALPNProtocol", &parse_expected_alpn_protocol },
+#endif
     { "HandshakeMode", &parse_handshake_mode },
     { "ResumptionExpected", &parse_resumption_expected },
 };
@@ -399,6 +403,7 @@
 void SSL_TEST_CTX_free(SSL_TEST_CTX *ctx)
 {
 
+#ifndef OPENSSL_NO_NEXTPROTONEG
     OPENSSL_free(ctx->client_npn_protocols);
     OPENSSL_free(ctx->server_npn_protocols);
     OPENSSL_free(ctx->server2_npn_protocols);
@@ -407,6 +412,7 @@
     OPENSSL_free(ctx->server2_alpn_protocols);
     OPENSSL_free(ctx->expected_npn_protocol);
     OPENSSL_free(ctx->expected_alpn_protocol);
+#endif
     OPENSSL_free(ctx);
 }
 
diff --git a/test/ssl_test_ctx.h b/test/ssl_test_ctx.h
index d3d86e7..83850e4 100644
--- a/test/ssl_test_ctx.h
+++ b/test/ssl_test_ctx.h
@@ -92,6 +92,7 @@
     ssl_session_ticket_t session_ticket_expected;
     /* Whether the server/client CTX should use DTLS or TLS. */
     ssl_test_method_t method;
+#ifndef OPENSSL_NO_NEXTPROTONEG
     /*
      * NPN and ALPN protocols supported by the client, server, and second
      * (SNI) server. A comma-separated list.
@@ -104,6 +105,7 @@
     char *server_alpn_protocols;
     char *server2_alpn_protocols;
     char *expected_alpn_protocol;
+#endif
     /* Whether to test a resumed/renegotiated handshake. */
     ssl_handshake_mode_t handshake_mode;
     /* Whether the second handshake is resumed or a full handshake (boolean). */
diff --git a/test/ssl_test_ctx_test.c b/test/ssl_test_ctx_test.c
index 6366e0a..52691f0 100644
--- a/test/ssl_test_ctx_test.c
+++ b/test/ssl_test_ctx_test.c
@@ -89,6 +89,7 @@
                 ssl_session_ticket_name(ctx2->session_ticket_expected));
         return 0;
     }
+#ifndef OPENSSL_NO_NEXTPROTONEG
     if (!strings_equal("ClientNPNProtocols", ctx->client_npn_protocols,
                        ctx2->client_npn_protocols))
         return 0;
@@ -120,6 +121,7 @@
     if (!strings_equal("ExpectedALPNProtocol", ctx->expected_alpn_protocol,
                        ctx2->expected_alpn_protocol))
         return 0;
+#endif
     if (ctx->handshake_mode != ctx2->handshake_mode) {
         fprintf(stderr, "HandshakeMode mismatch: %s vs %s.\n",
                 ssl_handshake_mode_name(ctx->handshake_mode),
@@ -214,10 +216,12 @@
         SSL_TEST_SERVERNAME_IGNORE_MISMATCH;
     fixture.expected_ctx->session_ticket_expected = SSL_TEST_SESSION_TICKET_YES;
     fixture.expected_ctx->method = SSL_TEST_METHOD_DTLS;
+#ifndef OPENSSL_NO_NEXTPROTONEG
     fixture.expected_ctx->client_npn_protocols = OPENSSL_strdup("foo,bar");
     fixture.expected_ctx->server2_alpn_protocols = OPENSSL_strdup("baz");
     OPENSSL_assert(fixture.expected_ctx->client_npn_protocols != NULL);
     OPENSSL_assert(fixture.expected_ctx->server2_alpn_protocols != NULL);
+#endif
     fixture.expected_ctx->handshake_mode = SSL_TEST_HANDSHAKE_RESUME;
     fixture.expected_ctx->resumption_expected = 1;
     EXECUTE_SSL_TEST_CTX_TEST();