include win32 tests
This commit is contained in:
parent
b65a58609f
commit
3d89246fef
|
@ -18,9 +18,6 @@ import org.apache.log4j.PropertyConfigurator;
|
|||
|
||||
public class SigarTestPrinter extends ResultPrinter {
|
||||
|
||||
private static String PACKAGE_NAME =
|
||||
SigarTestCase.class.getPackage().getName();
|
||||
|
||||
private HashMap failures = new HashMap();
|
||||
private int maxNameLen = 0;
|
||||
|
||||
|
@ -105,6 +102,18 @@ public class SigarTestPrinter extends ResultPrinter {
|
|||
suite.addTestSuite(test);
|
||||
}
|
||||
|
||||
private static Class findTest(Class[] tests, String name) {
|
||||
String tname = "Test" + name;
|
||||
|
||||
for (int i=0; i<tests.length; i++) {
|
||||
if (tests[i].getName().endsWith(tname)) {
|
||||
return tests[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void runTests(Class[] tests, String[] args) {
|
||||
TestSuite suite = new TestSuite("Sigar tests");
|
||||
|
||||
|
@ -124,13 +133,12 @@ public class SigarTestPrinter extends ResultPrinter {
|
|||
SigarTestCase.setWriter(printer.getWriter());
|
||||
|
||||
for (int i=0; i<args.length; i++) {
|
||||
Class test;
|
||||
try {
|
||||
test = Class.forName(PACKAGE_NAME + ".Test" + args[i]);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Class test = findTest(tests, args[i]);
|
||||
if (test == null) {
|
||||
String msg = "Invalid test: " + args[i];
|
||||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
|
||||
addTest(printer, suite, test);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,24 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
|
||||
import net.hyperic.sigar.SigarException;
|
||||
import net.hyperic.sigar.SigarLoader;
|
||||
|
||||
import net.hyperic.sigar.cmd.SigarCommandBase;
|
||||
import net.hyperic.sigar.cmd.Shell;
|
||||
|
||||
import net.hyperic.sigar.win32.test.TestEventLog;
|
||||
import net.hyperic.sigar.win32.test.TestMetaBase;
|
||||
import net.hyperic.sigar.win32.test.TestPdh;
|
||||
import net.hyperic.sigar.win32.test.TestRegistryKey;
|
||||
import net.hyperic.sigar.win32.test.TestService;
|
||||
|
||||
public class SigarTestRunner extends SigarCommandBase {
|
||||
|
||||
private Collection completions;
|
||||
|
||||
private static final Class[] TESTS = {
|
||||
private static final Class[] TESTS;
|
||||
|
||||
private static final Class[] ALL_TESTS = {
|
||||
TestLog.class,
|
||||
TestInvoker.class,
|
||||
TestPTQL.class,
|
||||
|
@ -39,6 +48,27 @@ public class SigarTestRunner extends SigarCommandBase {
|
|||
TestUptime.class,
|
||||
};
|
||||
|
||||
private static final Class[] WIN32_TESTS = {
|
||||
TestEventLog.class,
|
||||
TestPdh.class,
|
||||
TestMetaBase.class,
|
||||
TestRegistryKey.class,
|
||||
TestService.class,
|
||||
};
|
||||
|
||||
static {
|
||||
if (SigarLoader.IS_WIN32) {
|
||||
TESTS = new Class[ALL_TESTS.length + WIN32_TESTS.length];
|
||||
System.arraycopy(ALL_TESTS, 0, TESTS,
|
||||
0, ALL_TESTS.length);
|
||||
System.arraycopy(WIN32_TESTS, 0, TESTS,
|
||||
ALL_TESTS.length, WIN32_TESTS.length);
|
||||
}
|
||||
else {
|
||||
TESTS = ALL_TESTS;
|
||||
}
|
||||
}
|
||||
|
||||
public SigarTestRunner(Shell shell) {
|
||||
super(shell);
|
||||
|
||||
|
|
Loading…
Reference in New Issue