Menu

Unit_Testing_for_Linux_Platform

Unit Testing for Linux Platform

This page discusses how to set up Google Test for Magic Lantern code targeting the Linux platform.

Setting up Google Test

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

Executing libmlmath Tests

Build the Core math Unit Test Libraries

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.

  • Eclipse Makefile: "$MLE_HOME/Core/math/linux/libmlmathtest/.project"

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.

Execute the Core math Unit Test Libraries

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

Executing libmlert-runtime Tests

Build the Core mlert Unit Test Libraries

These instructions build the Core mlert unit test libraries for the Magic Lantern SDK. The Eclipse IDE development tool is used.

  • Eclipse Makefile: "$MLE_HOME/Core/mlert/linux/unittest/.project"

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.

Execute the Core mlert Unit Test Libraries

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

Google Test Resources


Related

Developer Wiki: SDK_Build_Environment_for_Linux_Platform

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.