]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Port script_5
authorAndrew Dinh <andrewd@openssl.org>
Wed, 24 Jun 2026 15:59:43 +0000 (22:59 +0700)
committerNorbert Pocs <norbertp@openssl.org>
Tue, 30 Jun 2026 07:54:33 +0000 (09:54 +0200)
Also fixes a bug in the OP_STREAM_RESET macro

Assisted-by: Claude:claude-sonnet-4-6
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 07:54:46 2026
(Merged from https://github.com/openssl/openssl/pull/31707)

test/quic_multistream_test.c
test/radix/quic_ops.c
test/radix/quic_tests.c

index 4edd53e15fb9c2e5931202181d94ea274baf7987..38289e6892e7187a3aff6c732d416f2195f4611e 100644 (file)
@@ -373,18 +373,6 @@ static void s_unlock(struct helper *h, struct helper_local *hl);
 #define ACQUIRE_S() s_lock(h, hl)
 #define ACQUIRE_S_NOHL() s_lock(h, NULL)
 
-static int check_stream_reset(struct helper *h, struct helper_local *hl)
-{
-    uint64_t stream_id = hl->check_op->arg2, aec = 0;
-
-    if (!ossl_quic_tserver_stream_has_peer_reset_stream(ACQUIRE_S(), stream_id, &aec)) {
-        h->check_spin_again = 1;
-        return 0;
-    }
-
-    return TEST_uint64_t_eq(aec, 42);
-}
-
 static int check_stream_stopped(struct helper *h, struct helper_local *hl)
 {
     uint64_t stream_id = hl->check_op->arg2;
@@ -2063,25 +2051,7 @@ static const struct script_op script_4[] = {
 
 /* 5. Test stream reset functionality */
 static const struct script_op script_5[] = {
-    OP_C_SET_ALPN("ossltest"),
-    OP_C_CONNECT_WAIT(),
-
-    OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE),
-    OP_C_NEW_STREAM_BIDI(a, C_BIDI_ID(0)),
-    OP_C_NEW_STREAM_BIDI(b, C_BIDI_ID(1)),
-
-    OP_C_WRITE(a, "apple", 5),
-    OP_C_STREAM_RESET(a, 42),
-
-    OP_C_WRITE(b, "strawberry", 10),
-
-    OP_S_BIND_STREAM_ID(a, C_BIDI_ID(0)),
-    OP_S_BIND_STREAM_ID(b, C_BIDI_ID(1)),
-    OP_S_READ_EXPECT(b, "strawberry", 10),
-    /* Reset disrupts read of already sent data */
-    OP_S_READ_FAIL(a, 0),
-    OP_CHECK(check_stream_reset, C_BIDI_ID(0)),
-
+    /* test moved to test/radix/quic_tests.c */
     OP_END
 };
 
index 11cf93be305c7157cc08c6c9b59178f267168330..27e5a3705d0149283da068a95e1930411395a12a 100644 (file)
@@ -1099,7 +1099,7 @@ err:
 
 #define OP_STREAM_RESET(name, error_code) \
     (OP_SELECT_SSL(0, name),              \
-        OP_PUSH_U64(flags),               \
+        OP_PUSH_PZ(#name),                \
         OP_PUSH_U64(error_code),          \
         OP_FUNC(hf_stream_reset))
 
index d1d8c549496bb544e60902efea32ce8275031836..2f778e7a2693518d906e1c93bbced02a42a62641 100644 (file)
@@ -765,6 +765,30 @@ DEF_SCRIPT(check_ctx_cbks, "Check new_pending and client_hello callbacks")
     OP_FUNC(check_pending);
 }
 
+DEF_FUNC(check_stream_reset_5)
+{
+    int ok = 0;
+    SSL *ssl;
+    uint64_t aec = 0;
+    int state;
+
+    REQUIRE_SSL(ssl);
+
+    state = SSL_get_stream_read_state(ssl);
+    if (state != SSL_STREAM_STATE_RESET_REMOTE)
+        F_SPIN_AGAIN();
+
+    if (!TEST_true(SSL_get_stream_read_error_code(ssl, &aec)))
+        goto err;
+
+    if (!TEST_uint64_t_eq(aec, 42))
+        goto err;
+
+    ok = 1;
+err:
+    return ok;
+}
+
 /*
  * script_5 - script_106 are place holders for tests we
  * currently keep in test/quic_multistream_test.c.
@@ -778,8 +802,29 @@ DEF_SCRIPT(check_ctx_cbks, "Check new_pending and client_hello callbacks")
  * The scaffolding here hopes to avoid conflicts in 'scripts'
  * array below when more PRs will be in flight.
  */
-DEF_SCRIPT(script_5, "place holder for multistram script_5")
+
+/* 5. Test stream reset functionality */
+DEF_SCRIPT(script_5, "Test stream reset functionality")
 {
+    OP_SIMPLE_PAIR_CONN_ND();
+
+    OP_NEW_STREAM(C, Ca, 0 /* bidirectional */);
+    OP_NEW_STREAM(C, Cb, 0 /* bidirectional */);
+
+    OP_WRITE(Ca, "apple", 5);
+    OP_STREAM_RESET(Ca, 42);
+
+    OP_WRITE(Cb, "strawberry", 10);
+
+    OP_ACCEPT_CONN_WAIT_ND(L, S, 0);
+    OP_ACCEPT_STREAM_WAIT(S, Sa, 0); /* first stream = Ca */
+    OP_ACCEPT_STREAM_WAIT(S, Sb, 0); /* second stream = Cb */
+
+    /* Reset disrupts read of already-sent data */
+    OP_SELECT_SSL(0, Sa);
+    OP_FUNC(check_stream_reset_5);
+
+    OP_READ_EXPECT(Sb, "strawberry", 10);
 }
 
 DEF_SCRIPT(script_6, "place holder for multistram script_6")