hotspot/test/compiler/intrinsics/mathexact/sanity/Verifier.java
changeset 26514 5332d7d44bb0
parent 26513 12198895df07
parent 26497 facbbaaa0ee6
child 26521 03ff40b61e10
equal deleted inserted replaced
26513:12198895df07 26514:5332d7d44bb0
     1 /*
       
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 import java.io.BufferedReader;
       
    25 import java.io.FileReader;
       
    26 import java.util.Properties;
       
    27 
       
    28 public class Verifier {
       
    29 
       
    30     public static void main(String[] args) throws Exception {
       
    31         if (args.length == 0)
       
    32             throw new RuntimeException("Test bug, nothing to verify");
       
    33         for (String hsLogFile : args) {
       
    34             verify(hsLogFile);
       
    35         }
       
    36     }
       
    37 
       
    38     private static void verify(String hsLogFile) throws Exception {
       
    39         System.out.println("Verifying " + hsLogFile);
       
    40 
       
    41         final Properties expectedProperties = new Properties();
       
    42         final FileReader reader = new FileReader(hsLogFile + ".verify.properties");
       
    43         expectedProperties.load(reader);
       
    44         reader.close();
       
    45 
       
    46         int fullMatchCnt = 0;
       
    47         int suspectCnt = 0;
       
    48         final String intrinsicId = expectedProperties.getProperty("intrinsic.name");
       
    49         final String prefix = "<intrinsic id='";
       
    50         final String prefixWithId = prefix + intrinsicId + "'";
       
    51         final int expectedCount = Integer.parseInt(expectedProperties.getProperty("intrinsic.expectedCount"));
       
    52 
       
    53         BufferedReader r = new BufferedReader(new FileReader(hsLogFile));
       
    54         String s;
       
    55         while ((s = r.readLine()) != null) {
       
    56             if (s.startsWith(prefix)) {
       
    57                 if (s.startsWith(prefixWithId)) {
       
    58                     fullMatchCnt++;
       
    59                 } else {
       
    60                     suspectCnt++;
       
    61                     System.out.println("WARNING: Other intrinsic detected " + s);
       
    62                 }
       
    63             }
       
    64         }
       
    65         r.close();
       
    66 
       
    67         System.out.println("Intrinsic " + intrinsicId + " verification, expected: " + expectedCount + ", matched: " + fullMatchCnt + ", suspected: " + suspectCnt);
       
    68         if (expectedCount != fullMatchCnt)
       
    69             throw new RuntimeException("Unexpected count of intrinsic  " + prefixWithId + " expected:" + expectedCount + ", matched: " + fullMatchCnt + ", suspected: " + suspectCnt);
       
    70     }
       
    71 }