-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathProfileOptimization.cs
More file actions
54 lines (45 loc) · 1.89 KB
/
ProfileOptimization.cs
File metadata and controls
54 lines (45 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.IO;
using System.Threading;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
namespace System.Runtime.Tests
{
public class ProfileOptimizationTest : FileCleanupTestBase
{
[Theory]
[InlineData(false)]
[InlineData(true)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/31853", TestRuntimes.Mono)]
public void ProfileOptimization_CheckFileExists(bool stopProfile)
{
string profileFile = GetTestFileName();
RemoteExecutor.Invoke((_profileFile, _stopProfile) =>
{
// Perform the test work
ProfileOptimization.SetProfileRoot(Path.GetDirectoryName(_profileFile));
ProfileOptimization.StartProfile(Path.GetFileName(_profileFile));
if (bool.Parse(_stopProfile))
{
ProfileOptimization.StartProfile(null);
CheckProfileFileExists(_profileFile);
}
}, profileFile, stopProfile.ToString()).Dispose();
CheckProfileFileExists(profileFile);
}
static void CheckProfileFileExists(string profileFile)
{
// profileFile should deterministically exist now -- if not, wait 5 seconds
bool existed = File.Exists(profileFile);
if (!existed)
{
Thread.Sleep(5000);
}
Assert.True(File.Exists(profileFile), $"'{profileFile}' does not exist");
Assert.True(new FileInfo(profileFile).Length > 0, $"'{profileFile}' is empty");
Assert.True(existed, $"'{profileFile}' did not immediately exist, but did exist 5 seconds later");
}
}
}