Files
Aaru/Aaru.Tests/Partitions/BSD.cs

427 lines
15 KiB
C#
Raw Normal View History

2017-07-18 06:33:47 +01:00
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : BSD.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
2017-07-18 06:33:47 +01:00
//
// Component : DiscImageChef unit testing.
2017-07-18 06:33:47 +01:00
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2020-07-25 01:58:50 +01:00
// Copyright © 2011-2020 Natalia Portillo
2017-07-18 06:33:47 +01:00
// ****************************************************************************/
2017-07-18 06:33:47 +01:00
using System.Collections.Generic;
using System.IO;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes;
using Aaru.CommonTypes.Interfaces;
using Aaru.DiscImages;
using Aaru.Filters;
2017-07-18 06:33:47 +01:00
using NUnit.Framework;
2020-02-27 00:33:26 +00:00
namespace Aaru.Tests.Partitions
2017-07-18 06:33:47 +01:00
{
[TestFixture]
public class Bsd
2017-07-18 06:33:47 +01:00
{
2020-07-22 13:20:25 +01:00
readonly string[] _testFiles =
2018-12-31 13:17:27 +00:00
{
"parted.aif", "netbsd_1.6.aif", "netbsd_6.1.5.aif", "netbsd_7.1.aif"
2018-12-31 13:17:27 +00:00
};
2017-07-18 06:33:47 +01:00
2020-07-20 21:11:32 +01:00
readonly Partition[][] _wanted =
2017-12-19 20:33:03 +00:00
{
// Parted
2017-12-19 20:33:03 +00:00
new[]
{
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 38797312,
Name = null,
Type = "FAT",
Offset = 1048576,
Length = 75776,
Sequence = 0,
Start = 2048
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 19922944,
Name = null,
Type = "FAT",
Offset = 40894464,
Length = 38912,
Sequence = 1,
Start = 79872
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 48234496,
Name = null,
Type = "FAT",
Offset = 61865984,
Length = 94208,
Sequence = 2,
Start = 120832
2017-12-21 02:52:12 +00:00
}
2017-07-18 06:33:47 +01:00
},
2020-02-29 18:03:35 +00:00
2017-07-26 23:35:35 +01:00
// NetBSD 1.6
2017-12-19 20:33:03 +00:00
new[]
{
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 10453504,
Name = null,
Type = "FAT",
Offset = 516096,
Length = 20417,
Sequence = 0,
Start = 1008
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 209715200,
Name = null,
Type = "FAT",
Offset = 11354112,
Length = 409600,
Sequence = 1,
Start = 22176
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 805306368,
Name = null,
Type = "FAT",
Offset = 221405184,
Length = 1572864,
Sequence = 2,
Start = 432432
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 747656192,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 1027031040,
Length = 1460266,
Sequence = 3,
Start = 2005920
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 268435456,
Name = null,
Type = "4.4LFS",
Offset = 1774854144,
Length = 524288,
Sequence = 4,
Start = 3466512
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 103743488,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 2043740160,
Length = 202624,
Sequence = 5,
Start = 3991680
2017-12-21 02:52:12 +00:00
}
2017-07-26 23:35:35 +01:00
},
2020-02-29 18:03:35 +00:00
2017-07-26 23:35:35 +01:00
// NetBSD 6.1.5
2017-12-19 20:33:03 +00:00
new[]
{
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 10485760,
Name = null,
Type = "FAT",
Offset = 516096,
Length = 20480,
Sequence = 0,
Start = 1008
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 104857600,
Name = null,
Type = "FAT",
Offset = 11354112,
Length = 204800,
Sequence = 1,
Start = 22176
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 209715200,
Name = null,
Type = "FAT",
Offset = 116637696,
Length = 409600,
Sequence = 2,
Start = 227808
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 40771584,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 326688768,
Length = 79632,
Sequence = 3,
Start = 638064
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 419430400,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 367460352,
Length = 819200,
Sequence = 4,
Start = 717696
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 471859200,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 787562496,
Length = 921600,
Sequence = 5,
Start = 1538208
2017-12-19 20:33:03 +00:00
},
2020-02-29 18:03:35 +00:00
2017-07-26 23:35:35 +01:00
// Type conflicts between DragonFly and NetBSD, really is Apple UFS
2017-12-19 20:33:03 +00:00
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 78643200,
Name = null,
Type = "Hammer",
Offset = 1259790336,
Length = 153600,
Sequence = 6,
Start = 2460528
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 99614720,
Name = null,
Type = "UNIX 7th Edition",
Offset = 1338753024,
Length = 194560,
Sequence = 7,
Start = 2614752
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 244318208,
Name = null,
Type = "4.4LFS",
Offset = 1438875648,
Length = 477184,
Sequence = 8,
Start = 2810304
2017-12-19 20:33:03 +00:00
},
2020-02-29 18:03:35 +00:00
2017-07-26 23:35:35 +01:00
// Type conflicts, really is Linux ext2
2017-12-19 20:33:03 +00:00
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 463978496,
Name = null,
Type = "Digital LSM Public Region",
Offset = 1683505152,
Length = 906208,
Sequence = 9,
Start = 3288096
2017-12-21 02:52:12 +00:00
}
2017-07-26 23:35:35 +01:00
},
2020-02-29 18:03:35 +00:00
2017-07-26 23:35:35 +01:00
// NetBSD 7.1
2017-12-19 20:33:03 +00:00
new[]
{
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 10321920,
Name = null,
Type = "FAT",
Offset = 516096,
Length = 20160,
Sequence = 0,
Start = 1008
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 104767488,
Name = null,
Type = "FAT",
Offset = 11354112,
Length = 204624,
Sequence = 1,
Start = 22176
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 209534976,
Name = null,
Type = "FAT",
Offset = 116637696,
Length = 409248,
Sequence = 2,
Start = 227808
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 40255488,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 326688768,
Length = 78624,
Sequence = 3,
Start = 638064
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 419069952,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 367460352,
Length = 818496,
Sequence = 4,
Start = 717696
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 471711744,
Name = null,
Type = "4.2BSD Fast File System",
Offset = 787562496,
Length = 921312,
Sequence = 5,
Start = 1538208
2017-12-19 20:33:03 +00:00
},
2020-02-29 18:03:35 +00:00
2017-07-26 23:35:35 +01:00
// Type conflicts between DragonFly and NetBSD, really is Apple UFS
2017-12-19 20:33:03 +00:00
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 78446592,
Name = null,
Type = "Hammer",
Offset = 1259790336,
Length = 153216,
Sequence = 6,
Start = 2460528
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 99606528,
Name = null,
Type = "UNIX 7th Edition",
Offset = 1338753024,
Length = 194544,
Sequence = 7,
Start = 2614752
2017-12-19 20:33:03 +00:00
},
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 243597312,
Name = null,
Type = "4.4LFS",
Offset = 1438875648,
Length = 475776,
Sequence = 8,
Start = 2810304
2017-12-19 20:33:03 +00:00
},
2020-02-29 18:03:35 +00:00
2017-07-26 23:35:35 +01:00
// Type conflicts, really is Linux ext2
2017-12-19 20:33:03 +00:00
new Partition
{
2020-07-20 04:34:16 +01:00
Description = null,
Size = 463970304,
Name = null,
Type = "Digital LSM Public Region",
Offset = 1683505152,
Length = 906192,
Sequence = 9,
Start = 3288096
2017-12-21 02:52:12 +00:00
}
}
};
2017-07-18 06:33:47 +01:00
[Test]
public void Test()
{
2020-07-22 13:20:25 +01:00
for(int i = 0; i < _testFiles.Length; i++)
2017-07-18 06:33:47 +01:00
{
2020-07-20 21:11:32 +01:00
string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "BSD slices",
2020-07-22 13:20:25 +01:00
_testFiles[i]);
2020-07-08 20:02:59 +01:00
IFilter filter = new ZZZNoFilter();
2017-07-18 06:33:47 +01:00
filter.Open(location);
IMediaImage image = new AaruFormat();
2020-07-22 13:20:25 +01:00
Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
2020-07-22 13:20:25 +01:00
Assert.AreEqual(_wanted[i].Length, partitions.Count, _testFiles[i]);
2020-02-29 18:03:35 +00:00
2017-07-18 06:33:47 +01:00
for(int j = 0; j < partitions.Count; j++)
{
// Too chatty
//Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]);
2020-07-22 13:20:25 +01:00
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]);
2017-07-18 06:33:47 +01:00
}
2017-07-25 03:28:21 +01:00
}
2017-07-18 06:33:47 +01:00
}
}
2017-12-19 20:33:03 +00:00
}