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
21 changes: 10 additions & 11 deletions src/installer/test/Assets/TestProjects/BundleProbeTester/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ namespace BundleProbeTester
{
public static class Program
{
// The return type on BundleProbeDelegate is byte instead of bool because
// using non-blitable bool type caused a failure (incorrect value) on linux-musl-x64.
// The bundle-probe callback is only called from native code in the product
// Therefore the type on this test is adjusted to circumvent the failure.
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool BundleProbeDelegate([MarshalAs(UnmanagedType.LPWStr)] string path, IntPtr size, IntPtr offset);
public delegate byte BundleProbeDelegate([MarshalAs(UnmanagedType.LPWStr)] string path, IntPtr size, IntPtr offset);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ok to be LPWstr or should become IntPtr?
If the goal is to inline or avoid a stub, can that happen if the call needs to pin the string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the LPWstr is OK.
I spoke with @jkoritzinsky about this today, looks like the problem was wrt managed bool vs native bool values in the return type. Please see: #36372.


unsafe static bool Probe(BundleProbeDelegate bundleProbe, string path, bool isExpected)
{
Int64 size, offset;
bool exists = bundleProbe(path, (IntPtr)(&offset), (IntPtr)(&size));
bool exists = bundleProbe(path, (IntPtr)(&offset), (IntPtr)(&size)) != 0;

switch (exists, isExpected)
{
Expand All @@ -39,8 +43,6 @@ unsafe static bool Probe(BundleProbeDelegate bundleProbe, string path, bool isEx
case (false, false):
return true;
}

return false; // dummy
}

public static int Main(string[] args)
Expand Down Expand Up @@ -72,13 +74,10 @@ public static int Main(string[] args)
bool success =
Probe(bundleProbeDelegate, "BundleProbeTester.dll", isExpected: true) &&
Probe(bundleProbeDelegate, "BundleProbeTester.runtimeconfig.json", isExpected: true) &&
Probe(bundleProbeDelegate, "System.Private.CoreLib.dll", isExpected: true);
// The following test is failing on Linux-musl-x64-release.
// The test is temporarily disabled to keep rolling builds green until the bug is fixed.
// https://github.com/dotnet/runtime/issues/35755
// Probe(bundleProbeDelegate, "hostpolicy.dll", isExpected: false) &&
// Probe(bundleProbeDelegate, "--", isExpected: false) &&
// Probe(bundleProbeDelegate, "", isExpected: false);
Probe(bundleProbeDelegate, "System.Private.CoreLib.dll", isExpected: true) &&
Probe(bundleProbeDelegate, "hostpolicy.dll", isExpected: false) &&
Probe(bundleProbeDelegate, "--", isExpected: false) &&
Probe(bundleProbeDelegate, "", isExpected: false);

if (!success)
{
Expand Down