跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

new-windows-test-vm.tests.ps1

33 行 · 1.4 KB历史下载
1#requires -Version 5.1
2# Simulate a Hyper-V host which defaults to dynamic memory on New-VM.
3$ErrorActionPreference = 'Stop'
4$path = Join-Path $PSScriptRoot 'new-windows-test-vm.ps1'
5$errors = $null
6$ast = [Management.Automation.Language.Parser]::ParseFile($path, [ref]$null, [ref]$errors)
7if ($errors.Count) { throw $errors[0] }
8$function = $ast.Find({
9 param($node)
10 $node -is [Management.Automation.Language.FunctionDefinitionAst] -and $node.Name -eq 'Set-TestVMResources'
11}, $true)
12. ([scriptblock]::Create($function.Extent.Text))
13
14$vm = [pscustomobject]@{ DynamicMemoryEnabled = $true; Startup = 4GB }
15function Set-VM {
16 param($VM, $ProcessorCount, [switch]$StaticMemory, $MemoryStartupBytes, $AutomaticStartAction, $AutomaticCheckpointsEnabled)
17 if (!$script:ignoreStaticMode -and $StaticMemory) { $VM.DynamicMemoryEnabled = $false }
18 $VM.Startup = $MemoryStartupBytes
19}
20function Get-VMMemory { param($VM) $VM }
21Set-TestVMResources $vm 4 8GB
22if ($vm.DynamicMemoryEnabled -or $vm.Startup -ne 8GB) { throw 'Guest can exceed the requested memory.' }
23
24$vm.DynamicMemoryEnabled = $true
25$script:ignoreStaticMode = $true
26try {
27 Set-TestVMResources $vm 4 8GB
28} catch {
29 if (!$_.Exception.Message.Contains('requested fixed budget')) { throw }
30 Write-Output 'Passed fixed guest memory budgeting and rejection of inconsistent Hyper-V readback.'
31 return
32}
33throw 'Ignored static-memory request was reported as successful.'