@@ -2,70 +2,96 @@ import XCTest
22@testable import libhostmgr
33
44final class VMConfigurationTests : XCTestCase {
5+ let min : UInt64 = 4_194_304
6+ let hostReservedRAM : UInt64 = 1024 * 1024 * 4096
57
68 func testThatMemorySizeCalculationsAreValidForUnshared8GBCapacity( ) throws {
7- let min : UInt64 = 4_194_304
89 let max : UInt64 = 8_589_934_592
910 let configuration = try VMConfiguration (
1011 diskImagePath: URL ( fileURLWithPath: " /dev/null " ) ,
1112 macAddress: . randomLocallyAdministered( )
1213 )
1314
14- XCTAssertEqual ( configuration. calculateMemorySize ( min: min, max: max, shared: false ) , 4_294_967_296 )
15+ XCTAssertEqual ( configuration. calculateMemorySize (
16+ min: min,
17+ max: max,
18+ hostReserved: hostReservedRAM,
19+ shared: false
20+ ) , 4_294_967_296 )
1521 }
1622
1723 func testThatMemorySizeCalculationsAreValidForShared8GBCapacity( ) throws {
18- let min : UInt64 = 4_194_304
1924 let max : UInt64 = 8_589_934_592
2025 let configuration = try VMConfiguration (
2126 diskImagePath: URL ( fileURLWithPath: " /dev/null " ) ,
2227 macAddress: . randomLocallyAdministered( )
2328 )
2429
25- XCTAssertEqual ( configuration. calculateMemorySize ( min: min, max: max, shared: true ) , 2_147_483_648 )
30+ XCTAssertEqual ( configuration. calculateMemorySize (
31+ min: min,
32+ max: max,
33+ hostReserved: hostReservedRAM,
34+ shared: true
35+ ) , 2_147_483_648 )
2636 }
2737
2838 func testThatMemorySizeCalculationsAreValidForUnshared16GBCapacity( ) throws {
29- let min : UInt64 = 4_194_304
3039 let max : UInt64 = 17_179_869_184
3140 let configuration = try VMConfiguration (
3241 diskImagePath: URL ( fileURLWithPath: " /dev/null " ) ,
3342 macAddress: . randomLocallyAdministered( )
3443 )
3544
36- XCTAssertEqual ( configuration. calculateMemorySize ( min: min, max: max, shared: false ) , 12_884_901_888 )
45+ XCTAssertEqual ( configuration. calculateMemorySize (
46+ min: min,
47+ max: max,
48+ hostReserved: hostReservedRAM,
49+ shared: false
50+ ) , 12_884_901_888 )
3751 }
3852
3953 func testThatMemorySizeCalculationsAreValidForShared16GBCapacity( ) throws {
40- let min : UInt64 = 4_194_304
4154 let max : UInt64 = 17_179_869_184
4255 let configuration = try VMConfiguration (
4356 diskImagePath: URL ( fileURLWithPath: " /dev/null " ) ,
4457 macAddress: . randomLocallyAdministered( )
4558 )
4659
47- XCTAssertEqual ( configuration. calculateMemorySize ( min: min, max: max, shared: true ) , 6_442_450_944 )
60+ XCTAssertEqual ( configuration. calculateMemorySize (
61+ min: min,
62+ max: max,
63+ hostReserved: hostReservedRAM,
64+ shared: true
65+ ) , 6_442_450_944 )
4866 }
4967
5068 func testThatMemorySizeCalculationsAreValidForUnshared32GBCapacity( ) throws {
51- let min : UInt64 = 4_194_304
5269 let max : UInt64 = 34_359_738_368
5370 let configuration = try VMConfiguration (
5471 diskImagePath: URL ( fileURLWithPath: " /dev/null " ) ,
5572 macAddress: . randomLocallyAdministered( )
5673 )
5774
58- XCTAssertEqual ( configuration. calculateMemorySize ( min: min, max: max, shared: false ) , 30_064_771_072 )
75+ XCTAssertEqual ( configuration. calculateMemorySize (
76+ min: min,
77+ max: max,
78+ hostReserved: hostReservedRAM,
79+ shared: false
80+ ) , 30_064_771_072 )
5981 }
6082
6183 func testThatMemorySizeCalculationsAreValidForShared32GBCapacity( ) throws {
62- let min : UInt64 = 4_194_304
6384 let max : UInt64 = 34_359_738_368
6485 let configuration = try VMConfiguration (
6586 diskImagePath: URL ( fileURLWithPath: " /dev/null " ) ,
6687 macAddress: . randomLocallyAdministered( )
6788 )
6889
69- XCTAssertEqual ( configuration. calculateMemorySize ( min: min, max: max, shared: true ) , 15_032_385_536 )
90+ XCTAssertEqual ( configuration. calculateMemorySize (
91+ min: min,
92+ max: max,
93+ hostReserved: hostReservedRAM,
94+ shared: true
95+ ) , 15_032_385_536 )
7096 }
7197}
0 commit comments