< prev index next >

test/hotspot/jtreg/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java

Print this page


   1 /*
   2  * Copyright (c) 2016, 2017, 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 jdk.test.lib.cds.CDSTestUtils;
  25 import jdk.test.lib.process.OutputAnalyzer;

  26 
  27 
  28 // This class contains methods common to all transformation test cases
  29 public class TransformTestCommon {
  30 
  31     // get parameters to an agent depending on the test case
  32     // these parameters will instruct the agent which classes should be
  33     // transformed
  34     public static String getAgentParams(TestEntry entry,
  35                                         String parent, String child) {
  36 
  37         if (entry.transformParent && entry.transformChild)
  38             return parent + "," + child;
  39         if (entry.transformParent)
  40             return parent;
  41         if (entry.transformChild)
  42             return child;
  43 
  44         return "";
  45     }


  84                                                   String parent, String child)
  85         throws Exception {
  86 
  87         String patternBase = "TransformerAgent: SimpleTransformer called for: ";
  88 
  89         out.shouldContain(patternBase + child + "@1");
  90         out.shouldContain(patternBase + parent + "@1");
  91 
  92         out.shouldNotContain(patternBase + child + "@2");
  93         out.shouldNotContain(patternBase + parent + "@2");
  94     }
  95 
  96 
  97     public static void checkResults(TestEntry entry, OutputAnalyzer out,
  98                                     String parent, String child)
  99         throws Exception {
 100 
 101         // If we were not able to map an archive,
 102         // then do not perform other checks, since
 103         // there was no sharing at all
 104         if (CDSTestUtils.isUnableToMap(out))
 105             return;


 106 
 107         String childVmName = child.replace('.', '/');
 108         String parentVmName = parent.replace('.', '/');
 109 
 110         CDSTestUtils.checkExec(out);
 111         checkTransformationCounts(entry, out, parentVmName, childVmName);
 112         checkTransformationResults(entry, out);
 113         checkSharingByClass(entry, out, parent, child);
 114     }
 115 }
   1 /*
   2  * Copyright (c) 2016, 2018, 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 jdk.test.lib.cds.CDSTestUtils;
  25 import jdk.test.lib.process.OutputAnalyzer;
  26 import jtreg.SkippedException;
  27 
  28 
  29 // This class contains methods common to all transformation test cases
  30 public class TransformTestCommon {
  31 
  32     // get parameters to an agent depending on the test case
  33     // these parameters will instruct the agent which classes should be
  34     // transformed
  35     public static String getAgentParams(TestEntry entry,
  36                                         String parent, String child) {
  37 
  38         if (entry.transformParent && entry.transformChild)
  39             return parent + "," + child;
  40         if (entry.transformParent)
  41             return parent;
  42         if (entry.transformChild)
  43             return child;
  44 
  45         return "";
  46     }


  85                                                   String parent, String child)
  86         throws Exception {
  87 
  88         String patternBase = "TransformerAgent: SimpleTransformer called for: ";
  89 
  90         out.shouldContain(patternBase + child + "@1");
  91         out.shouldContain(patternBase + parent + "@1");
  92 
  93         out.shouldNotContain(patternBase + child + "@2");
  94         out.shouldNotContain(patternBase + parent + "@2");
  95     }
  96 
  97 
  98     public static void checkResults(TestEntry entry, OutputAnalyzer out,
  99                                     String parent, String child)
 100         throws Exception {
 101 
 102         // If we were not able to map an archive,
 103         // then do not perform other checks, since
 104         // there was no sharing at all
 105         if (CDSTestUtils.isUnableToMap(out)) {
 106             throw new SkippedException(CDSTestUtils.UnableToMapMsg);
 107         }
 108 
 109 
 110         String childVmName = child.replace('.', '/');
 111         String parentVmName = parent.replace('.', '/');
 112 
 113         CDSTestUtils.checkExec(out);
 114         checkTransformationCounts(entry, out, parentVmName, childVmName);
 115         checkTransformationResults(entry, out);
 116         checkSharingByClass(entry, out, parent, child);
 117     }
 118 }
< prev index next >