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:
Rohit Yadav 2022-03-07 14:55:42 +05:30 committed by GitHub
parent cb872ab6bd
commit 2f6fc56e74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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);
} }
} }