KConfig: handle directory symlinks correctly.
ClosedPublic

Authored by dfaure on Aug 19 2018, 10:34 AM.

Details

Summary

When /home is a symlink, for instance (as is often the case on FreeBSD),
group deletion would fail because KConfig was comparing non-canonical
paths with canonical-paths:

QDEBUG : KConfigTest::testDelete() Comparing "/home/adridg/.qttest/config/
kconfigtest_subdir/kconfigtest" and "/usr/home/adridg/.qttest/config/
kconfigtest_subdir/kconfigtest"

Test Plan

mkdir /tmp/derp; ln -s /tmp/derp /tmp/drop
HOME=/tmp/derp bin/kconfigtest testDelete # Success
HOME=/tmp/drop bin/kconfigtest testDelete # Fail

Diff Detail

Repository
R237 KConfig
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 6715
Build 6733: arc lint + arc unit
dfaure created this revision.Aug 19 2018, 10:34 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptAug 19 2018, 10:34 AM
Restricted Application edited subscribers, added: kde-frameworks-devel; removed: Frameworks. · View Herald Transcript
dfaure requested review of this revision.Aug 19 2018, 10:34 AM

This shows up in the unit tests. Whether it has any effect in real life is unknown. FreeBSD often -- sometimes, maybe, depending on FS setup and layout -- has /home -> /usr/home or /home -> usr/home, and of course there could be weird user setups as well where .cache is symlinked to a different location with more disk space. In any case, this is triggering unit-test failures in the CI, so cleaning it up to consistently compare the same kind of filename is a good thing. I'll give this a test on my home system and give a shout when I have.

adridg added a comment.EditedAug 20 2018, 9:01 PM

Without patch, all tests

Totals: 44 passed, 2 failed, 0 skipped, 0 blacklisted, 225ms

The two failed tests are:

  • testThreads
  • testDelete

With patch, all tests

Totals: 45 passed, 1 failed, 0 skipped, 0 blacklisted, 229ms

The one failed test is:

  • testDefaults

Without patch, some tests

Some tests means run HOME=/tmp/drop bin/kconfigtest testDelete testThreads testDefaults

********* Start testing of KConfigTest *********
Config: Using QtTest library 5.10.1, Qt 5.10.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 5.0.0 (tags/RELEASE_500/final 312559))
PASS   : KConfigTest::initTestCase()
FAIL!  : KConfigTest::testDelete() '!delgr.exists()' returned FALSE. ()
   Loc: [/home/adridg/src/kde/tier-1/kconfig/autotests/kconfigtest.cpp(802)]
PASS   : KConfigTest::testThreads()
FAIL!  : KConfigTest::testDefaults() Compared values are not the same
   Actual   (group.readEntry("entry1", QString())): "hello"
   Expected (Default)                             : "Default"
   Loc: [/home/adridg/src/kde/tier-1/kconfig/autotests/kconfigtest.cpp(399)]
PASS   : KConfigTest::cleanupTestCase()

With patch, some tests

********* Start testing of KConfigTest *********
Config: Using QtTest library 5.10.1, Qt 5.10.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 5.0.0 (tags/RELEASE_500/final 312559))
PASS   : KConfigTest::initTestCase()
PASS   : KConfigTest::testDelete()
FAIL!  : KConfigTest::testThreads() Compared values are not the same
   Actual   (group.readEntry("entry1", QString())): "hello"
   Expected (Default)                             : "Default"
   Loc: [/zbigone/src/kde/tier-1/kconfig/autotests/kconfigtest.cpp(399)]
PASS   : KConfigTest::testDefaults()
PASS   : KConfigTest::cleanupTestCase()
Totals: 4 passed, 1 failed, 0 skipped, 0 blacklisted, 41ms
********* Finished testing of KConfigTest *********

Sorry, this is getting very confusing:

  • when running all tests, unpatched: testDelete and testThreads fail
  • when running all tests, patched: testDefaults fails

I suspect there are some more missing canonicalizations, but I don't have time right now to go hunting them.

dfaure updated this revision to Diff 48823.Jan 6 2019, 9:18 PM

Improved fix so that testDefaults passes too

apol accepted this revision.Feb 4 2019, 11:37 AM
This revision is now accepted and ready to land.Feb 4 2019, 11:37 AM
dfaure closed this revision.Feb 4 2019, 12:42 PM