Commit fc46aef9 authored by Ștefan Antoniu Alexandru IONESCU (105356)'s avatar Ștefan Antoniu Alexandru IONESCU (105356)
Browse files

Added gtest support. Added instructions and examples for running test cases.

parent 9ca83b0d
{
"files.associations": {
<<<<<<< Updated upstream
"array": "cpp",
"string": "cpp",
"string_view": "cpp",
......@@ -15,10 +16,30 @@
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
=======
"config.h": "c",
"datatypes.h": "c",
"integers.h": "c",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"hash_map": "cpp",
"strstream": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
>>>>>>> Stashed changes
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
<<<<<<< Updated upstream
=======
"codecvt": "cpp",
>>>>>>> Stashed changes
"complex": "cpp",
"condition_variable": "cpp",
"csetjmp": "cpp",
......@@ -30,11 +51,16 @@
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
<<<<<<< Updated upstream
=======
"cuchar": "cpp",
>>>>>>> Stashed changes
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
<<<<<<< Updated upstream
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
......@@ -42,11 +68,39 @@
"rope": "cpp",
"slist": "cpp",
"functional": "cpp",
=======
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"rope": "cpp",
"slist": "cpp",
"fstream": "cpp",
>>>>>>> Stashed changes
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
<<<<<<< Updated upstream
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
......@@ -75,6 +129,22 @@
"memory": "cpp",
"memory_resource": "cpp",
"random": "cpp",
=======
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"scoped_allocator": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
>>>>>>> Stashed changes
"variant": "cpp"
}
}
\ No newline at end of file
......@@ -88,6 +88,35 @@ MultiPathVoIPLite/build (first terminal)# ./MpVoIPLite matei dan serverip_1 sip_
MultiPathVoIPLite/build (second terminal)# ./MpVoIPLite dan matei serverip_1 sip_port smkex_port_1 dan2 matei2 serverip_2 smkex_port_2 init
############ Testing the app using Google test ################
For testing the app using the Gtest library:
We need to compile and run a separate binary for testing purposes.
1. Install libgtest and perequisites:
$ sudo apt-get install libgtest-dev
$ sudo apt-get install cmake
$ cd /usr/src/gtest
$ sudo cmake CMakeLists.txt
$ sudo make
# copy or symlink libgtest.a and libgtest_main.a to your /usr/lib folder
$ sudo cp *.a /usr/lib
2. Compile the binary as follows:
MultiPathVoIPLite# cd google_tests
MultiPathVoIPLite/google_tests# mkdir build
MultiPathVoIPLite/google_tests# cd build
MultiPathVoIPLite/google_tests/build# cmake ../
MultiPathVoIPLite/google_tests/build# make -j8
3. Run the test binary as follows:
./runTests
############ Testing PJSIP Apps from command line ################
......
cmake_minimum_required(VERSION 3.4)
project("Multi-Path VoIP Lite TEST")
FIND_PACKAGE(OpenSSL REQUIRED)
FIND_PACKAGE(ALSA REQUIRED)
include (FindPkgConfig)
if (PKG_CONFIG_FOUND) # true if pkg-config works on the system
pkg_check_modules(PJSIP REQUIRED libpjproject)
endif()
include_directories(${PJSIP_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS})
link_directories(${PJSIP_LIBRARY_DIRS} ${ALSA_LIBRARIES})
# Locate GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
set(SRC_FILES
../smkex/src/*.cpp
../web_sockets/src/*.cpp
../auto_resend/src/*.cpp
../base_service/src/*.cpp
../buddy/src/*.cpp
../call_manager/src/*.cpp
../config/src/*.cpp
../data_msg/src/*.cpp
../sip_stack/src/*.cpp
#../../tests/src/*.cpp
../user_account/src/*.cpp
../utils/src/*.cpp
)
set(SRC_HEADER_FILES
../smkex/include
../web_sockets/include
../auto_resend/include
../base_service/include
../buddy/include
../config/include
../buddy/include
../call_manager/include
../config/include
../data_msg/include
../sip_stack/include
#../../tests/include
../user_account/include
../utils/include
)
# add_library(libpj STATIC IMPORTED GLOBAL)
# set_target_properties(libpj PROPERTIES IMPORTED_LOCATION /usr/local/lib/libpj-x86_64-unknown-linux-gnu.a)
# set_target_properties(libpj PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include)
include_directories(${SRC_HEADER_FILES})
file(GLOB_RECURSE sources ${SRC_FILES})
set(MP_DEBUG 1)
set(MP_OS_LINUX 1)
set(MP_LOG_TO_CONSOLE 1)
add_custom_target(build-time-make-directory ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ../smkex
COMMAND ${CMAKE_COMMAND} -E copy ../../smkex/dhparam.pem
../smkex/dhparam.pem
DEPENDS ./../smkex/dhparam.pem
)
# Libs
#include_directories(/usr/local/include)
#link_directories(/usr/local/lib)
# Link runTests with what we want to test and the GTest and pthread library
# add_executable(runTests tests.cpp ../../smkex/src/Smkex.cpp ../../smkex/src/SmkexSessionInfo.cpp ../../smkex/src/SmkexRecord.cpp ../../utils/src/MpLogger.cpp ../../smkex/src/crypto.cpp ../../base_service/src/MpBaseService.cpp ../../sip_stack/src/MpSIPStack.cpp)
add_executable(runTests tests.cpp ${sources})
message("status:${PJSIP_LIBRARIES}")
target_link_libraries(runTests ${PJSIP_LIBRARIES} libwebsockets.a libpjsua2-x86_64-unknown-linux-gnu.a ${GTEST_LIBRARIES})
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAnQM854HADrNS1tjoBhQ/VGnQirAymx1/KI8mnbAyfOSfSCgfIxFb
VIDuwO7QnA0Q9hiqSgIClH8vZeQLMcBffq9HZud2v6Uzp4TmrJ0mBg9plSSWWbfJ
aSykjTyJsh+EoCzDbPsrwE0uxkM2d84Ran3lhroRMdFmgheyLem1yAmfW7TnoHRC
gtENOtYqLOeGV2Hk1cxG9IZfac5c4C4QRUpDZudj/pQfSFMheDBjplf+BZzVeSvW
oNFltuaUevfPgrIfcsf94FifQn7H+WuvnlgVEWP/rkdMc9Xsop3yP3Y6ymotMKuu
xGQUKR33r9NpqcsPuGTb4Kr9Ydtq81F7owIBAg==
-----END DH PARAMETERS-----
#include <gtest/gtest.h>
#include "../smkex/include/Smkex.h"
#include "../smkex/include/SmkexSessionInfo.h"
#include "../smkex/include/SmkexRecord.h"
#include "../utils/include/MpLogger.h"
#include "../smkex/include/crypto.h"
#include "../base_service/include/MpBaseService.h"
#include <openssl/rand.h>
#include <openssl/sha.h>
#include <openssl/err.h>
#include <string>
#include <pj/activesock.h>
#include <pj/compat/socket.h>
#include <pj/assert.h>
#include <pj/errno.h>
#include <pj/log.h>
#include <pj/pool.h>
#include <pj/sock.h>
#include <pj/string.h>
Smkex obj;
SmkexSessionInfo i;
SmkexSessionInfo i2;
// SmkexSessionInfo i2;
std::string s = "abcd";
// Testing Session functionality
TEST(SessionInfoTest, addSession) {
ASSERT_TRUE(obj.addSessionInfo(s, i));
}
// TEST(SessionInfoTest, replaceSession) {
// ASSERT_TRUE(obj.replaceSessionInfo(s, i2));
// }
// TEST(SessionInfoTest, hasSession) {
// ASSERT_TRUE(obj.hasSessionInfo(s));
// }
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment