SSHFSMountsTest not deleting mock processes
Describe the bug The mock processes created in SSHFSMountsTests are not being deleted reliably when those tests finish, so they don't get the expectation verification in the right tests.
Most often (depending on the test order) these mock processes are often deleted in other tests. Expectations are currently honored, so that goes by silently.
However, when shuffling, the tests may finish with some mock processes still around, which google test detects and reports. This is what we hit in #1399.
To Reproduce Running these tests in isolation is enough to trigger the source problem:
multipass_tests --gtest_filter=SSHFSMounts*
This issue comes from the "delete_later" ptrs here. They were supposed to be deleted with this, but that isn't working.
Ugh, that delete_later pointer is sure causing some issues. There are other runtime scenarios that exposes the issue and cause headaches such as deleting an instance with a mount and quickly launching a new instance with that same name and defining a mount afterwards. The primary instance is particularly prone to this since the mount is automatic and can happen before the previous deleteLater() is finished.
Interesting. I wonder if there would be a way to do away with them and have some proper RAII in there.
Meanwhile, this mentions the requirements for the objects to actually be deleted in an event loop. Maybe they are not fulfilled in the test... TBC
The issue remains:
$ multipass_tests --gtest_filter=SSHFSMount*
[...]
ERROR: 4 leaked mock objects found at program exit. Expectations on a mock object are verified when
the object is destructed. Leaking a mock means that its expectations aren't verified, which is
usually a test bug. If you really intend to leak a mock, you can suppress this error using
testing::Mock::AllowLeak(mock_object), or you may use a fake or stub instead of a mock.