device: Fail with any non-zero return value on storage print_data_save()

When saving the prints we use g_file_set_contents under the hood and in
case return its error code that is a positive value.

So in such case we don't fail if we have a write failure at the end of
the enrollment.

While we could ensure in file storage to always return a negative value,
it's always better to ensure that is has to be 0 when we didn't get an
error.

Add a test checking for this case.
This commit is contained in:
Marco Trevisan (Treviño)
2021-01-27 17:06:29 +01:00
parent 2af0e6407a
commit 2b81184b42
2 changed files with 5 additions and 1 deletions

View File

@ -1603,6 +1603,10 @@ class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest):
self.enroll_image('whorl', expected_result='enroll-failed')
def test_enroll_write_print_error(self):
self.set_print_not_writable('testuser', FPrint.Finger.LEFT_THUMB)
self.enroll_image('whorl', expected_result='enroll-failed', finger='left-thumb')
def test_verify_invalid_storage_dir(self):
self.enroll_image('whorl')
os.chmod(self.state_dir, mode=0o000)