Use generic method to search for partitions, supporting

partitions inside partitions. At the same time SGI DVH is
	disabled because it is not working correctly. Fixes #60
This commit is contained in:
2017-07-24 23:35:33 +01:00
parent dad9ea8584
commit 72dd8d9179
108 changed files with 517 additions and 521 deletions

View File

@@ -79,8 +79,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.Acorn();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{

View File

@@ -44,6 +44,7 @@ using DiscImageChef.Filters;
using DiscImageChef.ImagePlugins;
using DiscImageChef.PartPlugins;
using NUnit.Framework;
using DiscImageChef.Core;
namespace DiscImageChef.Tests.Partitions
{
@@ -207,10 +208,10 @@ namespace DiscImageChef.Tests.Partitions
Sequence = 8, Start = 35542 },
new Partition{ Description = null, Size = 1766400, Name = "Usr file system", Type = "Apple_UNIX_SVR2", Offset = 24734720, Length = 3450,
Sequence = 9, Start = 48310 },
new Partition{ Description = null, Size = 1558528, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 26519552, Length = 3044,
Sequence = 10, Start = 51796 },
new Partition{ Description = null, Size = 18432, Name = "Extra", Type = "Apple_Free", Offset = 26501120, Length = 36,
Sequence = 11, Start = 51760 },
Sequence = 10, Start = 51760 },
new Partition{ Description = null, Size = 1558528, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 26519552, Length = 3044,
Sequence = 11, Start = 51796 },
},
// Mac OS 6.0.4
new []{
@@ -276,10 +277,10 @@ namespace DiscImageChef.Tests.Partitions
new []{
new Partition{ Description = null, Size = 5120, Name = null, Type = "Apple_Driver", Offset = 32768, Length = 10,
Sequence = 0, Start = 64 },
new Partition{ Description = null, Size = 14013952, Name = "MacOS", Type = "Apple_HFS", Offset = 49152, Length = 27371,
Sequence = 1, Start = 96 },
new Partition{ Description = null, Size = 16384, Name = "Macintosh", Type = "Apple_Driver", Offset = 32768, Length = 32,
Sequence = 2, Start = 64 },
Sequence = 1, Start = 64 },
new Partition{ Description = null, Size = 14013952, Name = "MacOS", Type = "Apple_HFS", Offset = 49152, Length = 27371,
Sequence = 2, Start = 96 },
new Partition{ Description = null, Size = 1492992, Name = "Eschatology 1", Type = "Apple_UNIX_SVR2", Offset = 14063104, Length = 2916,
Sequence = 3, Start = 27467 },
new Partition{ Description = null, Size = 919040, Name = "A/UX Root", Type = "Apple_UNIX_SVR2", Offset = 15556096, Length = 1795,
@@ -298,10 +299,10 @@ namespace DiscImageChef.Tests.Partitions
Sequence = 10, Start = 47321 },
new Partition{ Description = null, Size = 798208, Name = "Unreserved 3", Type = "Apple_UNIX_SVR2", Offset = 24883712, Length = 1559,
Sequence = 11, Start = 48601 },
new Partition{ Description = null, Size = 2252800, Name = "Unreserved 4", Type = "Apple_UNIX_SVR2", Offset = 25825280, Length = 4400,
Sequence = 12, Start = 50440 },
new Partition{ Description = null, Size = 143360, Name = "Extra", Type = "Apple_Free", Offset = 25681920, Length = 280,
Sequence = 13, Start = 50160 },
Sequence = 12, Start = 50160 },
new Partition{ Description = null, Size = 2252800, Name = "Unreserved 4", Type = "Apple_UNIX_SVR2", Offset = 25825280, Length = 4400,
Sequence = 13, Start = 50440 },
},
// Mac OS 6.0.8
new []{
@@ -315,26 +316,26 @@ namespace DiscImageChef.Tests.Partitions
Sequence = 3, Start = 9033 },
new Partition{ Description = null, Size = 3020800, Name = "Eschatology 1", Type = "Apple_UNIX_SVR2", Offset = 5768704, Length = 5900,
Sequence = 4, Start = 11267 },
new Partition{ Description = null, Size = 2091520, Name = "A/UX Root", Type = "Apple_UNIX_SVR2", Offset = 25986560, Length = 4085,
Sequence = 5, Start = 50755 },
new Partition{ Description = null, Size = 3693056, Name = "Swap", Type = "Apple_UNIX_SVR2", Offset = 22293504, Length = 7213,
Sequence = 6, Start = 43542 },
new Partition{ Description = null, Size = 2308096, Name = "Root file system", Type = "Apple_UNIX_SVR2", Offset = 19985408, Length = 4508,
Sequence = 7, Start = 39034 },
new Partition{ Description = null, Size = 2885120, Name = "Usr file system", Type = "Apple_UNIX_SVR2", Offset = 17100288, Length = 5635,
Sequence = 8, Start = 33399 },
new Partition{ Description = null, Size = 1615872, Name = "Unreserved 1", Type = "Apple_UNIX_SVR2", Offset = 8789504, Length = 3156,
Sequence = 9, Start = 17167 },
Sequence = 5, Start = 17167 },
new Partition{ Description = null, Size = 1384960, Name = "Unreserved 3", Type = "Apple_UNIX_SVR2", Offset = 10405376, Length = 2705,
Sequence = 6, Start = 20323 },
new Partition{ Description = null, Size = 952832, Name = "Unreserved 4", Type = "Apple_UNIX_SVR2", Offset = 11790336, Length = 1861,
Sequence = 7, Start = 23028 },
new Partition{ Description = null, Size = 1246208, Name = "Extra", Type = "Apple_Free", Offset = 12743168, Length = 2434,
Sequence = 8, Start = 24889 },
new Partition{ Description = null, Size = 1495040, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 13989376, Length = 2920,
Sequence = 9, Start = 27323 },
new Partition{ Description = null, Size = 1615872, Name = "Unreserved 2", Type = "Apple_UNIX_SVR2", Offset = 15484416, Length = 3156,
Sequence = 10, Start = 30243 },
new Partition{ Description = null, Size = 1384960, Name = "Unreserved 3", Type = "Apple_UNIX_SVR2", Offset = 10405376, Length = 2705,
Sequence = 11, Start = 20323 },
new Partition{ Description = null, Size = 952832, Name = "Unreserved 4", Type = "Apple_UNIX_SVR2", Offset = 11790336, Length = 1861,
Sequence = 12, Start = 23028 },
new Partition{ Description = null, Size = 1495040, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 13989376, Length = 2920,
Sequence = 13, Start = 27323 },
new Partition{ Description = null, Size = 1246208, Name = "Extra", Type = "Apple_Free", Offset = 12743168, Length = 2434,
Sequence = 14, Start = 24889 },
new Partition{ Description = null, Size = 2885120, Name = "Usr file system", Type = "Apple_UNIX_SVR2", Offset = 17100288, Length = 5635,
Sequence = 11, Start = 33399 },
new Partition{ Description = null, Size = 2308096, Name = "Root file system", Type = "Apple_UNIX_SVR2", Offset = 19985408, Length = 4508,
Sequence = 12, Start = 39034 },
new Partition{ Description = null, Size = 3693056, Name = "Swap", Type = "Apple_UNIX_SVR2", Offset = 22293504, Length = 7213,
Sequence = 13, Start = 43542 },
new Partition{ Description = null, Size = 2091520, Name = "A/UX Root", Type = "Apple_UNIX_SVR2", Offset = 25986560, Length = 4085,
Sequence = 14, Start = 50755 },
},
// Mac OS 6.0
new []{
@@ -369,22 +370,22 @@ namespace DiscImageChef.Tests.Partitions
Sequence = 0, Start = 64 },
new Partition{ Description = null, Size = 16384, Name = "Macintosh", Type = "Apple_Driver", Offset = 32768, Length = 32,
Sequence = 1, Start = 64 },
new Partition{ Description = null, Size = 5262336, Name = "MacOS", Type = "Apple_HFS", Offset = 15845888, Length = 10278,
Sequence = 2, Start = 30949 },
new Partition{ Description = null, Size = 3073024, Name = "Scratch", Type = "Apple_Scratch", Offset = 49152, Length = 6002,
Sequence = 3, Start = 96 },
new Partition{ Description = null, Size = 1707520, Name = "Eschatology 1", Type = "Apple_UNIX_SVR2", Offset = 21108224, Length = 3335,
Sequence = 4, Start = 41227 },
new Partition{ Description = null, Size = 5262336, Name = "Extra", Type = "Apple_Free", Offset = 22815744, Length = 10278,
Sequence = 5, Start = 44562 },
Sequence = 2, Start = 96 },
new Partition{ Description = null, Size = 2726400, Name = "Root file system", Type = "Apple_UNIX_SVR2", Offset = 3122176, Length = 5325,
Sequence = 6, Start = 6098 },
Sequence = 3, Start = 6098 },
new Partition{ Description = null, Size = 3180544, Name = "Extra", Type = "Apple_Free", Offset = 5848576, Length = 6212,
Sequence = 7, Start = 11423 },
Sequence = 4, Start = 11423 },
new Partition{ Description = null, Size = 4203520, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 9029120, Length = 8210,
Sequence = 8, Start = 17635 },
Sequence = 5, Start = 17635 },
new Partition{ Description = null, Size = 2613248, Name = "Extra", Type = "Apple_Free", Offset = 13232640, Length = 5104,
Sequence = 9, Start = 25845 },
Sequence = 6, Start = 25845 },
new Partition{ Description = null, Size = 5262336, Name = "MacOS", Type = "Apple_HFS", Offset = 15845888, Length = 10278,
Sequence = 7, Start = 30949 },
new Partition{ Description = null, Size = 1707520, Name = "Eschatology 1", Type = "Apple_UNIX_SVR2", Offset = 21108224, Length = 3335,
Sequence = 8, Start = 41227 },
new Partition{ Description = null, Size = 5262336, Name = "Extra", Type = "Apple_Free", Offset = 22815744, Length = 10278,
Sequence = 9, Start = 44562 },
},
// Mac OS 7.1.1
new []{
@@ -392,24 +393,24 @@ namespace DiscImageChef.Tests.Partitions
Sequence = 0, Start = 64 },
new Partition{ Description = null, Size = 16384, Name = "Macintosh", Type = "Apple_Driver43", Offset = 32768, Length = 32,
Sequence = 1, Start = 64 },
new Partition{ Description = null, Size = 5148160, Name = "MacOS", Type = "Apple_HFS", Offset = 7294464, Length = 10055,
Sequence = 2, Start = 14247 },
new Partition{ Description = null, Size = 2097152, Name = "ProDOS", Type = "Apple_PRODOS", Offset = 5197312, Length = 4096,
Sequence = 3, Start = 10151 },
new Partition{ Description = null, Size = 3996672, Name = "A/UX Root", Type = "Apple_UNIX_SVR2", Offset = 24081408, Length = 7806,
Sequence = 4, Start = 47034 },
new Partition{ Description = null, Size = 1486848, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 49152, Length = 2904,
Sequence = 5, Start = 96 },
new Partition{ Description = null, Size = 4406784, Name = "Extra", Type = "Apple_Free", Offset = 12442624, Length = 8607,
Sequence = 6, Start = 24302 },
new Partition{ Description = null, Size = 2485760, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 16849408, Length = 4855,
Sequence = 7, Start = 32909 },
new Partition{ Description = null, Size = 4746240, Name = "Extra", Type = "Apple_Free", Offset = 19335168, Length = 9270,
Sequence = 8, Start = 37764 },
Sequence = 2, Start = 96 },
new Partition{ Description = null, Size = 2097152, Name = "ProDOS", Type = "Apple_PRODOS", Offset = 1536000, Length = 4096,
Sequence = 9, Start = 3000 },
Sequence = 3, Start = 3000 },
new Partition{ Description = null, Size = 1564160, Name = "Extra", Type = "Apple_Free", Offset = 3633152, Length = 3055,
Sequence = 10, Start = 7096 },
Sequence = 4, Start = 7096 },
new Partition{ Description = null, Size = 2097152, Name = "ProDOS", Type = "Apple_PRODOS", Offset = 5197312, Length = 4096,
Sequence = 5, Start = 10151 },
new Partition{ Description = null, Size = 5148160, Name = "MacOS", Type = "Apple_HFS", Offset = 7294464, Length = 10055,
Sequence = 6, Start = 14247 },
new Partition{ Description = null, Size = 4406784, Name = "Extra", Type = "Apple_Free", Offset = 12442624, Length = 8607,
Sequence = 7, Start = 24302 },
new Partition{ Description = null, Size = 2485760, Name = "Random A/UX fs", Type = "Apple_UNIX_SVR2", Offset = 16849408, Length = 4855,
Sequence = 8, Start = 32909 },
new Partition{ Description = null, Size = 4746240, Name = "Extra", Type = "Apple_Free", Offset = 19335168, Length = 9270,
Sequence = 9, Start = 37764 },
new Partition{ Description = null, Size = 3996672, Name = "A/UX Root", Type = "Apple_UNIX_SVR2", Offset = 24081408, Length = 7806,
Sequence = 10, Start = 47034 },
},
// Mac OS 7.5
new []{
@@ -422,21 +423,21 @@ namespace DiscImageChef.Tests.Partitions
},
// GNU Parted
new []{
new Partition{ Description = null, Size = 47185920, Name = "untitled", Type = "Apple_HFS", Offset = 2097152, Length = 92160,
Sequence = 0, Start = 4096 },
new Partition{ Description = null, Size = 84934656, Name = "untitled", Type = "Apple_UNIX_SVR2", Offset = 49283072, Length = 165888,
Sequence = 1, Start = 96256 },
new Partition{ Description = null, Size = 2064384, Name = "Extra", Type = "Apple_Free", Offset = 32768, Length = 4032,
Sequence = 2, Start = 64 },
Sequence = 0, Start = 64 },
new Partition{ Description = null, Size = 47185920, Name = "untitled", Type = "Apple_HFS", Offset = 2097152, Length = 92160,
Sequence = 1, Start = 4096 },
new Partition{ Description = null, Size = 84934656, Name = "untitled", Type = "Apple_UNIX_SVR2", Offset = 49283072, Length = 165888,
Sequence = 2, Start = 96256 },
},
// Silverlining 2.2.1
new []{
new Partition{ Description = null, Size = 3072, Name = null, Type = "Apple_Driver", Offset = 32768, Length = 6,
Sequence = 0, Start = 64 },
new Partition{ Description = null, Size = 25088, Name = null, Type = "Apple_Driver", Offset = 98304, Length = 49,
Sequence = 1, Start = 192 },
new Partition{ Description = null, Size = 65536, Name = "Macintosh_SL", Type = "Apple_Driver43", Offset = 32768, Length = 128,
Sequence = 2, Start = 64 },
Sequence = 1, Start = 64 },
new Partition{ Description = null, Size = 25088, Name = null, Type = "Apple_Driver", Offset = 98304, Length = 49,
Sequence = 2, Start = 192 },
new Partition{ Description = null, Size = 65536, Name = "Macintosh_SL", Type = "Apple_Driver_ATA", Offset = 98304, Length = 128,
Sequence = 3, Start = 192 },
new Partition{ Description = null, Size = 25804800, Name = "Untitled #1", Type = "Apple_HFS", Offset = 163840, Length = 50400,
@@ -481,8 +482,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.AppleMap();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{

View File

@@ -122,8 +122,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.AtariPartitions();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{

View File

@@ -77,8 +77,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.BSD();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{

View File

@@ -91,8 +91,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.GuidPartitionTable();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{

View File

@@ -573,8 +573,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.MBR();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{

View File

@@ -70,8 +70,6 @@ namespace DiscImageChef.Tests.Partitions
[Test]
public void Test()
{
throw new System.NotImplementedException("Partition schemes inside partitions are not yet implemented, and should be tested here.");
/*
for(int i = 0; i < testfiles.Length; i++)
{
string location = Path.Combine(Consts.TestFilesRoot, "partitions", "minix", testfiles[i]);
@@ -79,22 +77,21 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.BSD();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{
// Too chatty
//Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]);
Assert.AreEqual(wanted[i][j].PartitionLength, partitions[j].PartitionLength, testfiles[i]);
Assert.AreEqual(wanted[i][j].PartitionName, partitions[j].PartitionName, testfiles[i]);
Assert.AreEqual(wanted[i][j].PartitionType, partitions[j].PartitionType, testfiles[i]);
Assert.AreEqual(wanted[i][j].PartitionStart, partitions[j].PartitionStart, testfiles[i]);
Assert.AreEqual(wanted[i][j].PartitionSectors, partitions[j].PartitionSectors, testfiles[i]);
Assert.AreEqual(wanted[i][j].PartitionSequence, partitions[j].PartitionSequence, testfiles[i]);
Assert.AreEqual(wanted[i][j].PartitionStartSector, partitions[j].PartitionStartSector, testfiles[i]);
Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]);
Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]);
Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]);
Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]);
Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]);
Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]);
Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]);
}
}*/
}
}
}
}

View File

@@ -76,8 +76,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.PC98();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{

View File

@@ -65,8 +65,8 @@ namespace DiscImageChef.Tests.Partitions
Sequence = 2, Start = 345440 },
new Partition{ Description = null, Size = 87392256, Name = "UDH3", Type = "\"DOS\\3\"", Offset = 264257536, Length = 170688,
Sequence = 3, Start = 516128 },
new Partition{ Description = null, Size = 87392256, Name = "UDH4", Type = "\"RES\\86\"", Offset = 351649792, Length = 170688,
Sequence = 4, Start = 686816 },
new Partition{ Description = null, Size = 87300096, Name = "FAT16", Type = "0x06", Offset = 351663104, Length = 170508,
Sequence = 4, Start = 686842 },
new Partition{ Description = null, Size = 85311488, Name = "UDH5", Type = "\"RES\\86\"", Offset = 439042048, Length = 166624,
Sequence = 5, Start = 857504 },
},
@@ -106,8 +106,7 @@ namespace DiscImageChef.Tests.Partitions
filter.Open(location);
ImagePlugin image = new VDI();
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
PartPlugin parts = new DiscImageChef.PartPlugins.AmigaRigidDiskBlock();
Assert.AreEqual(true, parts.GetInformation(image, out List<Partition> partitions), testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
for(int j = 0; j < partitions.Count; j++)
{