test: make Windows Unicode gate byte-exact
This commit is contained in:
parent
cb60cf0218
commit
6fd78e0515
2 changed files with 24 additions and 7 deletions
21
.github/workflows/cross-platform.yml
vendored
21
.github/workflows/cross-platform.yml
vendored
|
|
@ -86,20 +86,33 @@ jobs:
|
|||
trap 'chmod -R u+rwX "$test_root" 2>/dev/null || true; rm -rf -- "$test_root"' EXIT
|
||||
output_dir="$test_root/saída-安全"
|
||||
archive="$test_root/cópia-安全.zupt"
|
||||
emoji_name=$'emoji-\xF0\x9F\x98\x80.bin'
|
||||
mkdir -p "$test_root/input/subdir" "$output_dir"
|
||||
printf 'Windows release smoke test\n' > "$test_root/input/café.txt"
|
||||
printf 'UTF-8: café-安全\n' > "$test_root/input/subdir/ação-安全.txt"
|
||||
printf 'emoji filename\n' > "$test_root/input/subdir/emoji-😀.bin"
|
||||
printf 'emoji filename\n' > "$test_root/input/subdir/$emoji_name"
|
||||
: > "$test_root/input/empty"
|
||||
dd if=/dev/urandom of="$test_root/input/subdir/random.bin" bs=4096 count=4 2>/dev/null
|
||||
(cd "$test_root" && "$exe" compress "$archive" input)
|
||||
"$exe" test "$archive"
|
||||
"$exe" list "$archive" > "$test_root/list.txt" 2>&1
|
||||
grep -F 'café.txt' "$test_root/list.txt"
|
||||
grep -F 'ação-安全.txt' "$test_root/list.txt"
|
||||
grep -F 'emoji-😀.bin' "$test_root/list.txt"
|
||||
"$exe" extract -o "$output_dir" "$archive"
|
||||
diff -r "$test_root/input" "$output_dir/input"
|
||||
python3 - "$test_root/list.txt" <<'PY'
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
listing = pathlib.Path(sys.argv[1]).read_bytes()
|
||||
expected = {
|
||||
"Latin-1": bytes.fromhex("636166c3a92e747874"),
|
||||
"BMP": bytes.fromhex("61c3a7c3a36f2de5ae89e585a82e747874"),
|
||||
"non-BMP": bytes.fromhex("656d6f6a692df09f98802e62696e"),
|
||||
}
|
||||
missing = [label for label, name in expected.items() if name not in listing]
|
||||
if missing:
|
||||
raise SystemExit("list output is missing exact UTF-8 names: " +
|
||||
", ".join(missing))
|
||||
PY
|
||||
objdump -p "$exe" > "$test_root/imports.txt"
|
||||
if grep -Eqi '(vendor[/\\]|libvuptsdk|libpqvaptvupt|libgcc_s|libstdc\+\+|libwinpthread|msys-2[.]0|cygwin1)[^[:space:]]*[.]dll' \
|
||||
"$test_root/imports.txt"; then
|
||||
|
|
|
|||
|
|
@ -248,13 +248,17 @@ else
|
|||
fail 'backslash separators are normalized within the extraction root'
|
||||
fi
|
||||
|
||||
legitimate_entry_hex=73616665206469722f61c3a7c3a36f2e747874
|
||||
legitimate_entry_hex=73616665206469722f61c3a7c3a36f2df09f98802e747874
|
||||
MSYS2_ARG_CONV_EXCL='--entry-hex=' \
|
||||
"$FIXTURE" "$TEST_ROOT/legitimate.zupt" \
|
||||
"--entry-hex=$legitimate_entry_hex"
|
||||
mkdir "$TEST_ROOT/legitimate-out"
|
||||
if file_contains_hex_bytes "$TEST_ROOT/legitimate.zupt" \
|
||||
"$legitimate_entry_hex" &&
|
||||
"$ZUPT_BIN" list "$TEST_ROOT/legitimate.zupt" \
|
||||
> "$TEST_ROOT/legitimate-list.log" 2>&1 &&
|
||||
file_contains_hex_bytes "$TEST_ROOT/legitimate-list.log" \
|
||||
"$legitimate_entry_hex" &&
|
||||
"$ZUPT_BIN" extract -o "$TEST_ROOT/legitimate-out" \
|
||||
"$TEST_ROOT/legitimate.zupt" > "$TEST_ROOT/legitimate.log" 2>&1 &&
|
||||
python3 - "$TEST_ROOT/legitimate-out" "$legitimate_entry_hex" <<'PY'
|
||||
|
|
@ -268,9 +272,9 @@ extracted = pathlib.Path(sys.argv[1]).joinpath(*relative_path.split("/"))
|
|||
raise SystemExit(0 if extracted.read_bytes() == b"fixture content\n" else 1)
|
||||
PY
|
||||
then
|
||||
pass 'safe nested UTF-8 path extracts normally'
|
||||
pass 'safe nested BMP and non-BMP UTF-8 path lists and extracts normally'
|
||||
else
|
||||
fail 'safe nested UTF-8 path extracts normally'
|
||||
fail 'safe nested BMP and non-BMP UTF-8 path lists and extracts normally'
|
||||
fi
|
||||
|
||||
mkdir -p "$TEST_ROOT/relative-root/work"
|
||||
|
|
|
|||
Loading…
Reference in a new issue