|
| 1 | +/* |
| 2 | + * Copyright Amazon.com Inc. 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 | +package com.sun.hotspot.tools.compiler; |
| 25 | + |
| 26 | +import org.junit.Assert; |
| 27 | +import org.junit.Test; |
| 28 | +import org.junit.runner.RunWith; |
| 29 | +import org.junit.runners.Parameterized; |
| 30 | +import org.junit.runners.Parameterized.Parameters; |
| 31 | + |
| 32 | +import java.io.File; |
| 33 | +import java.io.FilenameFilter; |
| 34 | +import java.util.ArrayList; |
| 35 | +import java.util.Collection; |
| 36 | +import java.util.List; |
| 37 | + |
| 38 | +@RunWith(value = Parameterized.class) |
| 39 | +public class TestPrebuiltLogs { |
| 40 | + private String logFile; |
| 41 | + static List<String> tests = new ArrayList<String>(); |
| 42 | + |
| 43 | + // BeforeClass is invoked after @Parameters, so we use static block to evaluate tests first. |
| 44 | + static { |
| 45 | + File file = new File("src/test/resources"); |
| 46 | + File[] testData = file.listFiles(new FilenameFilter() { |
| 47 | + @Override |
| 48 | + public boolean accept(File dir, String name) { |
| 49 | + return name.endsWith(".xml"); |
| 50 | + } |
| 51 | + }); |
| 52 | + |
| 53 | + for (File f: testData) { |
| 54 | + tests.add(f.toString()); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + @Parameters |
| 59 | + public static Collection data() { |
| 60 | + return tests; |
| 61 | + } |
| 62 | + |
| 63 | + public TestPrebuiltLogs(String logFile) { |
| 64 | + this.logFile = logFile; |
| 65 | + } |
| 66 | + |
| 67 | + void doItOrFail(String[] args) { |
| 68 | + try { |
| 69 | + LogCompilation.main(args); |
| 70 | + } catch (Throwable e) { |
| 71 | + e.printStackTrace(); |
| 72 | + Assert.fail(e.getMessage()); |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + @Test |
| 77 | + public void testDashi() throws Exception { |
| 78 | + String[] args = {"-i", logFile}; |
| 79 | + doItOrFail(args); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void testNone() throws Exception { |
| 84 | + String[] args = {logFile}; |
| 85 | + doItOrFail(args); |
| 86 | + } |
| 87 | +} |
0 commit comments