changeset 13314:93ed62498ddc

8194864: Outputs more details for PKCS11 tests if the NSS lib version cannot be determined Summary: It outputs the lib content if the lib version cannot be parsed Reviewed-by: xuelei
author igerasim
date Tue, 23 Oct 2018 11:29:39 -0700
parents d08372424e32
children 76696e5fbe49
files test/sun/security/pkcs11/PKCS11Test.java
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/security/pkcs11/PKCS11Test.java	Mon Oct 22 15:20:49 2018 +0000
+++ b/test/sun/security/pkcs11/PKCS11Test.java	Tue Oct 23 11:29:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -270,7 +270,9 @@
     }
 
     static double getNSSInfo(String library) {
-        String nssHeader = "$Header: NSS";
+        // look for two types of headers in NSS libraries
+        String nssHeader1 = "$Header: NSS";
+        String nssHeader2 = "Version: NSS";
         boolean found = false;
         String s = null;
         int i = 0;
@@ -298,7 +300,8 @@
                 }
 
                 s = new String(data, 0, read);
-                if ((i = s.indexOf(nssHeader)) > 0) {
+                i = s.indexOf(nssHeader1);
+                if (i > 0 || (i = s.indexOf(nssHeader2)) > 0) {
                     found = true;
                     // If the nssHeader is before 920 we can break, otherwise
                     // we may not have the whole header so do another read.  If
@@ -324,7 +327,17 @@
 
         // the index after whitespace after nssHeader
         int afterheader = s.indexOf("NSS", i) + 4;
-        String version = s.substring(afterheader, s.indexOf(' ', afterheader));
+        int nextSpaceIndex = s.indexOf(' ', afterheader);
+
+        // If the next space is not found,
+        // it has to print the content for further investigation.
+        if (nextSpaceIndex == -1) {
+            System.out.println("===== Content start =====");
+            System.out.println(s);
+            System.out.println("===== Content end =====");
+        }
+
+        String version = s.substring(afterheader, nextSpaceIndex);
 
         // If a "dot dot" release, strip the extra dots for double parsing
         String[] dot = version.split("\\.");