mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
maven: Fix build on osx (#6056)
kvm: don't read /proc/meminfo on non-Linux environments as part of constructor Co-authored-by: Nicolas Vazquez <nicovazquez90@gmail.com>
This commit is contained in:
parent
cb872ab6bd
commit
2f6fc56e74
@ -48,8 +48,10 @@ public class MemStat {
|
|||||||
public MemStat(long reservedMemory, long overCommitMemory) {
|
public MemStat(long reservedMemory, long overCommitMemory) {
|
||||||
this.reservedMemory = reservedMemory;
|
this.reservedMemory = reservedMemory;
|
||||||
this.overCommitMemory = overCommitMemory;
|
this.overCommitMemory = overCommitMemory;
|
||||||
|
if (System.getProperty("os.name").equals("Linux")) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public long getTotal() {
|
public long getTotal() {
|
||||||
return _memStats.get(TOTAL_KEY) - reservedMemory + overCommitMemory;
|
return _memStats.get(TOTAL_KEY) - reservedMemory + overCommitMemory;
|
||||||
|
|||||||
@ -5557,6 +5557,9 @@ public class LibvirtComputingResourceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMemoryFreeInKBsDomainReturningOfSomeMemoryStatistics() throws LibvirtException {
|
public void testMemoryFreeInKBsDomainReturningOfSomeMemoryStatistics() throws LibvirtException {
|
||||||
|
if (!System.getProperty("os.name").equals("Linux")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource();
|
LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource();
|
||||||
|
|
||||||
MemoryStatistic[] mem = createMemoryStatisticFreeMemory100();
|
MemoryStatistic[] mem = createMemoryStatisticFreeMemory100();
|
||||||
|
|||||||
@ -46,6 +46,9 @@ public class MemStatTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMemInfoParseTest() {
|
public void getMemInfoParseTest() {
|
||||||
MemStat memStat = new MemStat();
|
MemStat memStat = new MemStat();
|
||||||
|
if (!System.getProperty("os.name").equals("Linux")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Assert.assertEquals(memStat.getTotal(), 5970161664L);
|
Assert.assertEquals(memStat.getTotal(), 5970161664L);
|
||||||
Assert.assertEquals(memStat.getAvailable(), 3164520448L);
|
Assert.assertEquals(memStat.getAvailable(), 3164520448L);
|
||||||
@ -56,6 +59,9 @@ public class MemStatTest {
|
|||||||
@Test
|
@Test
|
||||||
public void reservedMemoryTest() {
|
public void reservedMemoryTest() {
|
||||||
MemStat memStat = new MemStat(1024, 2048);
|
MemStat memStat = new MemStat(1024, 2048);
|
||||||
|
if (!System.getProperty("os.name").equals("Linux")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Assert.assertEquals(memStat.getTotal(), 5970162688L);
|
Assert.assertEquals(memStat.getTotal(), 5970162688L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user