org.objectweb.fractal.cecilia.adl.test
Class CeciliaAdlTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.objectweb.fractal.cecilia.adl.test.CeciliaAdlTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AttributesTest, BindingsTest, CeciliaCTestCase, CeciliaPhasesPerf, ComponentsTest, CreateCeciliaFactoryTest, DirectivesTest, FactoryTest, IDLTest, LifeCycleControllerTest, MacroTest, MultiModuleTest, ShareTest, SimpleTest, SimpleTest, TestIncrementalCompil, TypesTest

public abstract class CeciliaAdlTestCase
extends junit.framework.TestCase

Utility class for compiler tests. Defines methods to compile ADL and run compiled application.
Tests can be configured using the following system properties:


Nested Class Summary
 class CeciliaAdlTestCase.FractalBackendLauncher
          A subclass of the Launcher which uses a fully compliant Fractal compiler.
 class CeciliaAdlTestCase.StaticallyLoadedCeciliaAdlLauncher
           
 
Field Summary
static java.lang.String BUILD_DIR_PROPERTY_NAME
          The name of the system property that specify the test output directory.
static java.lang.String C_FLAGS_PROPERTY_NAME
          The name of the system property that specify the compilation flags.
protected  boolean clearBuildDir
          This boolean can be set to false by sub class to avoid cleaning build directory at setup phase.
static java.lang.String COMPILER_CMD_PROPERTY_NAME
          The name of the system property that specify the compiler command.
static java.lang.String DEFAULT_BUILD_DIR
          The default value of the BUILD_DIR_PROPERTY_NAME property.
static java.lang.String DEFAULT_C_FLAGS
          The value of the default compilation flags.
static java.lang.String DEFAULT_LD_FLAGS
           
static java.lang.String DEFAULT_SOURCE_PATH
           
static java.lang.String LD_FLAGS_PROPERTY_NAME
           
static java.lang.String LINKER_CMD_PROPERTY_NAME
          The name of the system property that specify the linker command.
static java.lang.String SOURCE_PATH_PROPERTY_NAME
          The name of the system property that specify the source path of the tests.
static java.lang.String TEST_JOBS_PROPERTY_NAME
           
 
Constructor Summary
CeciliaAdlTestCase()
           
 
Method Summary
 java.io.File compileADL(java.lang.String adlName)
          Compiles the given ADL using the CeciliaADL factory.
 void compileAndRun(java.lang.String adlName)
          Compile and run th given ADL.
protected static boolean deleteDirectory(java.io.File path)
           
static java.io.File getBuildDir()
          Returns the test build directory.
static org.objectweb.fractal.cecilia.adl.Launcher getLauncher()
          Return the cached Launcher that is used by instances of this class.
protected  java.util.Map<java.lang.String,java.lang.String> getLauncherOptions()
           
 void runTest(java.io.File test, java.lang.String adlName)
          Run a compiled ADL.
 int runTestAndReturnValue(java.io.File test, java.lang.String adlName)
          Run a given executable and return its process exit value, or fail() if it does finish in time.
static void setLauncher(org.objectweb.fractal.cecilia.adl.Launcher l)
          Set the cached Launcher that will be used by instances of this class.
 void setUp()
           
 java.io.File tryCompileADL(java.lang.String adlName)
          Compiles the given ADL using the CeciliaADL factory and throws Exception if the compilation fails.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUILD_DIR_PROPERTY_NAME

public static final java.lang.String BUILD_DIR_PROPERTY_NAME
The name of the system property that specify the test output directory. This property is mandatory.

See Also:
Constant Field Values

DEFAULT_BUILD_DIR

public static final java.lang.String DEFAULT_BUILD_DIR
The default value of the BUILD_DIR_PROPERTY_NAME property.

See Also:
Constant Field Values

SOURCE_PATH_PROPERTY_NAME

public static final java.lang.String SOURCE_PATH_PROPERTY_NAME
The name of the system property that specify the source path of the tests. This property is mandatory.

See Also:
Constant Field Values

DEFAULT_SOURCE_PATH

public static final java.lang.String DEFAULT_SOURCE_PATH

COMPILER_CMD_PROPERTY_NAME

public static final java.lang.String COMPILER_CMD_PROPERTY_NAME
The name of the system property that specify the compiler command. This property is optional (default value is gcc).

See Also:
Constant Field Values

LINKER_CMD_PROPERTY_NAME

public static final java.lang.String LINKER_CMD_PROPERTY_NAME
The name of the system property that specify the linker command. This property is optional (default value is gcc).

See Also:
Constant Field Values

C_FLAGS_PROPERTY_NAME

public static final java.lang.String C_FLAGS_PROPERTY_NAME
The name of the system property that specify the compilation flags. This property is optional (default value is given by the "-g -c -Wall -Werror -Wredundant-decls -Wunreachable-code -Wstrict-prototypes -Wwrite-strings" constant).

See Also:
Constant Field Values

DEFAULT_C_FLAGS

public static final java.lang.String DEFAULT_C_FLAGS
The value of the default compilation flags.

See Also:
Constant Field Values

LD_FLAGS_PROPERTY_NAME

public static final java.lang.String LD_FLAGS_PROPERTY_NAME
See Also:
Constant Field Values

DEFAULT_LD_FLAGS

public static final java.lang.String DEFAULT_LD_FLAGS
See Also:
Constant Field Values

TEST_JOBS_PROPERTY_NAME

public static final java.lang.String TEST_JOBS_PROPERTY_NAME
See Also:
Constant Field Values

clearBuildDir

protected boolean clearBuildDir
This boolean can be set to false by sub class to avoid cleaning build directory at setup phase.

Constructor Detail

CeciliaAdlTestCase

public CeciliaAdlTestCase()
Method Detail

setUp

public void setUp()
           throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

deleteDirectory

protected static boolean deleteDirectory(java.io.File path)

getLauncher

public static org.objectweb.fractal.cecilia.adl.Launcher getLauncher()
Return the cached Launcher that is used by instances of this class.

Returns:

setLauncher

public static void setLauncher(org.objectweb.fractal.cecilia.adl.Launcher l)
Set the cached Launcher that will be used by instances of this class.

Parameters:
l -

getBuildDir

public static java.io.File getBuildDir()
                                throws java.lang.Exception
Returns the test build directory.

Returns:
the test build directory.
Throws:
java.lang.Exception - if the "cecilia.test.buildDir" system property is not specified.

getLauncherOptions

protected java.util.Map<java.lang.String,java.lang.String> getLauncherOptions()
                                                                       throws java.lang.Exception
Throws:
java.lang.Exception

compileADL

public java.io.File compileADL(java.lang.String adlName)
Compiles the given ADL using the CeciliaADL factory. If the compilation fails, it catches the exception and prints an error message.

Parameters:
adlName - the name of the ADL to compile
Returns:
the File returned by the factory.

tryCompileADL

public java.io.File tryCompileADL(java.lang.String adlName)
                           throws java.lang.Exception
Compiles the given ADL using the CeciliaADL factory and throws Exception if the compilation fails.

Parameters:
adlName - the name of the ADL to compile
Returns:
the File returned by the factory.
Throws:
java.lang.Exception - if something goes wrong.

runTest

public void runTest(java.io.File test,
                    java.lang.String adlName)
             throws java.lang.Exception
Run a compiled ADL. A threead is created which will kill the process if it does not ends in 1 second.

Parameters:
test - the compiled ADL.
adlName - the name of the ADL (used for error message).
Throws:
java.lang.Exception - if something goes wrong.

runTestAndReturnValue

public int runTestAndReturnValue(java.io.File test,
                                 java.lang.String adlName)
                          throws java.lang.Exception
Run a given executable and return its process exit value, or fail() if it does finish in time.

Parameters:
test -
adlName -
Returns:
the executable process exit value
Throws:
java.lang.Exception

compileAndRun

public void compileAndRun(java.lang.String adlName)
                   throws java.lang.Exception
Compile and run th given ADL.

Parameters:
adlName - the name of the adl to compile and run.
Throws:
java.lang.Exception - if something goes wrong.


Copyright © 2007-2009 ObjectWeb Consortium. All Rights Reserved.