it is possible for an eventlog to have no entries

This commit is contained in:
Doug MacEachern 2007-01-19 17:49:26 +00:00
parent 82f7664068
commit 6586fa8bd2
1 changed files with 7 additions and 5 deletions

View File

@ -92,7 +92,7 @@ public class TestEventLog extends SigarTestCase {
log.close(); log.close();
} }
private boolean readAll(String logname) throws Exception { private int readAll(String logname) throws Exception {
int fail = 0, success = 0, max = 500; int fail = 0, success = 0, max = 500;
String testMax = System.getProperty("sigar.testeventlog.max"); String testMax = System.getProperty("sigar.testeventlog.max");
if (testMax != null) { if (testMax != null) {
@ -125,18 +125,20 @@ public class TestEventLog extends SigarTestCase {
log.close(); log.close();
traceln("success=" + success + ", fail=" + fail); traceln("success=" + success + ", fail=" + fail);
return success > fail; return success;
} }
// Test reading all records // Test reading all records
public void testRead() throws Exception { public void testRead() throws Exception {
int total = 0;
String[] logs = EventLog.getLogNames(); String[] logs = EventLog.getLogNames();
for (int i=0; i<logs.length; i++) { for (int i=0; i<logs.length; i++) {
String msg = "readAll(" + logs[i] + ")"; String msg = "readAll(" + logs[i] + ")";
traceln(msg); traceln(msg);
if (!readAll(logs[i])) { total += readAll(logs[i]);
fail(msg);
} }
if (total == 0) {
fail("No eventlog entries read");
} }
} }