001/* Run the Ptolemy model tests in the auto/ directory using cg code generation under JUnit. 002 003 Copyright (c) 2011-2016 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028 029package ptolemy.util.test.junit; 030 031import org.junit.Before; 032import org.junit.Test; 033import org.junit.runner.RunWith; 034 035import junitparams.JUnitParamsRunner; 036import junitparams.Parameters; 037 038/////////////////////////////////////////////////////////////////// 039//// AutoCGJavaTests 040 041/** 042 * Run the Ptolemy model tests in the auto/ directory using cg code generation 043 * under JUnit. 044 * 045 * <p> 046 * This test must be run from the directory that contains the auto/ directory, 047 * for example: 048 * </p> 049 * 050 * <pre> 051 * (cd ptolemy/cg/adapter/generic/program/procedural/java/adapters/ptolemy/actor/lib/test; java -classpath ${PTII}:${PTII}/lib/junit-4.8.2.jar:${PTII}/lib/JUnitParams-0.3.0.jar org.junit.runner.JUnitCore ptolemy.util.test.junit.AutoCGJavaTests) 052 * </pre> 053 * 054 * <p> 055 * This test uses JUnitParams from <a 056 * href="http://code.google.com/p/junitparams/#in_browser" 057 * >http://code.google.com/p/junitparams/</a>, which is released under <a 058 * href="http://www.apache.org/licenses/LICENSE-2.0#in_browser">Apache License 059 * 2.0</a>. 060 * </p> 061 * 062 * @author Christopher Brooks 063 * @version $Id$ 064 * @since Ptolemy II 10.0 065 * @Pt.ProposedRating Red (cxh) 066 * @Pt.AcceptedRating Red (cxh) 067 */ 068@RunWith(JUnitParamsRunner.class) 069public class AutoCGJavaTests extends AutoCGTests { 070 071 /** 072 * Find the ptolemy.cg.kernel.generic.GenericCodeGenerator class 073 * and its generateCode static method that takes an array of 074 * strings. 075 * 076 * @exception Throwable If the class or constructor cannot be found. 077 */ 078 @Override 079 @Before 080 public void setUp() throws Throwable { 081 super.setUp(); 082 } 083 084 /** 085 * Generate, compile and run inline code for a model. 086 * 087 * @param fullPath The full path to the model file to be 088 * executed. If the fullPath ends with the value of the {@link 089 * #THERE_ARE_NO_AUTO_TESTS}, then the method returns 090 * immediately. 091 * @exception Throwable If thrown while executing the model. 092 */ 093 @Test 094 @Parameters(method = "modelValues") 095 public void runModelInline(String fullPath) throws Throwable { 096 runModel(fullPath, "java", false /* generateInSubdirectory */, 097 true /* inline */, 2500 /* maximumLinesPerBlock */, 098 false /*variablesAsArrays*/, "" /*generatorPackageList*/); 099 } 100 101 /** 102 * Generate, compile and run code as if the model was very large. 103 * 104 * @param fullPath The full path to the model file to be 105 * executed. If the fullPath ends with the value of the {@link 106 * #THERE_ARE_NO_AUTO_TESTS}, then the method returns 107 * immediately. 108 * @exception Throwable If thrown while executing the model. 109 */ 110 @Test 111 @Parameters(method = "modelValues") 112 public void runModelLarge(String fullPath) throws Throwable { 113 runModel(fullPath, "java", true /* generateInSubdirectory */, 114 false /* inline */, 1 /* maximumLinesPerBlock */, 115 true /*variablesAsArrays*/, "" /*generatorPackageList*/); 116 } 117 118 /** 119 * Generate, compile and run non-inline code for a model. 120 * 121 * @param fullPath The full path to the model file to be 122 * executed. If the fullPath ends with the value of the {@link 123 * #THERE_ARE_NO_AUTO_TESTS}, then the method returns 124 * immediately. 125 * @exception Throwable If thrown while executing the model. 126 */ 127 @Test 128 @Parameters(method = "modelValues") 129 public void runModelNoInline(String fullPath) throws Throwable { 130 runModel(fullPath, "java", false /* generateInSubdirectory */, 131 false /* inline */, 2500 /* maximumLinesPerBlock */, 132 false /*variablesAsArrays*/, "" /*generatorPackageList*/); 133 } 134}