Skip to content
Snippets Groups Projects
Commit 484d7c4d authored by Aurélien Gâteau's avatar Aurélien Gâteau
Browse files

Update partition path after partition has been created

Fixes #56
parent 71087181
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,9 @@ import sys ...@@ -27,6 +27,9 @@ import sys
def mount( devicePath, mountPoint, fs ): def mount( devicePath, mountPoint, fs ):
if not os.path.exists( mountPoint ): if not os.path.exists( mountPoint ):
os.makedirs( mountPoint ) os.makedirs( mountPoint )
assert devicePath
assert mountPoint
assert fs
subprocess.check_call( [ "mount", "-t", fs, devicePath, mountPoint ] ) subprocess.check_call( [ "mount", "-t", fs, devicePath, mountPoint ] )
......
...@@ -89,6 +89,7 @@ CreatePartitionJob::exec() ...@@ -89,6 +89,7 @@ CreatePartitionJob::exec()
report.toText() report.toText()
); );
} }
m_partition->setPartitionPath( partitionPath );
backendPartitionTable->commit(); backendPartitionTable->commit();
progress( step++ / stepCount ); progress( step++ / stepCount );
......
...@@ -70,8 +70,8 @@ JobTests::JobTests() ...@@ -70,8 +70,8 @@ JobTests::JobTests()
void void
JobTests::initTestCase() JobTests::initTestCase()
{ {
QString deviceName = qgetenv( "CALAMARES_TEST_DISK" ); QString devicePath = qgetenv( "CALAMARES_TEST_DISK" );
if ( deviceName.isEmpty() ) if ( devicePath.isEmpty() )
{ {
QSKIP( "Skipping test, CALAMARES_TEST_DISK is not set. It should point to a disk which can be safely formatted" ); QSKIP( "Skipping test, CALAMARES_TEST_DISK is not set. It should point to a disk which can be safely formatted" );
} }
...@@ -79,7 +79,7 @@ JobTests::initTestCase() ...@@ -79,7 +79,7 @@ JobTests::initTestCase()
QVERIFY( CalaPM::init() ); QVERIFY( CalaPM::init() );
CoreBackend* backend = CoreBackendManager::self()->backend(); CoreBackend* backend = CoreBackendManager::self()->backend();
m_device.reset( backend->scanDevice( deviceName ) ); m_device.reset( backend->scanDevice( devicePath ) );
QVERIFY( !m_device.isNull() ); QVERIFY( !m_device.isNull() );
FileSystemFactory::init(); FileSystemFactory::init();
...@@ -141,26 +141,40 @@ JobTests::testCreatePartition() ...@@ -141,26 +141,40 @@ JobTests::testCreatePartition()
{ {
queuePartitionTableCreation( PartitionTable::gpt ); queuePartitionTableCreation( PartitionTable::gpt );
CreatePartitionJob* job; CreatePartitionJob* job;
Partition* freePartition;
Partition* partition = firstFreePartition( m_device->partitionTable() ); freePartition = firstFreePartition( m_device->partitionTable() );
job = newCreatePartitionJob( partition, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, 1 * MB); QVERIFY( freePartition );
QVERIFY( job ); job = newCreatePartitionJob( freePartition, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, 1 * MB);
Partition* partition1 = job->partition();
QVERIFY( partition1 );
job->updatePreview(); job->updatePreview();
m_queue.enqueue( job_ptr( job ) ); m_queue.enqueue( job_ptr( job ) );
partition = firstFreePartition( m_device->partitionTable() ); freePartition = firstFreePartition( m_device->partitionTable() );
QVERIFY( partition ); QVERIFY( freePartition );
job = newCreatePartitionJob( partition, PartitionRole( PartitionRole::Primary ), FileSystem::LinuxSwap, 1 * MB); job = newCreatePartitionJob( freePartition, PartitionRole( PartitionRole::Primary ), FileSystem::LinuxSwap, 1 * MB);
Partition* partition2 = job->partition();
QVERIFY( partition2 );
job->updatePreview(); job->updatePreview();
m_queue.enqueue( job_ptr( job ) ); m_queue.enqueue( job_ptr( job ) );
partition = firstFreePartition( m_device->partitionTable() ); freePartition = firstFreePartition( m_device->partitionTable() );
QVERIFY( partition ); QVERIFY( freePartition );
job = newCreatePartitionJob( partition, PartitionRole( PartitionRole::Primary ), FileSystem::Fat32, 1 * MB); job = newCreatePartitionJob( freePartition, PartitionRole( PartitionRole::Primary ), FileSystem::Fat32, 1 * MB);
Partition* partition3 = job->partition();
QVERIFY( partition3 );
job->updatePreview(); job->updatePreview();
m_queue.enqueue( job_ptr( job ) ); m_queue.enqueue( job_ptr( job ) );
QVERIFY( m_runner.run() ); QVERIFY( m_runner.run() );
// Check partitionPath has been set. It is not known until the job has
// executed.
QString devicePath = m_device->deviceNode();
QCOMPARE( partition1->partitionPath(), devicePath + "1" );
QCOMPARE( partition2->partitionPath(), devicePath + "2" );
QCOMPARE( partition3->partitionPath(), devicePath + "3" );
} }
void void
...@@ -168,25 +182,37 @@ JobTests::testCreatePartitionExtended() ...@@ -168,25 +182,37 @@ JobTests::testCreatePartitionExtended()
{ {
queuePartitionTableCreation( PartitionTable::msdos ); queuePartitionTableCreation( PartitionTable::msdos );
CreatePartitionJob* job; CreatePartitionJob* job;
Partition* freePartition;
Partition* partition = firstFreePartition( m_device->partitionTable() ); freePartition = firstFreePartition( m_device->partitionTable() );
job = newCreatePartitionJob( partition, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, 10 * MB); QVERIFY( freePartition );
QVERIFY( job ); job = newCreatePartitionJob( freePartition, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, 10 * MB);
Partition* partition1 = job->partition();
QVERIFY( partition1 );
job->updatePreview(); job->updatePreview();
m_queue.enqueue( job_ptr( job ) ); m_queue.enqueue( job_ptr( job ) );
partition = firstFreePartition( m_device->partitionTable() ); freePartition = firstFreePartition( m_device->partitionTable() );
QVERIFY( partition ); QVERIFY( freePartition );
job = newCreatePartitionJob( partition, PartitionRole( PartitionRole::Extended ), FileSystem::Extended, 10 * MB); job = newCreatePartitionJob( freePartition, PartitionRole( PartitionRole::Extended ), FileSystem::Extended, 10 * MB);
job->updatePreview(); job->updatePreview();
m_queue.enqueue( job_ptr( job ) ); m_queue.enqueue( job_ptr( job ) );
Partition* extendedPartition = job->partition(); Partition* extendedPartition = job->partition();
partition = firstFreePartition( extendedPartition ); freePartition = firstFreePartition( extendedPartition );
QVERIFY( partition ); QVERIFY( freePartition );
job = newCreatePartitionJob( partition, PartitionRole( PartitionRole::Logical ), FileSystem::Ext4, 0); job = newCreatePartitionJob( freePartition, PartitionRole( PartitionRole::Logical ), FileSystem::Ext4, 0);
Partition* partition2 = job->partition();
QVERIFY( partition2 );
job->updatePreview(); job->updatePreview();
m_queue.enqueue( job_ptr( job ) ); m_queue.enqueue( job_ptr( job ) );
QVERIFY( m_runner.run() ); QVERIFY( m_runner.run() );
// Check partitionPath has been set. It is not known until the job has
// executed.
QString devicePath = m_device->deviceNode();
QCOMPARE( partition1->partitionPath(), devicePath + "1" );
QCOMPARE( extendedPartition->partitionPath(), devicePath + "2" );
QCOMPARE( partition2->partitionPath(), devicePath + "5" );
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment