Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Start to modify tests around modified contract
  • Loading branch information
steveisok committed Jun 17, 2024
commit 9fd6e6c53887bd183988ab09dd1e556fd8c2a7a6
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ internal struct host_runtime_contract
public delegate* unmanaged[Stdcall]<byte*, byte*, nint, void*, nint> get_runtime_property;
public delegate* unmanaged[Stdcall]<byte*, nint, nint, nint, byte> bundle_probe;
public IntPtr pinvoke_override;
public delegate* unmanaged[Stdcall]<nuint, void*> get_assemblies;
public delegate* unmanaged[Stdcall]<byte**, nuint> destroy_assemblies;
public delegate* unmanaged[Stdcall]<byte*, void*> resolve_assembly_to_path;
public byte* entry_assembly;
}
#pragma warning restore CS0649

Expand Down
5 changes: 5 additions & 0 deletions src/libraries/externals.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<ItemGroup>
<HostFxrFile Include="$(DotNetHostBinDir)$(LibPrefix)hostfxr$(LibSuffix)" />
<HostPolicyFile Include="$(DotNetHostBinDir)$(LibPrefix)hostpolicy$(LibSuffix)" />
<_HostSymbols Include="$(DotNetHostBinDir)$(LibPrefix)hostfxr$(LibSuffix)$(SymbolsSuffix)" />
<_HostSymbols Include="$(DotNetHostBinDir)$(LibPrefix)hostpolicy$(LibSuffix)$(SymbolsSuffix)" />
<DotnetExe Include="$(DotNetHostBinDir)dotnet$(ExeSuffix)" />
</ItemGroup>

Expand Down Expand Up @@ -82,6 +84,8 @@
<ItemGroup>
<RuntimeFiles Include="@(HostFxrFile)" Condition="Exists('@(HostFxrFile)')" />
<RuntimeFiles Include="@(HostPolicyFile)" Condition="Exists('@(HostPolicyFile)')" />
<RuntimeFiles Include="@(_HostSymbols)" Condition="Exists('@(_HostSymbols)')" IsNative="true" />

<!-- CoreRun is not used for testing anymore, but we still use it for benchmarking and profiling -->
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\corerun*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\corerun*" />
Expand Down Expand Up @@ -120,6 +124,7 @@
<!-- copy the host files to make the desktop samples work -->
<RuntimeFiles Include="@(HostFxrFile)" Condition="Exists('@(HostFxrFile)') and '$(TargetsMobile)' != 'true'"/>
<RuntimeFiles Include="@(HostPolicyFile)" Condition="Exists('@(HostPolicyFile)') and '$(TargetsMobile)' != 'true'" />
<RuntimeFiles Include="@(_HostSymbols)" IsNative="true" Condition="Exists('@(_HostSymbols)') and '$(TargetsMobile)' != 'true'" />
<ReferenceCopyLocalPaths Include="@(RuntimeFiles)" />
<!-- Setup runtime pack native. -->
<ReferenceCopyLocalPaths Include="@(MonoCrossFiles)"
Expand Down
1 change: 0 additions & 1 deletion src/native/corehost/hostpolicy/hostpolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,6 @@ SHARED_API int HOSTPOLICY_CALLTYPE corehost_resolve_component_dependencies(
return StatusCode::HostInvalidState;
}

// TO DO: Think of how resolve_probe_paths changes as a result of looking up paths on the host.
probe_paths_t probe_paths;
std::unique_ptr<name_to_resolved_asset_map_t> host_assemblies = std::unique_ptr<name_to_resolved_asset_map_t>(new name_to_resolved_asset_map_t());
if (!resolver.resolve_probe_paths(&probe_paths, host_assemblies, nullptr, /* ignore_missing_assemblies */ true))
Expand Down
35 changes: 34 additions & 1 deletion src/native/corehost/test/mockcoreclr/mockcoreclr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

#include "mockcoreclr.h"
#include "host_runtime_contract.h"
#include <chrono>
#include <iostream>
#include <thread>
Expand Down Expand Up @@ -44,16 +45,48 @@ SHARED_API pal::hresult_t STDMETHODCALLTYPE coreclr_initialize(
MockLogArg(hostHandle);
MockLogArg(domainId);

host_runtime_contract* host_contract;

for (int i = 0; i < propertyCount; ++i)
{
MockLogEntry("property", propertyKeys[i], propertyValues[i]);
if (strcmp(propertyKeys[i], "HOST_RUNTIME_CONTRACT") == 0)
{
char* endPtr;
uint64_t contractValue = strtoul(propertyValues[i], nullptr, 0);
host_contract = (host_runtime_contract*)contractValue;
}
else
{
MockLogEntry("property", propertyKeys[i], propertyValues[i]);
}
}

if (hostHandle != nullptr)
{
*hostHandle = reinterpret_cast<coreclr_t::host_handle_t>(static_cast<size_t>(0xdeadbeef));
}

if (host_contract != nullptr)
{
// construct the formerly known as TPA list
char** assemblies;
uint32_t assemblyCount = 0;
std::stringstream asmss;

assemblies = host_contract->get_assemblies(&assemblyCount, host_contract->context);

for (int ac = 0; ac < assemblyCount; ac++)
{
const char* assemblyPath = host_contract->resolve_assembly_to_path(assemblies[ac], host_contract->context);
asmss << assemblyPath << ":";
}

delete assemblies;

// for now - name this something else when tests start passing
MockLogEntry("property", "TRUSTED_PLATFORM_ASSEMBLIES", asmss.str());
}

return StatusCode::Success;
}

Expand Down