Unit Testing for MacOS Platform - magic-lantern-studio/mle-documentation GitHub Wiki
This page discusses how to set up Google Test for Magic Lantern code targeting the MacOS platform.
Table of Contents
- Setting up Google Test
- Executing libmlutil Tests
- Executing libmlmath Tests
- Executing libmlert Runtime Tests
- Executing libDWP Tests
- Google Test Resources
- Using Google Test with Qt
Setting up Google Test
gtest may be installed on the MacOS by using Homebrew. From the terminal window on the Mac, use
brew install googletest
The library, libgtest.a, will be install in /opt/homebrew/Cellar/googletest/1.14.0/lib. The header files will be installed into /opt/homebrew/Cellar/googletest/1.14.0/include/gtest.
[!NOTE] The above directory location may vary from 1.14.0, depending on which version of googletest will be installed by Homebrew.
Executing libmlutil Tests
Build the Core util Unit Test Libraries
These instructions build the Core util 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/util/linux/test/.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 libmlutil-test project.
In the Eclipse ProjectExplorer, right-click on the libmlutil-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/util/linux/test") and then run "make distclean").
To install the library, right-click on the libmlutil-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 (OpenGL Target Platform) include
Library | Directory Location | Component |
---|---|---|
libmlutiltest.a | "$MLE_ROOT/lib/" | Magic Lantern SDK (Debug) |
libmlutiltest.so | "$MLE_ROOT/lib" | Magic Lantern SDK (Debug) |
where MLE_ROOT is currently /opt/MagicLantern.
Execute the Core util 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.
Todo: provide a screen shot of the Run Configuration here.
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.
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/runtime-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 libmlert-runtime-test project.
In the Eclipse ProjectExplorer, right-click on the libmlert-runtime-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-runtime-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
Executing libDWP Tests
Build the Digital Workprint libDWP Unit Test Libraries
These instructions build the Digital Workprint libDWP unit test libraries for the Magic Lantern SDK. The Eclipse IDE development tool is used.
- Eclipse Makefile: "$MLE_HOME/DigitalWorkprint/test/linux/libDWP-test/.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 libDWP-test project.
In the Eclipse ProjectExplorer, right-click on the libDWP-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/DigitalWorkprint/test/linux/libDWP-test") and then run "make distclean").
To install the library, right-click on the libDWP-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 |
---|---|---|
libdwptest.a | "$MLE_ROOT/lib/" | Magic Lantern SDK (Debug) |
libdwptest.so | "$MLE_ROOT/lib" | Magic Lantern SDK (Debug) |
where MLE_ROOT is currently /opt/MagicLantern.
Execute the Digital Workprint libDWP 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.
Google Test Resources
Using Google Test with Qt
To use Google Test with Qt Creator, you will need to set the GOOGLETEST_DIR environment variable to the directory where you installed the googletest source (for example: /media/workarea/msm/Projects/googletest)