From c159ffe491bb46921e5754e8e2c579a3bf889a3a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 15 Sep 2020 16:49:45 +0200 Subject: [PATCH] [machineid] Polish up the tests - create dirs as needed (this will normally be done by unsquash, but for tests with paths it needs to be done by hand) - log what file is being checked - filePath() doesn't like the absolute paths we have (they're absolute in the chroot, and existing code just sticks rootMountPoint in front) --- src/modules/machineid/MachineIdJob.cpp | 6 ++++++ src/modules/machineid/Tests.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/machineid/MachineIdJob.cpp b/src/modules/machineid/MachineIdJob.cpp index 2feff6aea..8a33288b9 100644 --- a/src/modules/machineid/MachineIdJob.cpp +++ b/src/modules/machineid/MachineIdJob.cpp @@ -77,6 +77,12 @@ MachineIdJob::exec() //Create new files for ( const auto& entropy_file : m_entropy_files ) { + if ( !CalamaresUtils::System::instance()->createTargetParentDirs( entropy_file ) ) + { + return Calamares::JobResult::error( + QObject::tr( "Directory not found" ), + QObject::tr( "Could not create new random file
%1
." ).arg( entropy_file ) ); + } auto r = MachineId::createEntropy( m_entropy_copy ? MachineId::EntropyGeneration::CopyFromHost : MachineId::EntropyGeneration::New, root, diff --git a/src/modules/machineid/Tests.cpp b/src/modules/machineid/Tests.cpp index af6965a1f..13cce3de7 100644 --- a/src/modules/machineid/Tests.cpp +++ b/src/modules/machineid/Tests.cpp @@ -235,7 +235,8 @@ MachineIdTests::testJob() QVERIFY( r ); for ( const auto& fileName : j.entropyFileNames() ) { - QVERIFY( QFile::exists( tempRoot.filePath( fileName ) ) ); + cDebug() << "Verifying existence of" << fileName; + QVERIFY( QFile::exists( tempRoot.filePath( fileName.mid( 1 ) ) ) ); } }