Commit 6489f712165 for php
commit 6489f712165dafad9010530ffa0df65e88adbe6d
Author: Weilin Du <weilindu@php.net>
Date: Sun Nov 29 21:49:57 2026 +0800
ext/mbstring: Reduce redundant UTF-8 boundary test cases (#25899)
The exhaustive short-length sweep times out on the PPC64 ASan runner.
Sample short lengths near SIMD block boundaries while checking every
offset, and keep the long-string cases.
diff --git a/ext/mbstring/tests/mb_check_encoding_utf8_blocks.phpt b/ext/mbstring/tests/mb_check_encoding_utf8_blocks.phpt
index d4bfe27edab..4e55a2c3be8 100644
--- a/ext/mbstring/tests/mb_check_encoding_utf8_blocks.phpt
+++ b/ext/mbstring/tests/mb_check_encoding_utf8_blocks.phpt
@@ -4,8 +4,8 @@
mbstring
--FILE--
<?php
-// Valid and invalid sequences, placed at every offset of strings with various
-// lengths, so that they straddle the boundaries of 16, 32 and 64-byte blocks.
+// Place valid and invalid sequences at every offset of lengths selected around
+// SIMD block boundaries.
$sequences = [
"\xC3\xA9", "\xE4\xB8\xAD", "\xF0\x9F\x98\x80", "\xF4\x8F\xBF\xBF", "\xED\x9F\xBF", "\xEE\x80\x80",
"\x80", "\xBF", "\xC0\x80", "\xC1\xBF", "\xC2", "\xE0\x80\x80", "\xE0\xA0", "\xED\xA0\x80",
@@ -13,10 +13,11 @@
"\xC3\xA9\xA9", "\xE4\xB8", "\xF0\x9F",
];
$fillers = ["a", "\xC3\xA9", "\xE4\xB8\xAD", "\xF0\x9F\x98\x80"];
+$short_lengths = [0, 1, 2, 3, 4, 14, 15, 16, 17, 30, 31, 32, 33, 62, 63, 64, 65, 126, 127, 128, 129, 140];
$checked = 0;
$mismatches = 0;
foreach ($fillers as $filler) {
- for ($len = 0; $len <= 140; $len++) {
+ foreach ($short_lengths as $len) {
$base = str_repeat($filler, intdiv($len, strlen($filler)) + 1);
// Cut at a character boundary
$base = mb_strcut($base, 0, $len, 'UTF-8');