-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #28: Add support for NetBSD on macOS runners
- Loading branch information
1 parent
24f8268
commit c6ffabb
Showing
9 changed files
with
221 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import NetBsd from '../../../src/operating_systems/netbsd/netbsd' | ||
import * as hostModule from '../../../src/host' | ||
import * as arch from '../../../src/architecture' | ||
import * as os from '../../../src/operating_systems/kind' | ||
import {Accelerator} from '../../../src/vm' | ||
import HostQemu from '../../../src/host_qemu' | ||
import * as hypervisor from '../../../src/hypervisor' | ||
import * as qemu from '../../../src/qemu_vm' | ||
import * as xhyve from '../../../src/xhyve_vm' | ||
import * as netbsdQemuVm from '../../../src/operating_systems/netbsd/qemu_vm' | ||
|
||
describe('NetBSD OperatingSystem', () => { | ||
class Host extends hostModule.Host { | ||
get workDirectory(): string { | ||
return '/home/runner/work' | ||
} | ||
|
||
get vmModule(): typeof xhyve | typeof qemu { | ||
return qemu | ||
} | ||
|
||
override get qemu(): HostQemu { | ||
return new HostQemu.LinuxHostQemu() | ||
} | ||
|
||
override get hypervisor(): hypervisor.Hypervisor { | ||
return new hypervisor.Qemu() | ||
} | ||
|
||
override get efiHypervisor(): hypervisor.Hypervisor { | ||
return new hypervisor.QemuEfi() | ||
} | ||
|
||
override get defaultMemory(): string { | ||
return '6G' | ||
} | ||
|
||
override get defaultCpuCount(): number { | ||
return 6 | ||
} | ||
} | ||
|
||
let host = new Host() | ||
let osKind = os.Kind.for('netbsd') | ||
let architecture = arch.Architecture.for(arch.Kind.x86_64, host, osKind) | ||
let netbsd = new NetBsd(architecture, '0.0.0') | ||
let hypervisorDirectory = 'hypervisor/directory' | ||
let resourcesDirectory = 'resources/directory' | ||
let firmwareDirectory = 'firmware/directory' | ||
|
||
let config = { | ||
memory: '4G', | ||
cpuCount: 7, | ||
diskImage: '', | ||
resourcesDiskImage: '', | ||
userboot: '' | ||
} | ||
|
||
describe('createVirtualMachine', () => { | ||
it('creates a virtual machine with the correct configuration', () => { | ||
let qemuVmSpy = spyOn(netbsdQemuVm, 'Vm') | ||
|
||
netbsd.createVirtualMachine( | ||
hypervisorDirectory, | ||
resourcesDirectory, | ||
firmwareDirectory, | ||
config | ||
) | ||
|
||
expect(qemuVmSpy).toHaveBeenCalledOnceWith( | ||
hypervisorDirectory, | ||
resourcesDirectory, | ||
architecture, | ||
{ | ||
...config, | ||
ssHostPort: 2847, | ||
cpu: 'qemu64', | ||
accelerator: Accelerator.tcg, | ||
machineType: 'pc', | ||
uuid: '864ED7F0-7876-4AA7-8511-816FABCFA87F', | ||
firmware: `${firmwareDirectory}/share/qemu/bios-256k.bin` | ||
} | ||
) | ||
}) | ||
|
||
describe('when on a macOS host', () => { | ||
class Host extends hostModule.Host { | ||
get workDirectory(): string { | ||
return '/Users/runner/work' | ||
} | ||
|
||
get vmModule(): typeof xhyve | typeof qemu { | ||
return xhyve | ||
} | ||
|
||
override get qemu(): HostQemu { | ||
return new HostQemu.MacosHostQemu() | ||
} | ||
|
||
override get hypervisor(): hypervisor.Hypervisor { | ||
return new hypervisor.Xhyve() | ||
} | ||
|
||
override get efiHypervisor(): hypervisor.Hypervisor { | ||
return this.hypervisor | ||
} | ||
|
||
override get defaultMemory(): string { | ||
return '13G' | ||
} | ||
|
||
override get defaultCpuCount(): number { | ||
return 3 | ||
} | ||
} | ||
|
||
let host = new Host() | ||
let osKind = os.Kind.for('netbsd') | ||
let architecture = arch.Architecture.for(arch.Kind.x86_64, host, osKind) | ||
let netbsd = new NetBsd(architecture, '0.0.0') | ||
|
||
it('creates a virtual machine configured with BIOS firmware', () => { | ||
let qemuVmSpy = spyOn(netbsdQemuVm, 'Vm') | ||
|
||
netbsd.createVirtualMachine( | ||
hypervisorDirectory, | ||
resourcesDirectory, | ||
firmwareDirectory, | ||
config | ||
) | ||
|
||
expect(qemuVmSpy).toHaveBeenCalledOnceWith( | ||
hypervisorDirectory, | ||
resourcesDirectory, | ||
architecture, | ||
{ | ||
...config, | ||
ssHostPort: 2847, | ||
cpu: 'host', | ||
accelerator: Accelerator.hvf, | ||
machineType: 'pc', | ||
uuid: '864ED7F0-7876-4AA7-8511-816FABCFA87F', | ||
firmware: `${firmwareDirectory}/share/qemu/bios-256k.bin` | ||
} | ||
) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {Vm} from '../../../src/operating_systems/netbsd/qemu_vm' | ||
import * as arch from '../../../src/architecture' | ||
import {host} from '../../../src/host' | ||
import * as os from '../../../src/operating_systems/kind' | ||
import {Accelerator} from '../../../src/vm' | ||
import '../../../src/operating_systems/netbsd/netbsd' | ||
|
||
describe('NetBSD QemuVm', () => { | ||
let memory = '5G' | ||
let cpuCount = 10 | ||
|
||
let osKind = os.Kind.for('netbsd') | ||
let architecture = arch.Architecture.for(arch.Kind.x86_64, host, osKind) | ||
let config = { | ||
memory: memory, | ||
cpuCount: cpuCount, | ||
diskImage: '', | ||
ssHostPort: 0, | ||
cpu: '', | ||
accelerator: Accelerator.tcg, | ||
machineType: '', | ||
uuid: '', | ||
resourcesDiskImage: '', | ||
userboot: '', | ||
firmware: '' | ||
} | ||
let vm = new Vm('', '', architecture, config) | ||
|
||
let getFlagValue = (flag: string) => vm.command[vm.command.indexOf(flag) + 1] | ||
let actualMemory = () => getFlagValue('-m') | ||
let actualSmp = () => getFlagValue('-smp') | ||
|
||
describe('command', () => { | ||
it('constucts a command with the correct memory configuration', () => { | ||
expect(actualMemory()).toEqual(memory) | ||
}) | ||
|
||
it('constucts a command with the correct SMP configuration', () => { | ||
expect(actualSmp()).toEqual(cpuCount.toString()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters