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,7 +48,9 @@ public class MemStat {
public MemStat(long reservedMemory, long overCommitMemory) {
this.reservedMemory = reservedMemory;
this.overCommitMemory = overCommitMemory;
this.refresh();
if (System.getProperty("os.name").equals("Linux")) {
this.refresh();
}
}
public long getTotal() {

View File

@ -5557,6 +5557,9 @@ public class LibvirtComputingResourceTest {
@Test
public void testMemoryFreeInKBsDomainReturningOfSomeMemoryStatistics() throws LibvirtException {
if (!System.getProperty("os.name").equals("Linux")) {
return;
}
LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource();
MemoryStatistic[] mem = createMemoryStatisticFreeMemory100();

View File

@ -46,6 +46,9 @@ public class MemStatTest {
@Test
public void getMemInfoParseTest() {
MemStat memStat = new MemStat();
if (!System.getProperty("os.name").equals("Linux")) {
return;
}
Assert.assertEquals(memStat.getTotal(), 5970161664L);
Assert.assertEquals(memStat.getAvailable(), 3164520448L);
@ -56,6 +59,9 @@ public class MemStatTest {
@Test
public void reservedMemoryTest() {
MemStat memStat = new MemStat(1024, 2048);
if (!System.getProperty("os.name").equals("Linux")) {
return;
}
Assert.assertEquals(memStat.getTotal(), 5970162688L);
}
}