From d44a1fc45b8f5953f06c13ef3a2936a31fe2a740 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 12 Dec 2020 09:49:01 +0200 Subject: test: add scenario for restoring mode bits --- obnam.md | 19 +++++++++++++++++++ subplot/data.py | 4 ++++ subplot/data.yaml | 3 +++ 3 files changed, 26 insertions(+) diff --git a/obnam.md b/obnam.md index 7e2bc92..9b98dae 100644 --- a/obnam.md +++ b/obnam.md @@ -550,6 +550,25 @@ given a manifest of the directory live restored in rest in rest.yaml then files live.yaml and rest.yaml match ~~~ +### Mode bits + +This scenario verifies that the mode ("permission") bits are restored +correctly. + +~~~scenario +given an installed obnam +and a running chunk server +and a client config based on metadata.yaml +and a file live/data.dat containing some random data +and file live/data.dat has mode 464 +and a manifest of the directory live in live.yaml +when I run obnam backup metadata.yaml +then backup generation is GEN +when I invoke obnam restore metadata.yaml 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 9eadd3f..09df6c5 100644 --- a/subplot/data.py +++ b/subplot/data.py @@ -13,6 +13,10 @@ def create_file_with_random_data(ctx, filename=None): f.write(data) +def chmod_file(ctx, filename=None, mode=None): + os.chmod(filename, int(mode, 8)) + + def create_manifest_of_live(ctx, dirname=None, manifest=None): _create_manifest_of_directory(ctx, dirname=dirname, manifest=manifest) diff --git a/subplot/data.yaml b/subplot/data.yaml index 4f9871a..3b4d938 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: file {filename} has mode {mode} + function: chmod_file + - given: a manifest of the directory {dirname} in {manifest} function: create_manifest_of_live -- cgit v1.2.1