Skip to content

Commit be0e5b5

Browse files
committed
skip test that will fail if current user is non-admin
1 parent f10c45b commit be0e5b5

2 files changed

Lines changed: 465 additions & 453 deletions

File tree

contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,16 @@ public void testReportEvent() {
519519
String applicationEventLog = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application";
520520
String jnaEventSource = "JNADevEventSource";
521521
String jnaEventSourceRegistryPath = applicationEventLog + "\\" + jnaEventSource;
522-
Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
522+
// ignore test if not able to create key (need to be administrator to do this).
523+
try {
524+
final boolean keyCreated = Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
525+
if (!keyCreated) {
526+
return;
527+
}
528+
} catch (Win32Exception e) {
529+
return;
530+
}
531+
523532
HANDLE h = Advapi32.INSTANCE.RegisterEventSource(null, jnaEventSource);
524533
IntByReference before = new IntByReference();
525534
assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, before));

0 commit comments

Comments
 (0)