Files
Aaru/Aaru.Tests/Filesystems/AFFS.cs

350 lines
12 KiB
C#
Raw Normal View History

2017-07-08 19:23:52 +01:00
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
2017-07-08 19:24:07 +01:00
// Filename : AFFS.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
2017-07-08 19:23:52 +01:00
//
// Component : DiscImageChef unit testing.
2017-07-08 19:23:52 +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/>.
//
// ----------------------------------------------------------------------------
2018-12-29 17:34:38 +00:00
// Copyright © 2011-2019 Natalia Portillo
2017-07-08 19:23:52 +01:00
// ****************************************************************************/
using System.Collections.Generic;
2017-07-08 19:23:52 +01:00
using System.IO;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes;
using Aaru.CommonTypes.Interfaces;
using Aaru.DiscImages;
using Aaru.Filesystems;
using Aaru.Filters;
2017-07-08 19:23:52 +01:00
using NUnit.Framework;
2020-02-27 00:33:26 +00:00
namespace Aaru.Tests.Filesystems
2017-07-08 19:23:52 +01:00
{
[TestFixture]
public class Affs
2017-07-08 19:23:52 +01:00
{
2020-02-29 18:03:35 +00:00
readonly string[] testfiles =
{
"amigaos_3.9.adf.lz", "amigaos_3.9_intl.adf.lz"
};
2017-07-08 19:23:52 +01:00
2020-02-29 18:03:35 +00:00
readonly MediaType[] mediatypes =
{
MediaType.CBM_AMIGA_35_DD, MediaType.CBM_AMIGA_35_DD
};
2017-07-08 19:23:52 +01:00
2020-02-29 18:03:35 +00:00
readonly ulong[] sectors =
{
1760, 1760
};
2017-07-08 19:23:52 +01:00
2020-02-29 18:03:35 +00:00
readonly uint[] sectorsize =
{
512, 512
};
2017-07-08 19:23:52 +01:00
2020-02-29 18:03:35 +00:00
readonly long[] clusters =
{
1760, 1760
};
2017-07-08 19:23:52 +01:00
2020-02-29 18:03:35 +00:00
readonly int[] clustersize =
{
512, 512
};
2017-07-08 19:23:52 +01:00
2020-02-29 18:03:35 +00:00
readonly string[] volumename =
{
"Volume label", "Volume label"
};
2017-07-08 19:23:52 +01:00
2020-02-29 18:03:35 +00:00
readonly string[] volumeserial =
{
"A5D9FAE2", "A5DA0CC9"
};
2017-07-08 19:23:52 +01:00
[Test]
public void Test()
{
for(int i = 0; i < testfiles.Length; i++)
{
2020-07-08 20:02:59 +01:00
string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System",
testfiles[i]);
IFilter filter = new LZip();
2017-07-08 19:23:52 +01:00
filter.Open(location);
IMediaImage image = new ZZZRawImage();
2020-02-29 18:03:35 +00:00
Assert.AreEqual(true, image.Open(filter), testfiles[i]);
Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
IFilesystem fs = new AmigaDOSPlugin();
2020-02-29 18:03:35 +00:00
var wholePart = new Partition
{
2020-02-29 18:03:35 +00:00
Name = "Whole device", Length = image.Info.Sectors,
Size = image.Info.Sectors * image.Info.SectorSize
};
2020-02-29 18:03:35 +00:00
Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]);
fs.GetInformation(image, wholePart, out _, null);
2020-02-29 18:03:35 +00:00
Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]);
Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]);
Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]);
Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]);
Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]);
2017-07-08 19:23:52 +01:00
}
}
}
[TestFixture]
public class AffsMbr
{
2020-02-29 18:03:35 +00:00
readonly string[] testfiles =
{
"aros.aif", "aros_intl.aif"
2020-02-29 18:03:35 +00:00
};
2020-02-29 18:03:35 +00:00
readonly ulong[] sectors =
{
409600, 409600
};
2020-02-29 18:03:35 +00:00
readonly uint[] sectorsize =
{
512, 512
};
2020-02-29 18:03:35 +00:00
readonly long[] clusters =
{
408240, 408240
};
2020-02-29 18:03:35 +00:00
readonly int[] clustersize =
{
512, 512
};
2020-02-29 18:03:35 +00:00
readonly string[] volumename =
{
"Volume label", "Volume label"
};
2020-02-29 18:03:35 +00:00
readonly string[] volumeserial =
{
"A582DCA4", "A582BC91"
};
[Test]
public void Test()
{
for(int i = 0; i < testfiles.Length; i++)
{
2020-07-08 20:02:59 +01:00
string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR)",
testfiles[i]);
IFilter filter = new ZZZNoFilter();
filter.Open(location);
IMediaImage image = new AaruFormat();
2020-02-29 18:03:35 +00:00
Assert.AreEqual(true, image.Open(filter), testfiles[i]);
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
2018-06-22 08:08:38 +01:00
IFilesystem fs = new AmigaDOSPlugin();
int part = -1;
2020-02-29 18:03:35 +00:00
for(int j = 0; j < partitions.Count; j++)
2020-02-29 18:03:35 +00:00
if(partitions[j].Type == "0x2D" ||
partitions[j].Type == "0x2E")
{
part = j;
2020-02-29 18:03:35 +00:00
break;
}
Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}");
Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]);
fs.GetInformation(image, partitions[part], out _, null);
2020-02-29 18:03:35 +00:00
Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]);
Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]);
Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]);
Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]);
Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]);
}
}
}
[TestFixture]
public class AffsMbrRdb
{
2020-02-29 18:03:35 +00:00
readonly string[] testfiles =
{
"aros.aif", "aros_intl.aif"
2020-02-29 18:03:35 +00:00
};
2020-02-29 18:03:35 +00:00
readonly ulong[] sectors =
{
409600, 409600
};
2020-02-29 18:03:35 +00:00
readonly uint[] sectorsize =
{
512, 512
};
2020-02-29 18:03:35 +00:00
readonly long[] clusters =
{
406224, 406224
};
2020-02-29 18:03:35 +00:00
readonly int[] clustersize =
{
512, 512
};
2020-02-29 18:03:35 +00:00
readonly string[] volumename =
{
"Volume label", "Volume label"
};
2020-02-29 18:03:35 +00:00
readonly string[] volumeserial =
{
"A58348CE", "A5833CD0"
};
[Test]
public void Test()
{
for(int i = 0; i < testfiles.Length; i++)
{
2020-07-08 20:02:59 +01:00
string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR+RDB)",
testfiles[i]);
IFilter filter = new ZZZNoFilter();
filter.Open(location);
IMediaImage image = new AaruFormat();
2020-02-29 18:03:35 +00:00
Assert.AreEqual(true, image.Open(filter), testfiles[i]);
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
2018-06-22 08:08:38 +01:00
IFilesystem fs = new AmigaDOSPlugin();
int part = -1;
2020-02-29 18:03:35 +00:00
for(int j = 0; j < partitions.Count; j++)
2020-02-29 18:03:35 +00:00
if(partitions[j].Type == "\"DOS\\1\"" ||
partitions[j].Type == "\"DOS\\3\"")
{
part = j;
2020-02-29 18:03:35 +00:00
break;
}
Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}");
Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]);
fs.GetInformation(image, partitions[part], out _, null);
2020-02-29 18:03:35 +00:00
Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]);
Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]);
Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]);
Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]);
Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]);
}
}
}
[TestFixture]
public class AffsRdb
{
readonly string[] testfiles =
{
"amigaos_3.9.aif", "amigaos_3.9_intl.aif", "aros.aif", "aros_intl.aif", "amigaos_4.0.aif",
"amigaos_4.0_intl.aif", "amigaos_4.0_cache.aif"
};
2020-02-29 18:03:35 +00:00
readonly ulong[] sectors =
{
1024128, 1024128, 409600, 409600, 1024128, 1024128, 1024128
};
2020-02-29 18:03:35 +00:00
readonly uint[] sectorsize =
{
512, 512, 512, 512, 512, 512, 512
};
2020-02-29 18:03:35 +00:00
readonly long[] clusters =
{
510032, 510032, 407232, 407232, 511040, 511040, 511040
};
2020-02-29 18:03:35 +00:00
readonly int[] clustersize =
{
1024, 1024, 512, 512, 1024, 1024, 1024
};
readonly string[] volumename =
{
"Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label",
"Volume label"
};
readonly string[] volumeserial =
2018-12-31 13:17:27 +00:00
{
"A56D0F5C", "A56D049C", "A58307A9", "A58304BE", "A56CC7EE", "A56CDDC4", "A56CC133"
};
[Test]
public void Test()
{
for(int i = 0; i < testfiles.Length; i++)
{
2020-07-08 20:02:59 +01:00
string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (RDB)",
testfiles[i]);
IFilter filter = new ZZZNoFilter();
filter.Open(location);
IMediaImage image = new AaruFormat();
2020-02-29 18:03:35 +00:00
Assert.AreEqual(true, image.Open(filter), testfiles[i]);
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
2018-06-22 08:08:38 +01:00
IFilesystem fs = new AmigaDOSPlugin();
int part = -1;
2020-02-29 18:03:35 +00:00
for(int j = 0; j < partitions.Count; j++)
2020-02-29 18:03:35 +00:00
if(partitions[j].Type == "\"DOS\\1\"" ||
partitions[j].Type == "\"DOS\\3\"" ||
partitions[j].Type == "\"DOS\\5\"")
{
part = j;
2020-02-29 18:03:35 +00:00
break;
}
Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}");
Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]);
fs.GetInformation(image, partitions[part], out _, null);
2020-02-29 18:03:35 +00:00
Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]);
Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]);
Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]);
Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]);
Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]);
}
}
}
2017-12-19 20:33:03 +00:00
}