/// <summary> /// Tests file access manifest. /// </summary> public static void TestManifestRetrieval(IEnumerable <ValidationData> validationData, FileAccessManifest fam, bool serializeManifest) { foreach (var line in fam.Describe()) { Console.WriteLine(line); } if (serializeManifest) { var writtenFlag = fam.Flag; var writtenDirectoryTranslator = fam.DirectoryTranslator; using (var stream = new MemoryStream()) { fam.Serialize(stream); stream.Position = 0; fam = FileAccessManifest.Deserialize(stream); } XAssert.AreEqual(writtenFlag, fam.Flag); XAssert.AreEqual(writtenDirectoryTranslator == null, fam.DirectoryTranslator == null); if (writtenDirectoryTranslator != null) { XAssert.AreEqual(writtenDirectoryTranslator.Count, fam.DirectoryTranslator.Count); var writtenTranslations = writtenDirectoryTranslator.Translations.ToArray(); var readTranslations = fam.DirectoryTranslator.Translations.ToArray(); for (int i = 0; i < writtenTranslations.Length; ++i) { XAssert.AreEqual(writtenTranslations[i].SourcePath, readTranslations[i].SourcePath); XAssert.AreEqual(writtenTranslations[i].TargetPath, readTranslations[i].TargetPath); } } } byte[] manifestTreeBytes = fam.GetManifestTreeBytes(); foreach (ValidationData dataItem in validationData) { uint nodePolicy; uint conePolicy; uint pathId; Usn expectedUsn; bool success = global::BuildXL.Native.Processes.Windows.ProcessUtilitiesWin.FindFileAccessPolicyInTree( manifestTreeBytes, dataItem.Path, new UIntPtr((uint)dataItem.Path.Length), out conePolicy, out nodePolicy, out pathId, out expectedUsn); XAssert.IsTrue(success, "Unable to find path in manifest"); XAssert.AreEqual( unchecked ((uint)dataItem.PathId), pathId, "PathId for '{0}' did not match", dataItem.Path); if (dataItem.NodePolicy.HasValue) { XAssert.AreEqual( unchecked ((uint)dataItem.NodePolicy.Value), nodePolicy, "Policy for '{0}' did not match", dataItem.Path); } if (dataItem.ConePolicy.HasValue) { XAssert.AreEqual( unchecked ((uint)dataItem.ConePolicy.Value), conePolicy, "Policy for '{0}' did not match", dataItem.Path); } XAssert.AreEqual( dataItem.ExpectedUsn, expectedUsn, "Usn for '{0}' did not match", dataItem.Path); } }