Martchus / cpp-utilities

Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
GNU General Public License v2.0
52 stars 18 forks source link

IoTests::testCopyWithNativeFileStream fails #24

Closed Nils-TUD closed 1 year ago

Nils-TUD commented 1 year ago

I tried to update to the latest version (5.22.0) with Arch Linux on x86-64, but the test IoTests::testCopyWithNativeFileStream fails:

==> Starting check()...
[9/10] cd /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0 && /usr/bin/ctest -V
UpdateCTestConfiguration  from :/home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/DartConfiguration.tcl
Test project /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
    Start 1: c++utilities_run_tests

1: Test command: /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/c++utilities_tests "-p" "/home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/testfiles" "-w" "/home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/testworkingdir"
1: Working Directory: /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0
1: Test timeout computed to be: 10000000
1: /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/testfiles/
1: /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/testfiles/
1: ./testfiles/
1: Directory used to store working copies:
1: /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/testworkingdir/
1: Executing test cases ...
1: ................E...
1: output for formatting with ANSI escape codes:
1: Error: some error
1: Warning: some warning
1: Info: some info
1: ==> ERROR: Arch-style error
1: ==> WARNING: Arch-style warning
1:     Arch-style message
1: ==> Arch-style success
1:   -> Arch-style sub-message
1: blue, blinking text on red background
1: ---------------------------------------------
1: ........................
1: 
1: 
1: !!!FAILURES!!!
1: Test Results:
1: Run:  43   Failures: 0   Errors: 1
1: 
1: 
1: 1) test: IoTests::testCopyWithNativeFileStream (E) 
1: uncaught exception of type std::exception (or derived).
1: - sendfile64() failed: Invalid argument: iostream error
1: 
1: 
1: Tests failed
1/1 Test #1: c++utilities_run_tests ...........***Failed    0.01 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.01 sec

The following tests FAILED:
      1 - c++utilities_run_tests (Failed)
Errors while running CTest
Output from these tests are in: /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
FAILED: CMakeFiles/check /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0/CMakeFiles/check 
cd /home/hrniels/.cache/pacaur/c++utilities/src/cpp-utilities-5.22.0 && /usr/bin/ctest -V
ninja: build stopped: subcommand failed.
==> ERROR: A failure occurred in check().
    Aborting...
Martchus commented 1 year ago

Well, it works for me on Arch. Maybe I should add a flag to disable this feature if it is problematic. If you're building this for Syncthing Tray you can ignore the error. If you're building this for Tag Editor you better not upgrade.

Did you retry? Just in case it might be a sporadic issue. Then I should definitely disable the feature for now.

Nils-TUD commented 1 year ago

Interesting. Yes, it happens everytime.

I investigated that some more and figured it out now. The problem is that I'm using ecryptfs for my home directory and that doesn't support sendfile.

I think you should fall back to read and write if sendfile fails to also support strange file systems (or other types of files? Not sure if your API can be used non-regular files) :)

Martchus commented 1 year ago

Thanks. I suppose that I should add a fallback indeed. I would have expected this would be handled under the hood by the kernel. The API is only intended to be used with regular files.

Martchus commented 1 year ago

I've pushed a fix. You may want to test it. On Arch, you can test it by building the AUR package c++utilities-git (which you of course don't need to actually install on your production system and even if you'd installed it the non-Git packages wouldn't be affected).

Nils-TUD commented 1 year ago

Yes, it works for me now. Thanks!