summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-09-13 14:10:11 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-13 21:37:38 +0000
commit699dff5876298a0c9748707feaf23fe6622c83f1 (patch)
tree4b6fdac14d582b9761ca0427c145fcc26482fdb3
parent2e41189d10ac430454f6b63ea483d85cee2c5b36 (diff)
downloadchrome-ec-699dff5876298a0c9748707feaf23fe6622c83f1.tar.gz
zephyr: zmake: Bound size of relative paths for resolve_build_dir tests
In Linux, both filenames and paths are not unbounded in size. The typical constants NAME_MAX and PATH_MAX specify the maximum size (in bytes) of a file name and a file path, respectively. In Linux, these constants are 256 and 4096. The regex which was previously used here assumed file names could be infinitely long. Bound it. Additionally, we need to limit to ASCII word characters, as Unicode characters may sometimes be more than one byte. BUG=b:199769823 BRANCH=none TEST=run unit tests Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I404302ea10ec27acc9c8e6988bb6dd6050deb09a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3158895 Reviewed-by: Raul E Rangel <rrangel@chromium.org>
-rw-r--r--zephyr/zmake/tests/test_util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/zephyr/zmake/tests/test_util.py b/zephyr/zmake/tests/test_util.py
index 0524a153fd..0c4cd4dda5 100644
--- a/zephyr/zmake/tests/test_util.py
+++ b/zephyr/zmake/tests/test_util.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import pathlib
+import re
import tempfile
import hypothesis
@@ -12,7 +13,9 @@ import pytest
import zmake.util as util
# Strategies for use with hypothesis
-relative_path = st.from_regex(regex=r"\A\w+[\w/]*\Z")
+relative_path = st.from_regex(
+ regex=re.compile(r"\A\w{1,255}(/\w{1,255}){0,15}\Z", re.ASCII)
+)
@hypothesis.given(relative_path, relative_path, relative_path)