From 06f173a7de7d5598414ed0b37b0c541ff28fad01 Mon Sep 17 00:00:00 2001 From: Jessica Schumaker Date: Tue, 11 Jun 2019 13:04:21 -0400 Subject: [PATCH] Register/Unregister for offline I/O in functional tests --- .../EnlistmentPerTestCase/RepairTests.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerTestCase/RepairTests.cs b/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerTestCase/RepairTests.cs index e089d20e98..678eb561da 100644 --- a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerTestCase/RepairTests.cs +++ b/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerTestCase/RepairTests.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; namespace GVFS.FunctionalTests.Tests.EnlistmentPerTestCase @@ -12,6 +13,26 @@ namespace GVFS.FunctionalTests.Tests.EnlistmentPerTestCase [Category(Categories.ExtraCoverage)] public class RepairTests : TestsWithEnlistmentPerTestCase { + private const string PrjFSLibPath = "libPrjFSLib.dylib"; + + [OneTimeSetUp] + public void TurnOfflineIOOn() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + RegisterForOfflineIO(); + } + } + + [OneTimeTearDown] + public void TurnOfflineIOOff() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + UnregisterForOfflineIO(); + } + } + [TestCase] public void NoFixesNeeded() { @@ -154,6 +175,12 @@ public void FixesCorruptGitConfig() this.Enlistment.MountGVFS(); } + [DllImport(PrjFSLibPath, EntryPoint = "PrjFS_RegisterForOfflineIO")] + private static extern uint RegisterForOfflineIO(); + + [DllImport(PrjFSLibPath, EntryPoint = "PrjFS_UnregisterForOfflineIO")] + private static extern uint UnregisterForOfflineIO(); + private void CreateCorruptIndexAndRename(string indexPath, Action corruptionAction) { string tempIndexPath = indexPath + ".lock";