This page discusses how to set up Google Test for Magic Lantern code targeting the Linux platform.
Instructions for building and installing Google Test can be found in the README file (https://github.com/google/googletest/blob/master/googletest/README.md). The information in this wiki page supplements that document.
Make sure that 'git' is installed since the source will be retrieved from GitHub.
$ sudo apt-get install git
Retrieve the source:
$ git clone https://github.com/google/googletest.git
Change your working directory to where you cloned the git repository and create the envrironment variable GTEST_DIR:
$ cd googletest
$ export GTEST_DIR=pwd
$ cd $GTEST_DIR
Build the Google Test library, libgtest.a:
$ cd $GTEST_DIR/googletest
$ g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} -pthread -c ${GTEST_DIR}/src/gtest-all.cc
$ ar -rv libgtest.a gtest-all.o
These instructions build the Core math unit test libraries for the Magic Lantern Studio tools, the Magic Lantern SDK for the OpenGL target, and the Magic Lantern Rehearsal Player. The Eclipse IDE development tool is used.
Import the above Eclipse project by selecting "File->Import...". This will bring up a Import dialog where you can choose "Existing Projects into Workspace" under the "General" tree item. Select "Next>" button to continue and browse to the above libmlmathtest project.
Modify the Eclipse Autotools settings for the project. Right-click on the libmlmathtest project and select "Properties" from the pop-up menu. Under the "Autotools" menu, select "Configure Settings". Then, in the "configure" section, select "Environment variables" to modify the GTEST_DIR variable (it is probably set to /home/msm/Projects/googletest). Point GTEST_DIR to the location where you installed Google Test. Select the "OK" button to apply and exit.
In the Eclipse ProjectExplorer, right-click on the libmlmathtest project and select "Build Project" from the pop-up menu.
Note: Before building, you may need to first regenerate the autoconf environment. The easiest way to do this is from the command line. In a terminal, change to the project directory (i.e. "cd $MLE_HOME/Core/math/linux/libmlmathtest") and then run "make distclean").
To install the library, right-click on the libmlmathtest project and select "Make Targets->Build..." from the pop-up menu. This will bring up a dialog panel showing the possible Make Targets for this project. Select "install" from Target list and then complete the action by selecting the "Build" button.
The library components that are built for the Magic Lantern SDK (OpenGL Target Platform) include
Library | Directory Location | Component |
---|---|---|
libmlmathtest.a | "$MLE_ROOT/lib/" | Magic Lantern SDK (Debug) |
libmlmathtest.so | "$MLE_ROOT/lib" | Magic Lantern SDK (Debug) |
where MLE_ROOT is currently /opt/MagicLantern.
To execute the unit tests, create a "Run Configuration" where the "C/C++ Application" is set to "exampleProgram/.libs/exampleProgram". Output is generated in the "Console" window.
Figure 1: Run Configuration for libmlmath Google Test
These instructions build the Core mlert unit test libraries for the Magic Lantern SDK. The Eclipse IDE development tool is used.
Import the above Eclipse project by selecting "File->Import...". This will bring up a Import dialog where you can choose "Existing Projects into Workspace" under the "General" tree item. Select "Next>" button to continue and browse to the above libmlerttest project.
Modify the Eclipse Autotools settings for the project. Right-click on the libmlert-test project and select "Properties" from the pop-up menu. Under the "Autotools" menu, select "Configure Settings". Then, in the "configure" section, select "Environment variables" to modify the GTEST_DIR variable (it is probably set to /home/msm/Projects/googletest). Point GTEST_DIR to the location where you installed Google Test. Select the "OK" button to apply and exit.
In the Eclipse ProjectExplorer, right-click on the libmlert-test project and select "Build Project" from the pop-up menu.
Note: Before building, you may need to first regenerate the autoconf environment. The easiest way to do this is from the command line. In a terminal, change to the project directory (i.e. "cd $MLE_HOME/Core/math/linux/libmlerttest") and then run "make distclean").
To install the library, right-click on the libmlert-test project and select "Make Targets->Build..." from the pop-up menu. This will bring up a dialog panel showing the possible Make Targets for this project. Select "install" from Target list and then complete the action by selecting the "Build" button.
The library components that are built for the Magic Lantern SDK include
Library | Directory Location | Component |
---|---|---|
libmlerttest.a | "$MLE_ROOT/lib/" | Magic Lantern SDK (Debug) |
libmlerttest.so | "$MLE_ROOT/lib" | Magic Lantern SDK (Debug) |
where MLE_ROOT is currently /opt/MagicLantern.
To execute the unit tests, create a "Run Configuration" where the "C/C++ Application" is set to "exampleProgram/.libs/exampleProgram". Output is generated in the "Console" window.
Figure 2: Run Configuration for libmlert Google Test