internal static string GetCleanGpuName(GpuVendor vendor, string name) { switch (vendor) { case GpuVendor.Nvidia: { // GeForce RTX 2080/pcie/SSE2 -> GeForce RTX 2080 var matches = _gpuGeforceRegex.Match(name); if (matches.Success) { return(matches.Groups[1].Value); } } break; case GpuVendor.AMD: { // AMD Radeon(TM) Vega 8 Graphics -> Radeon Vega 8 var matches = _gpuRadeonRegex.Match(name); if (matches.Success) { return($"Radeon {matches.Groups[1].Value}"); } } break; case GpuVendor.Intel: { // Intel(R) UHD Graphics 630 -> UHD Graphics 630 var matches = _gpuIntelRegex.Match(name); if (matches.Success) { return(matches.Groups[1].Value); } } break; } // Eh, couldn't improve it return(name); }
/// <summary> /// Gets an overview of the most recent rendering test run. /// </summary> /// <param name="vendor">The vendor for which to retrieve a rendering test run.</param> /// <param name="planKey">The Bamboo plan key for which to retrieve results.</param> /// <param name="branchKey">The Bamboo branch key for which to retrieve results.</param> /// <param name="page">The index of the selected page of results.</param> /// <param name="pageSize">The number of test results on each page of the overview.</param> /// <returns>A <see cref="RenderingTestOverview"/> instance which represents the msot recent test run.</returns> public RenderingTestOverview GetMostRecentRenderingTestOverview(GpuVendor vendor, String planKey, String branchKey, Int32 page, Int32 pageSize) { var id = 0L; var directory = GetMostRecentTestResultsDirectory(vendor, planKey, branchKey, out id); if (directory == null) return null; var cachedTestInfos = RetrieveCachedTestInfo(directory); var images = directory.GetFiles("*.png"); var imagesByTest = from file in images let filename = Path.GetFileName(file.FullName) let testname = GetTestNameFromImageFileName(file.FullName) where !String.IsNullOrEmpty(testname) group filename by testname into g select g; var workingDirectoryPattern = ConfigurationManager.AppSettings["BambooWorkingDirectoryPattern"]; var workingDirectory = String.Format(workingDirectoryPattern, branchKey ?? planKey); var outputDir = VirtualPathUtility.ToAbsolute(String.Format("~/TestResults/{0}/{1}/{2}", vendor, workingDirectory, id)); var tests = new List<RenderingTest>(); foreach (var cachedTestInfo in cachedTestInfos) { var imageName = cachedTestInfo.Name.Split(' ').First(); var testExpected = String.Format("{0}_Expected.png", imageName); var testActual = String.Format("{0}_Actual.png", imageName); var testDiff = String.Format("{0}_Diff.png", imageName); var test = new RenderingTest(cachedTestInfo.Name, cachedTestInfo.Description, GetRelativeUrlOfImage(outputDir, testExpected), GetRelativeUrlOfImage(outputDir, testActual), GetRelativeUrlOfImage(outputDir, testDiff)); test.Failed = (cachedTestInfo.Status == CachedTestInfoStatus.Failed); tests.Add(test); } var resultTests = tests.OrderBy(test => test.Name).Select((test, index) => new { Page = index / pageSize, Test = test }).GroupBy(item => item.Page) .Select(group => group.Select(item => item.Test)).ToList(); var resultPages = resultTests.Select(x => new RenderingTestPage() { Failed = x.Any(y => y.Failed) }); if (page < 0 || page >= resultTests.Count) page = 0; return new RenderingTestOverview() { TestRunID = id, PassedTestCount = tests.Where(x => !x.Failed).Count(), FailedTestCount = tests.Where(x => x.Failed).Count(), SelectedPage = page, Tests = resultTests.Any() ? resultTests[page].ToList() : new List<RenderingTest>(), Pages = resultPages.ToList(), TimeProcessed = directory.CreationTime, Vendor = vendor }; }
internal GpuInfo(GpuVendor vendor, string name) { Vendor = vendor; Name = HardwareDetector.GetCleanGpuName(vendor, name).Trim(); }
/// <summary> /// Gets a <see cref="DirectoryInfo"/> which represents the most recent rendering test run. /// </summary> /// <param name="vendor">The vendor for which to retrieve a rendering test run.</param> /// <param name="planKey">The Bamboo plan key for which to retrieve results.</param> /// <param name="branchKey">The Bamboo branch key for which to retrieve results.</param> /// <param name="id">The identifier of the test run associated with the retrieved directory.</param> /// <returns>A <see cref="DirectoryInfo"/> which represents the most recent rendering test run.</returns> private static DirectoryInfo GetMostRecentTestResultsDirectory(GpuVendor vendor, String planKey, String branchKey, out Int64 id) { var root = ConfigurationManager.AppSettings["TestResultRootDirectory"]; var rootMapped = Path.IsPathRooted(root) ? root : HttpContext.Current.Server.MapPath(root); switch (vendor) { case GpuVendor.Intel: rootMapped = Path.Combine(rootMapped, "Intel"); break; case GpuVendor.Nvidia: rootMapped = Path.Combine(rootMapped, "Nvidia"); break; case GpuVendor.Amd: rootMapped = Path.Combine(rootMapped, "Amd"); break; default: throw new ArgumentException("Unrecognized GPU hardware vendor."); } var workingDirectoryPattern = ConfigurationManager.AppSettings["BambooWorkingDirectoryPattern"]; var workingDirectory = String.Format(workingDirectoryPattern, branchKey ?? planKey); rootMapped = Path.Combine(rootMapped, workingDirectory); if (!Directory.Exists(rootMapped)) { id = 0; return null; } var rootSubdirs = Directory.GetDirectories(rootMapped); var rootSubdirsByID = from subdir in rootSubdirs let dirInfo = new DirectoryInfo(subdir) let dirID = GetDirectoryID(dirInfo.Name) where dirID.HasValue orderby dirInfo.CreationTime descending select new { ID = dirID, DirectoryInfo = dirInfo }; var directory = rootSubdirsByID.FirstOrDefault(); if (directory == null) { id = 0; return null; } id = directory.ID.Value; return directory.DirectoryInfo; }