From bc904b0ef170db1a0dcfd65c0fce525370203cfb Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Thu, 30 Oct 2025 21:03:37 -0400 Subject: [PATCH] Fixes to ensure that the jtreg test is not built or executed if krb5 is not installed --- make/test/JtregNativeJdk.gmk | 16 +++++++++++----- .../security/krb5/native/NativeCacheTest.java | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index b810b073e8f..e2e26c56190 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -110,12 +110,18 @@ ifeq ($(call isTargetOs, linux), true) BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libCreationTimeHelper := -ldl endif -# Kerberos native test library needs krb5 and com_err libraries -BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libNativeCredentialCacheHelper := -lkrb5 -lcom_err +# Kerberos native test library - only build if krb5 is available +ifeq ($(ENABLE_LIBLINUXKRB5), true) + BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libNativeCredentialCacheHelper := $(KRB5_LIBS) + BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libNativeCredentialCacheHelper := $(KRB5_CFLAGS) -ifeq ($(call isTargetOs, macosx), true) - # On macOS, disable deprecation warnings for krb5 API - BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libNativeCredentialCacheHelper := -Wno-deprecated-declarations + ifeq ($(call isTargetOs, macosx), true) + # On macOS, disable deprecation warnings for krb5 API + BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libNativeCredentialCacheHelper += -Wno-deprecated-declarations + endif +else + # Exclude the Kerberos test library if krb5 is not available + BUILD_JDK_JTREG_EXCLUDE += libNativeCredentialCacheHelper.c endif ifeq ($(ASAN_ENABLED), true) diff --git a/test/jdk/sun/security/krb5/native/NativeCacheTest.java b/test/jdk/sun/security/krb5/native/NativeCacheTest.java index 54760427694..741d19d081c 100644 --- a/test/jdk/sun/security/krb5/native/NativeCacheTest.java +++ b/test/jdk/sun/security/krb5/native/NativeCacheTest.java @@ -80,6 +80,9 @@ public class NativeCacheTest { // Test JAAS access to in-memory cache testJAASAccessToInMemoryCache(inMemoryCacheName); + } catch (UnsatisfiedLinkError e) { + System.out.println("Kerberos native library not available - test skipped"); + return; } catch (Exception e) { System.err.println("Test failed: " + e.getMessage()); throw e;