From 709bfa6a4ab5d85293a845d3079284aeba49a301 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 7 Mar 2021 22:25:57 +0000 Subject: [PATCH] Add unit test for issue 300. --- Aaru.Tests/Issues/266.cs | 2 +- Aaru.Tests/Issues/300.cs | 103 ++++++++++++++++++++ Aaru.Tests/Issues/FsExtractHashIssueTest.cs | 8 +- Aaru.Tests/Issues/FsExtractIssueTest.cs | 7 +- 4 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 Aaru.Tests/Issues/300.cs diff --git a/Aaru.Tests/Issues/266.cs b/Aaru.Tests/Issues/266.cs index 0021f6089..d0b0a67eb 100644 --- a/Aaru.Tests/Issues/266.cs +++ b/Aaru.Tests/Issues/266.cs @@ -20,7 +20,7 @@ namespace Aaru.Tests.Issues protected override string DataFolder => Path.Combine(Consts.TEST_FILES_ROOT, "Issues", "Fixed", "issue266"); protected override string TestFile => "Namco (USA) (2005 Assets).cue"; protected override Dictionary ParsedOptions => new Dictionary(); - protected override bool Debug => true; + protected override bool Debug => false; protected override bool Xattrs => false; protected override string Encoding => null; protected override bool ExpectPartitions => true; diff --git a/Aaru.Tests/Issues/300.cs b/Aaru.Tests/Issues/300.cs new file mode 100644 index 000000000..a0d72362f --- /dev/null +++ b/Aaru.Tests/Issues/300.cs @@ -0,0 +1,103 @@ +using System.Collections.Generic; +using System.IO; + +// ReSharper disable StringLiteralTypo + +namespace Aaru.Tests.Issues +{ + /* https://github.com/aaru-dps/Aaru/issues/300 + * + * SilasLaspada commented on Mar 9, 2020 + * + * Trying to extract files from an image results in + * "Partition 1: + * Identifying filesystem on partition + * Error reading file: Object reference not set to an instance of an object." + * + * Aaru does extract the files successfully as far as I can tell despite the error. + * Log and image files: https://drive.google.com/open?id=17Hzuo4rj9UbLA8Zh3-tclkWM3a_L43e7 + */ + + // 20200309 CLAUNIA: Fixed in 48f067d79ff30cfd10e084085ff479bbb0939512 + public class _300 : FsExtractHashIssueTest + { + protected override string DataFolder => Path.Combine(Consts.TEST_FILES_ROOT, "Issues", "Fixed", "issue300"); + protected override string TestFile => "sony.dicf"; + protected override Dictionary ParsedOptions => new Dictionary(); + protected override bool Debug => true; + protected override bool Xattrs => false; + protected override string Encoding => null; + protected override bool ExpectPartitions => true; + protected override string Namespace => null; + + protected override FsExtractHashData ExpectedData => new FsExtractHashData + { + Partitions = new[] + { + new PartitionVolumes + { + Volumes = new[] + { + new VolumeData + { + VolumeName = "Sony USB Driver", + Directories = new List(), + FilesWithMd5 = new Dictionary + { + { + "DATA1.HDR", "3d1ffe01d012dcc0fc208ff0c0dd5cfe" + }, + { + "$PATH_TABLE.MSB", "cc662c00c2ee224212141f82414f06c2" + }, + { + "PRIV.DLL", "a2a17469db36053d5000781eb00e8da2" + }, + { + "LAYOUT.BIN", "5a7c5bc8faad06c9b0e7b674bef678de" + }, + { + "USBSETUP.DAT", "efeae3b28ce736eeab4347912ffa7293" + }, + { + "$PATH_TABLE.LSB", "b396ff192a15bd3a0bc6075eef122ebd" + }, + { + "SETUP.INX", "91311772c03c18d3e0bce5d1ca8c4375" + }, + { + "IKERNEL.EX_", "63736e15d6061f12d0ea9cc9586ee931" + }, + { + "SETUP.INI", "22a4471186e5bf51c94c75fc6edb052d" + }, + { + "SONYSYS.DAT", "5abfed688c49490a63f57ed9dd2a2ead" + }, + { + "$", "557e3a3615a72aba02dce151b36ebc7a" + }, + { + "$PVD", "a96f2e6434b669f2b4582965b5661f4a" + }, + { + "DATA2.CAB", "debccd001263b8863e9677984e05fcc5" + }, + { + "DOSETUP.DAT", "48aa8c4215e554239d8f702beb1769da" + }, + { + "SETUP.EXE", "d0f6e0fb47eafc597fc588bb18711211" + }, + { + "DATA1.CAB", "4ce6639d1f34dee43b037787c35c1561" + } + } + } + } + }, + new PartitionVolumes() + } + }; + } +} \ No newline at end of file diff --git a/Aaru.Tests/Issues/FsExtractHashIssueTest.cs b/Aaru.Tests/Issues/FsExtractHashIssueTest.cs index 3c51fc367..8d3f27fe3 100644 --- a/Aaru.Tests/Issues/FsExtractHashIssueTest.cs +++ b/Aaru.Tests/Issues/FsExtractHashIssueTest.cs @@ -32,7 +32,8 @@ namespace Aaru.Tests.Issues var filtersList = new FiltersList(); IFilter inputFilter = filtersList.GetFilter(TestFile); - ParsedOptions.Add("debug", Debug.ToString()); + Dictionary options = ParsedOptions; + options["debug"] = Debug.ToString(); Assert.IsNotNull(inputFilter, "Cannot open specified file."); @@ -83,6 +84,9 @@ namespace Aaru.Tests.Issues continue; } + if(ExpectedData.Partitions[i].Volumes is null) + continue; + Assert.AreEqual(ExpectedData.Partitions[i].Volumes.Length, idPlugins.Count, $"Expected {ExpectedData.Partitions[i].Volumes.Length} filesystems identified in partition {i} but found {idPlugins.Count}"); @@ -102,7 +106,7 @@ namespace Aaru.Tests.Issues filesystemFound = true; - Errno error = fs.Mount(imageFormat, partitions[i], encodingClass, ParsedOptions, Namespace); + Errno error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); Assert.AreEqual(Errno.NoError, error, $"Could not mount {pluginName} in partition {i}."); diff --git a/Aaru.Tests/Issues/FsExtractIssueTest.cs b/Aaru.Tests/Issues/FsExtractIssueTest.cs index c1aef01f5..4c4aebeac 100644 --- a/Aaru.Tests/Issues/FsExtractIssueTest.cs +++ b/Aaru.Tests/Issues/FsExtractIssueTest.cs @@ -29,7 +29,8 @@ namespace Aaru.Tests.Issues var filtersList = new FiltersList(); IFilter inputFilter = filtersList.GetFilter(TestFile); - ParsedOptions.Add("debug", Debug.ToString()); + Dictionary options = ParsedOptions; + options["debug"] = Debug.ToString(); Assert.IsNotNull(inputFilter, "Cannot open specified file."); @@ -90,7 +91,7 @@ namespace Aaru.Tests.Issues filesystemFound = true; - error = fs.Mount(imageFormat, partitions[i], encodingClass, ParsedOptions, Namespace); + error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); Assert.AreEqual(Errno.NoError, error, $"Could not mount {pluginName} in partition {i}."); @@ -111,7 +112,7 @@ namespace Aaru.Tests.Issues filesystemFound = true; - error = fs.Mount(imageFormat, partitions[i], encodingClass, ParsedOptions, Namespace); + error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); Assert.AreEqual(Errno.NoError, error, $"Could not mount {plugin.Name} in partition {i}.");