提交 b3d08868 编写于 作者: V vinnie

7152582: PKCS11 tests should use the NSS libraries available in the OS

Reviewed-by: mullan
上级 814d2ffe
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -129,6 +129,13 @@ public abstract class PKCS11Test { ...@@ -129,6 +129,13 @@ public abstract class PKCS11Test {
} }
private static String PKCS11_BASE; private static String PKCS11_BASE;
static {
try {
PKCS11_BASE = getBase();
} catch (Exception e) {
// ignore
}
}
private final static String PKCS11_REL_PATH = "sun/security/pkcs11"; private final static String PKCS11_REL_PATH = "sun/security/pkcs11";
...@@ -160,20 +167,18 @@ public abstract class PKCS11Test { ...@@ -160,20 +167,18 @@ public abstract class PKCS11Test {
} }
String osid = osName + "-" String osid = osName + "-"
+ props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model"); + props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model");
String ostype = osMap.get(osid); String nssLibDir = osMap.get(osid);
if (ostype == null) { if (nssLibDir == null) {
System.out.println("Unsupported OS, skipping: " + osid); System.out.println("Unsupported OS, skipping: " + osid);
return null; return null;
// throw new Exception("Unsupported OS " + osid); // throw new Exception("Unsupported OS " + osName);
} }
if (ostype.length() == 0) { if (nssLibDir.length() == 0) {
System.out.println("NSS not supported on this platform, skipping test"); System.out.println("NSS not supported on this platform, skipping test");
return null; return null;
} }
String base = getBase(); System.setProperty("pkcs11test.nss.libdir", nssLibDir);
String libdir = base + SEP + "nss" + SEP + "lib" + SEP + ostype + SEP; return nssLibDir;
System.setProperty("pkcs11test.nss.libdir", libdir);
return libdir;
} }
protected static void safeReload(String lib) throws Exception { protected static void safeReload(String lib) throws Exception {
...@@ -191,6 +196,8 @@ public abstract class PKCS11Test { ...@@ -191,6 +196,8 @@ public abstract class PKCS11Test {
safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4")); safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4"));
safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4")); safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4"));
safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4")); safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4"));
safeReload(libdir + System.mapLibraryName("sqlite3"));
safeReload(libdir + System.mapLibraryName("nssutil3"));
return true; return true;
} }
...@@ -229,15 +236,15 @@ public abstract class PKCS11Test { ...@@ -229,15 +236,15 @@ public abstract class PKCS11Test {
private static final Map<String,String> osMap; private static final Map<String,String> osMap;
// Location of the NSS libraries on each supported platform
static { static {
osMap = new HashMap<String,String>(); osMap = new HashMap<String,String>();
osMap.put("SunOS-sparc-32", "solaris-sparc"); osMap.put("SunOS-sparc-32", "/usr/lib/mps/");
osMap.put("SunOS-sparcv9-64", "solaris-sparcv9"); osMap.put("SunOS-sparcv9-64", "/usr/lib/mps/64/");
osMap.put("SunOS-x86-32", "solaris-i586"); osMap.put("SunOS-x86-32", "/usr/lib/mps/");
osMap.put("SunOS-amd64-64", "solaris-amd64"); osMap.put("SunOS-amd64-64", "/usr/lib/mps/64/");
osMap.put("Linux-i386-32", "linux-i586"); osMap.put("Linux-i386-32", "/usr/lib/");
osMap.put("Linux-amd64-64", "linux-amd64"); osMap.put("Linux-amd64-64", "/usr/lib64/");
osMap.put("Windows-x86-32", "windows-i586");
} }
private final static char[] hexDigits = "0123456789abcdef".toCharArray(); private final static char[] hexDigits = "0123456789abcdef".toCharArray();
......
# #
# Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -50,7 +50,7 @@ case "$OS" in ...@@ -50,7 +50,7 @@ case "$OS" in
ARCH=`isainfo` ARCH=`isainfo`
case "$ARCH" in case "$ARCH" in
sparc* ) sparc* )
PF="solaris-sparc" NSSDIR="/usr/lib/mps"
;; ;;
* ) * )
echo "Will not run test on: Solaris ${ARCH}" echo "Will not run test on: Solaris ${ARCH}"
...@@ -64,7 +64,7 @@ case "$OS" in ...@@ -64,7 +64,7 @@ case "$OS" in
FS="/" FS="/"
case "$ARCH" in case "$ARCH" in
i[3-6]86 ) i[3-6]86 )
PF="linux-i586" NSSDIR="/usr/lib"
;; ;;
* ) * )
echo "Will not run test on: Linux ${ARCH}" echo "Will not run test on: Linux ${ARCH}"
...@@ -91,7 +91,7 @@ chmod u+w key3.db ...@@ -91,7 +91,7 @@ chmod u+w key3.db
chmod u+w cert8.db chmod u+w cert8.db
echo | ${TESTJAVA}${FS}bin${FS}java -Dnss \ echo | ${TESTJAVA}${FS}bin${FS}java -Dnss \
-Dnss.lib=${NSS}${FS}lib${FS}${PF}${FS}${LIBNAME} \ -Dnss.lib=${NSSDIR}${FS}${LIBNAME} \
KeyToolTest KeyToolTest
status=$? status=$?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册