Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/tests/Common/Coreclr.TestWrapper/MobileAppHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ private static int HandleMobileApp(string action, string platform, string catego
{
//install or uninstall mobile app
int exitCode = -100;

if (action == "install" && (File.Exists($"{testBinaryBase}/.retry") || File.Exists($"{testBinaryBase}/.reboot")))
{
return exitCode;
}

string outputFile = Path.Combine(reportBase, action, $"{category}_{action}.output.txt");
string errorFile = Path.Combine(reportBase, action, $"{category}_{action}.error.txt");
bool platformValueFlag = true;
Expand Down Expand Up @@ -81,6 +87,11 @@ private static int HandleMobileApp(string action, string platform, string catego
}
}

if (action == "install")
{
cmdStr += " --timeout 00:05:00";
}

using (Process process = new Process())
{
if (OperatingSystem.IsWindows())
Expand Down Expand Up @@ -108,6 +119,19 @@ private static int HandleMobileApp(string action, string platform, string catego
{
// Process completed.
exitCode = process.ExitCode;

// See https://github.com/dotnet/xharness/blob/main/src/Microsoft.DotNet.XHarness.Common/CLI/ExitCode.cs
// 78 - PACKAGE_INSTALLATION_FAILURE
// 81 - DEVICE_NOT_FOUND
// 85 - ADB_DEVICE_ENUMERATION_FAILURE
// 86 - PACKAGE_INSTALLATION_TIMEOUT
if (action == "install" && (exitCode == 78 || exitCode == 81|| exitCode == 85|| exitCode == 86))
{
CreateRetryFile($"{testBinaryBase}/.retry", exitCode, category);
CreateRetryFile($"{testBinaryBase}/.reboot", exitCode, category);
return exitCode;
}

Task.WaitAll(copyOutput, copyError);
}
else
Expand Down Expand Up @@ -155,5 +179,13 @@ private static string ConvertCmd2Arg(string cmd)

return $"{cmdPrefix} \"{cmd}\"";
}

private static void CreateRetryFile(string fileName, int exitCode, string appName)
{
using (StreamWriter writer = new StreamWriter(fileName))
{
writer.WriteLine($"appName: {appName}; exitCode: {exitCode}");
}
}
}
}