summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-26 10:25:59 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-26 10:27:33 +0200
commit96831d81fefcb76f2b33bc97b6206f594a7fcd5f (patch)
tree912d4d1efbd2b9088af1769ed3c5f927b09fe0bd
parent2f95edc25f127fd5ac1fb9df96bf8489dbece3ec (diff)
downloadobnam2-96831d81fefcb76f2b33bc97b6206f594a7fcd5f.tar.gz
test: add verification test for non-UTF8 filenames
-rw-r--r--obnam.md19
-rw-r--r--subplot/data.py6
-rw-r--r--subplot/data.yaml3
3 files changed, 28 insertions, 0 deletions
diff --git a/obnam.md b/obnam.md
index fbbf994..6706fb7 100644
--- a/obnam.md
+++ b/obnam.md
@@ -876,6 +876,25 @@ given a manifest of the directory live restored in rest in rest.yaml
then files live.yaml and rest.yaml match
~~~
+## Tricky filenames
+
+Obnam needs to handle all filenames the underlying operating and file
+system can handle. This scenario verifies it can handle a filename
+that consists on a single byte with its top bit set. This is not
+ASCII, and it's not UTF-8.
+
+~~~scenario
+given an installed obnam
+and a running chunk server
+and a client config based on metadata.yaml
+and a file in live with a non-UTF8 filename
+and a manifest of the directory live in live.yaml
+when I run obnam --config metadata.yaml backup
+then backup generation is GEN
+when I invoke obnam --config metadata.yaml restore <GEN> rest
+given a manifest of the directory live restored in rest in rest.yaml
+then files live.yaml and rest.yaml match
+~~~
diff --git a/subplot/data.py b/subplot/data.py
index ba3636c..a24cd0c 100644
--- a/subplot/data.py
+++ b/subplot/data.py
@@ -13,6 +13,12 @@ def create_file_with_random_data(ctx, filename=None):
f.write(data)
+def create_nonutf8_filename(ctx, dirname=None):
+ filename = "\x88"
+ os.mkdir(dirname)
+ open(filename, "wb").close()
+
+
def chmod_file(ctx, filename=None, mode=None):
os.chmod(filename, int(mode, 8))
diff --git a/subplot/data.yaml b/subplot/data.yaml
index 32c9cd5..7659319 100644
--- a/subplot/data.yaml
+++ b/subplot/data.yaml
@@ -6,6 +6,9 @@
- given: "a file {filename} containing some random data"
function: create_file_with_random_data
+- given: "a file in {dirname} with a non-UTF8 filename"
+ function: create_nonutf8_filename
+
- given: file {filename} has mode {mode}
function: chmod_file