KAutoSaveFile: add a unit test to check max. filename length

Authored by ahmadsamir on Dec 5 2019, 3:08 PM.

Description

KAutoSaveFile: add a unit test to check max. filename length

Summary:
In KAutoSaveFilePrivate::tempFile() the name of the kautosavefile that's
going to be created is generated using the filename and the absolute path
and some other bits (e.g. a string generated using KRandom). The problem
with that approach is that sometimes really long filenames can get created.
This unit test ensures that the checks in tempFile() work correctly and
generate filenames that don't exceed NAME_MAX (255 bytes/chars for Linux),
otherwise the files can't be opened.

Depends on D24489

References:
/usr/include/linux/limits.h
https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html
https://www.kernel.org/doc/Documentation/filesystems/path-lookup.rst

Test Plan:

  • Running ctest -R autosavefiletest fails with current master
  • Apply the patch from D24489, and the test should pass

Reviewers: Frameworks, mpyne, dfaure

Reviewed By: dfaure

Subscribers: mardelle, dhaumann, dfaure, kde-frameworks-devel

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D25767