public static ChangeTrackerSupport Initialize(FileContentTableWithTrackerTests test) { var loggingContext = new LoggingContext("Dummy", "Dummy"); var fileContentTable = FileContentTable.CreateNew(); VolumeMap volumeMap = VolumeMap.TryCreateMapOfAllLocalVolumes(loggingContext); XAssert.IsNotNull(volumeMap); var journal = JournalAccessorGetter.TryGetJournalAccessor(loggingContext, volumeMap, AssemblyHelper.GetAssemblyLocation(Assembly.GetExecutingAssembly())).Value; XAssert.IsNotNull(journal); var fileChangeTracker = FileChangeTracker.StartTrackingChanges(loggingContext, volumeMap, journal, null); return(new ChangeTrackerSupport( loggingContext, test.m_pathTable, fileChangeTracker, fileContentTable, volumeMap, journal, AbsolutePath.Create(test.m_pathTable, test.TemporaryDirectory), null)); }
/// <summary> /// Gets an instance of <see cref="IChangeJournalAccessor"/> for tests. /// </summary> /// <param name="volumeMap">Volume map.</param> /// <returns>An instance of <see cref="IChangeJournalAccessor"/>.</returns> public static Possible <IChangeJournalAccessor> TryGetJournalAccessorForTest(VolumeMap volumeMap) { string path = FileUtilities.GetTempFileName(); var maybeJournal = JournalAccessorGetter.TryGetJournalAccessor(volumeMap, path); FileUtilities.DeleteFile(path); return(maybeJournal); }
private Optional <global::BuildXL.Storage.ChangeJournalService.IChangeJournalAccessor> TryGetJournalAccessor(VolumeMap map) { return(map.Volumes.Any() ? JournalAccessorGetter.TryGetJournalAccessor(LoggingContext, map, AssemblyHelper.GetAssemblyLocation(Assembly.GetExecutingAssembly())) : Optional <global::BuildXL.Storage.ChangeJournalService.IChangeJournalAccessor> .Invalid); }
/// <nodoc/> public FactIfSupportedAttribute( bool requiresAdmin = false, bool requiresJournalScan = false, bool requiresSymlinkPermission = false, bool requiresWindowsBasedOperatingSystem = false, bool requiresUnixBasedOperatingSystem = false, bool requiresHeliumDriversAvailable = false, bool requiresHeliumDriversNotAvailable = false) { RequiresAdmin = requiresAdmin; RequiresJournalScan = requiresJournalScan; RequiresSymlinkPermission = requiresSymlinkPermission; if (Skip != null) { // If skip is specified, do nothing because the test will be skipped anyway. return; } if (requiresAdmin) { if (!s_isElevated.HasValue) { s_isElevated = CurrentProcess.IsElevated; } if (!s_isElevated.Value) { Skip = "Test must be run elevated!"; return; } } if (requiresSymlinkPermission) { if (!s_canCreateSymlink.HasValue) { string tempFile = Path.GetTempFileName(); string symlinkPath = Path.GetTempFileName(); FileUtilities.DeleteFile(symlinkPath); // For reliable tests, we ensure that the symlink is created. s_canCreateSymlink = FileUtilities.TryCreateSymbolicLink(symlinkPath, tempFile, true).Succeeded&& FileUtilities.FileExistsNoFollow(symlinkPath); FileUtilities.DeleteFile(symlinkPath); FileUtilities.DeleteFile(tempFile); } if (!s_canCreateSymlink.Value) { Skip = "Test must be run with symbolic link creation privileged"; return; } } if (requiresJournalScan) { if (!s_canScanJournal.HasValue) { var loggingContext = new LoggingContext("Dummy", "Dummy"); var map = VolumeMap.TryCreateMapOfAllLocalVolumes(loggingContext); var accessor = JournalAccessorGetter.TryGetJournalAccessor(loggingContext, map, AssemblyHelper.GetAssemblyLocation(Assembly.GetExecutingAssembly())); s_canScanJournal = accessor.IsValid && accessor.Value != null; } if (!s_canScanJournal.Value) { Skip = "Test requires access to the in process change journal scan. Either run elevated on install RS2."; return; } } if (requiresWindowsBasedOperatingSystem) { if (OperatingSystemHelper.IsUnixOS) { Skip = "Test must be run on the CLR on Windows based operating systems!"; return; } } if (requiresUnixBasedOperatingSystem) { if (!OperatingSystemHelper.IsUnixOS) { Skip = "Test must be run on the CoreCLR on Unix based operating systems!"; return; } } if (requiresHeliumDriversAvailable) { if (!s_isHeliumFiltersAvailable.HasValue) { s_isHeliumFiltersAvailable = ProcessUtilities.IsWciAndBindFiltersAvailable(); } if (!s_isHeliumFiltersAvailable.Value) { Skip = "Test must be run elevated on a machine with WCI and Bind filters available."; return; } } if (requiresHeliumDriversNotAvailable) { if (!s_isHeliumFiltersAvailable.HasValue) { s_isHeliumFiltersAvailable = ProcessUtilities.IsWciAndBindFiltersAvailable(); } if (s_isHeliumFiltersAvailable.Value) { Skip = "Test must be run on a machine where WCI and Bind filters are NOT available."; return; } } }