165 osName = "Windows"; |
165 osName = "Windows"; |
166 NSPR_PREFIX = "lib"; |
166 NSPR_PREFIX = "lib"; |
167 } |
167 } |
168 String osid = osName + "-" |
168 String osid = osName + "-" |
169 + props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model"); |
169 + props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model"); |
170 String nssLibDir = osMap.get(osid); |
170 String[] nssLibDirs = osMap.get(osid); |
171 if (nssLibDir == null) { |
171 if (nssLibDirs == null) { |
172 System.out.println("Unsupported OS, skipping: " + osid); |
172 System.out.println("Unsupported OS, skipping: " + osid); |
173 return null; |
173 return null; |
174 // throw new Exception("Unsupported OS " + osName); |
174 } |
175 } |
175 if (nssLibDirs.length == 0) { |
176 if (nssLibDir.length() == 0) { |
|
177 System.out.println("NSS not supported on this platform, skipping test"); |
176 System.out.println("NSS not supported on this platform, skipping test"); |
178 return null; |
177 return null; |
179 } |
178 } |
180 System.setProperty("pkcs11test.nss.libdir", nssLibDir); |
179 String nssLibDir = null; |
|
180 for (String dir : nssLibDirs) { |
|
181 if (new File(dir).exists()) { |
|
182 nssLibDir = dir; |
|
183 System.setProperty("pkcs11test.nss.libdir", nssLibDir); |
|
184 break; |
|
185 } |
|
186 } |
181 return nssLibDir; |
187 return nssLibDir; |
182 } |
188 } |
183 |
189 |
184 protected static void safeReload(String lib) throws Exception { |
190 protected static void safeReload(String lib) throws Exception { |
185 try { |
191 try { |
232 Provider p = getSunPKCS11(p11config); |
238 Provider p = getSunPKCS11(p11config); |
233 test.premain(p); |
239 test.premain(p); |
234 } |
240 } |
235 |
241 |
236 |
242 |
237 private static final Map<String,String> osMap; |
243 private static final Map<String,String[]> osMap; |
238 |
244 |
239 // Location of the NSS libraries on each supported platform |
245 // Location of the NSS libraries on each supported platform |
240 static { |
246 static { |
241 osMap = new HashMap<String,String>(); |
247 osMap = new HashMap<String,String[]>(); |
242 osMap.put("SunOS-sparc-32", "/usr/lib/mps/"); |
248 osMap.put("SunOS-sparc-32", new String[]{"/usr/lib/mps/"}); |
243 osMap.put("SunOS-sparcv9-64", "/usr/lib/mps/64/"); |
249 osMap.put("SunOS-sparcv9-64", new String[]{"/usr/lib/mps/64/"}); |
244 osMap.put("SunOS-x86-32", "/usr/lib/mps/"); |
250 osMap.put("SunOS-x86-32", new String[]{"/usr/lib/mps/"}); |
245 osMap.put("SunOS-amd64-64", "/usr/lib/mps/64/"); |
251 osMap.put("SunOS-amd64-64", new String[]{"/usr/lib/mps/64/"}); |
246 osMap.put("Linux-i386-32", "/usr/lib/"); |
252 osMap.put("Linux-i386-32", new String[]{ |
247 osMap.put("Linux-amd64-64", "/usr/lib64/"); |
253 "/usr/lib/i386-linux-gnu/", "/usr/lib/"}); |
248 osMap.put("Windows-x86-32", |
254 osMap.put("Linux-amd64-64", new String[]{ |
249 PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)); |
255 "/usr/lib/x86_64-linux-gnu/", "/usr/lib64/"}); |
250 osMap.put("Windows-amd64-64", |
256 osMap.put("Windows-x86-32", new String[]{ |
251 PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)); |
257 PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)}); |
|
258 osMap.put("Windows-amd64-64", new String[]{ |
|
259 PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)}); |
252 } |
260 } |
253 |
261 |
254 private final static char[] hexDigits = "0123456789abcdef".toCharArray(); |
262 private final static char[] hexDigits = "0123456789abcdef".toCharArray(); |
255 |
263 |
256 public static String toString(byte[] b) { |
264 public static String toString(byte[] b) { |