|
@@ -4,8 +4,18 @@
|
|
|
# The test vector printf'ed into data.bin, as well as the names in filenames()
|
|
|
# should correspond exactly to the sequences in UnicodeSequences.valid.
|
|
|
|
|
|
+# Run with:
|
|
|
+# python3 genTestRes.py
|
|
|
+# Or:
|
|
|
+# python3 genTestRes.py TEST_INVALID_UNICODE_FS
|
|
|
+# The latter will attempt to create filenames which contain invalid Unicode
|
|
|
+# codepoints; this does not work on some filesystems, e.g. APFS.
|
|
|
+
|
|
|
import os
|
|
|
import shutil
|
|
|
+import sys
|
|
|
+
|
|
|
+MODE = " ".join(sys.argv[1:])
|
|
|
|
|
|
TESTDIR = "test-res"
|
|
|
|
|
@@ -17,19 +27,19 @@ os.mkdir(TESTDIR)
|
|
|
|
|
|
# Unicode test vectors
|
|
|
allUnicode = [
|
|
|
- [0x01],
|
|
|
+ [0x01], # will not work on NTFS
|
|
|
[0x7F],
|
|
|
[0xC2, 0x80],
|
|
|
[0xDF, 0xBF],
|
|
|
[0xE0, 0xA0, 0x80],
|
|
|
- [0xED, 0x9F, 0xBF],
|
|
|
+ [0xED, 0x9F, 0xBF], # will not work on APFS
|
|
|
[0xEE, 0x80, 0x80],
|
|
|
[0xEF, 0xBF, 0xBD],
|
|
|
[0xF0, 0x90, 0x80, 0x80],
|
|
|
- [0xF0, 0x9F, 0xBF, 0xBF],
|
|
|
- [0xF3, 0xBF, 0xBF, 0xBF],
|
|
|
+ [0xF0, 0x9F, 0xBF, 0xBF], # will not work on APFS
|
|
|
+ [0xF3, 0xBF, 0xBF, 0xBF], # will not work on APFS
|
|
|
[0xF4, 0x80, 0x80, 0x80],
|
|
|
- [0xF4, 0x8F, 0xBF, 0xBF],
|
|
|
+ [0xF4, 0x8F, 0xBF, 0xBF], # will not work on APFS
|
|
|
[0xF0, 0x9F, 0x98, 0x82, 0xF0, 0x9F, 0x98, 0x84, 0xF0, 0x9F, 0x98, 0x99],
|
|
|
[0xC8, 0xA7],
|
|
|
[0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, 0xEF, 0xBC, 0x8C, 0xE3, 0x81, 0xAB, 0xE3, 0x81, 0xBB, 0xE3, 0x82, 0x93, 0xE3, 0x81, 0x94]
|
|
@@ -43,6 +53,13 @@ allFilenames = allStrings[:]
|
|
|
if os.name == "nt":
|
|
|
allFilenames.remove(bytes([0x01]).decode("utf-8"))
|
|
|
|
|
|
+# on APFS (macOS 10.13+), filenames must consist of valid Unicode codepoints
|
|
|
+if MODE != "TEST_INVALID_UNICODE_FS":
|
|
|
+ allFilenames.remove(bytes([0xED, 0x9F, 0xBF]).decode("utf-8"))
|
|
|
+ allFilenames.remove(bytes([0xF0, 0x9F, 0xBF, 0xBF]).decode("utf-8"))
|
|
|
+ allFilenames.remove(bytes([0xF3, 0xBF, 0xBF, 0xBF]).decode("utf-8"))
|
|
|
+ allFilenames.remove(bytes([0xF4, 0x8F, 0xBF, 0xBF]).decode("utf-8"))
|
|
|
+
|
|
|
allBinary = b""
|
|
|
for data in allUnicode:
|
|
|
allBinary += bytes(data) + b"\n"
|