test/script/currently-failing/logcoverage.js

Fri, 03 May 2013 15:33:54 +0200

author
lagergren
date
Fri, 03 May 2013 15:33:54 +0200
changeset 247
5a3f7867e19c
parent 237
test/script/trusted/logcoverage.js@ad28f2b52b12
child 279
1fd18f40ab52
permissions
-rw-r--r--

8013477: Node.setSymbol needs to be copy on write - enable IR snapshots for recompilation based on callsite type specialization. [not enabled by default, hidden by a flag for now]
Reviewed-by: jlaskey, hannesw

     1 /*
     2  * Copyright (c) 2010, 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  */
    24 /**
    25  * mh_coverage.js
    26  * Screen scrape various logs to ensure that we cover enough functionality, 
    27  * e.g. method handle instrumentation
    28  *
    29  * @test
    30  * @run
    31  */
    33 /*
    34  * creates new script engine initialized with given options and
    35  * runs given code on it. Returns standard output captured.
    36  */
    38 function runScriptEngine(opts, name) {
    39     var imports = new JavaImporter(
    40         Packages.jdk.nashorn.api.scripting,
    41         java.io, java.lang, java.util);
    43     with(imports) {
    44         var fac = new NashornScriptEngineFactory();
    45         // get current System.err
    46         var oldErr = System.err;
    47 	var oldOut = System.out;
    48         var baosErr = new ByteArrayOutputStream();
    49         var newErr = new PrintStream(baosErr);
    50         var baosOut = new ByteArrayOutputStream();
    51 	var newOut = new PrintStream(baosOut);
    52         try {
    53             // set new standard err
    54             System.setErr(newErr);
    55             System.setOut(newOut);
    56             var strType = Java.type("java.lang.String");
    57             var engine = fac.getScriptEngine(Java.toJavaArray(opts, strType));
    58 	    var reader = new java.io.FileReader(name);
    59             engine.eval(reader);
    60             newErr.flush();
    61 	    newOut.flush();
    62             return new java.lang.String(baosErr.toByteArray());
    63         } finally {
    64             // restore System.err to old value
    65             System.setErr(oldErr);
    66 	    System.setOut(oldOut);
    67         }
    68     }
    69 }
    71 var str;
    73 var methodsCalled = [
    74    'asCollector', 
    75    'asType', 
    76    'bindTo', 
    77    'dropArguments', 
    78    'explicitCastArguments', 
    79    'filterArguments', 
    80    'filterReturnValue', 
    81    'findStatic', 
    82    'findVirtual',  
    83    'foldArguments', 
    84    'getter', 
    85    'guardWithTest', 
    86    'insertArguments', 
    87    'methodType', 
    88    'setter'
    89 ];
    91 function check(str, strs) {
    92     for each (s in strs) {
    93        if (str.indexOf(s) !== -1) {
    94 	   continue;
    95        }
    96        print(s + " not found");
    97        return;
    98     }
    99     print("check ok!");
   100 }
   102 str = runScriptEngine([ "--log=codegen,compiler=finest,methodhandles=finest,fields=finest" ], __DIR__ + "../basic/NASHORN-19.js");
   103 str += runScriptEngine([ "--log=codegen,compiler=finest,methodhandles=finest,fields=finest" ], __DIR__ + "../basic/varargs.js");
   105 check(str, methodsCalled);
   106 check(str, ['return', 'get', 'set', '[fields]']);
   107 check(str, ['codegen']);
   109 print("hello, world!");

mercurial