Allow kio-fuse debugging output with fileopstest
Currently it's not possible to get the very useful libfuse debugging or Qt logging output of kio-fuse
when running fileopstest
because kio-fuse
has to daemonize:
-
fuse_daemonize(opts.foreground)
opens/dev/null
as stdin, -out and -err -
opts.foreground
is forced totrue
when the-d
option for libfuse debugging is passed
This hack works around those restrictions:
diff --git a/main.cpp b/main.cpp
index 0759da3..c5babeb 100644
--- a/main.cpp
+++ b/main.cpp
@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <unistd.h>
#include <fuse_lowlevel.h>
#include <QSocketNotifier>
@@ -58,7 +59,11 @@ int main(int argc, char *argv[])
if(!kiofusevfs.start(args, opts.mountpoint))
return 1;
- fuse_daemonize(opts.foreground);
+ const int fd = dup(2);
+ fuse_daemonize(false);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ close(fd);
fuse_opt_free_args(&args);
diff --git a/tests/fileopstest.cpp b/tests/fileopstest.cpp
index 6f72f63..6c89389 100644
--- a/tests/fileopstest.cpp
+++ b/tests/fileopstest.cpp
@@ -62,7 +62,8 @@ void FileOpsTest::initTestCase()
QProcess kiofuseProcess;
kiofuseProcess.setProgram(programpath);
- kiofuseProcess.setArguments({m_mountDir.path()});
+ kiofuseProcess.setArguments({QStringLiteral("-d"), m_mountDir.path()});
+ kiofuseProcess.setProcessChannelMode(QProcess::ForwardedChannels);
kiofuseProcess.start();