Update for cmake

parent 9a2b7403
This diff is collapsed.
......@@ -16,19 +16,19 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# Config file for the belcard package.
# It defines the following variables:
#
# BELCARD_FOUND - system has belcard
# BELCARD_INCLUDE_DIRS - the belcard include directory
# BELCARD_LIBRARIES - The libraries needed to use belcard
# BELMSRP_FOUND - system has belmsrp
# BELMSRP_INCLUDE_DIRS - the belmsrp include directory
# BELMSRP_LIBRARIES - The libraries needed to use belcard
if(NOT LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${CMAKE_CURRENT_LIST_DIR}/BelcardTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/BelMSRPTargets.cmake")
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
......@@ -37,17 +37,21 @@ else()
find_package(Belr REQUIRED)
endif()
get_filename_component(BELCARD_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(BELMSRP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BELCARD_INCLUDE_DIRS "${EP_belcard_INCLUDE_DIR}")
set(BELMSRP_INCLUDE_DIRS "${EP_belmsrp_INCLUDE_DIR}")
else()
set(BELCARD_INCLUDE_DIRS "${BELCARD_CMAKE_DIR}/../../../include")
set(BELMSRP_INCLUDE_DIRS "${BELMSRP_CMAKE_DIR}/../../../include")
endif()
if(@ENABLE_SHARED@)
set(BELMSRP_LIBRARIES belmsrp)
else()
set(BELMSRP_LIBRARIES belmsrp-static)
endif()
if(BELR_FOUND)
list(APPEND BELCARD_INCLUDE_DIRS ${BELR_INCLUDE_DIRS})
list(APPEND BELCARD_LIBRARIES ${BELR_LIBRARIES})
list(APPEND BELMSRP_INCLUDE_DIRS ${BELR_INCLUDE_DIRS})
list(APPEND BELMSRP_LIBRARIES ${BELR_LIBRARIES})
endif()
set(BELCARD_LIBRARIES belcard)
set(BELCARD_FOUND 1)
set(BELMSRP_FOUND 1)
......@@ -44,24 +44,24 @@ fi
AC_SUBST(BELR_LIBS)
dnl ##################################################
dnl # Check for CUnit
dnl # Check for BCUnit
dnl ##################################################
PKG_CHECK_MODULES(CUNIT, cunit, [found_cunit=yes],[found_cunit=no])
PKG_CHECK_MODULES(BCUNIT, bcunit, [found_bcunit=yes],[found_bcunit=no])
if test "$found_cunit" = "no" ; then
AC_CHECK_HEADERS(CUnit/CUnit.h,
if test "$found_bcunit" = "no" ; then
AC_CHECK_HEADERS(BCUnit/BCUnit.h,
[
AC_CHECK_LIB(cunit,CU_add_suite,[
found_cunit=yes
CUNIT_LIBS+=" -lcunit"
AC_CHECK_LIB(bcunit,CU_add_suite,[
found_bcunit=yes
BCUNIT_LIBS+=" -lbcunit"
])
])
fi
case "$target_os" in
*darwin*)
#hack for macport
CUNIT_LIBS+=" -lncurses"
BCUNIT_LIBS+=" -lncurses"
;;
*mingw*)
CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
......@@ -70,18 +70,18 @@ case "$target_os" in
;;
esac
if test "$found_cunit" = "no" ; then
AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
if test "$found_bcunit" = "no" ; then
AC_MSG_WARN([Could not find bcunit framework, tests are not compiled.])
else
AC_CHECK_LIB(cunit,CU_get_suite,[
AC_CHECK_LIB(bcunit,CU_get_suite,[
AC_DEFINE(HAVE_CU_GET_SUITE,1,[defined when CU_get_suite is available])
],[foo=bar],[$CUNIT_LIBS])
AC_CHECK_LIB(cunit,CU_curses_run_tests,[
],[foo=bar],[$BCUNIT_LIBS])
AC_CHECK_LIB(bcunit,CU_curses_run_tests,[
AC_DEFINE(HAVE_CU_CURSES,1,[defined when CU_curses_run_tests is available])
],[foo=bar],[$CUNIT_LIBS])
],[foo=bar],[$BCUNIT_LIBS])
fi
AM_CONDITIONAL(BUILD_TESTS,test x$found_cunit = xyes)
AM_CONDITIONAL(BUILD_TESTS,test x$found_bcunit = xyes)
# Checks for header files.
......
############################################################################
# CMakeLists.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
set(HEADER_FILES
)
set(BELLEMSRP_HEADER_FILES )
foreach(HEADER_FILE ${HEADER_FILES})
list(APPEND BELLEMSRP_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/BELLEMSRP/${HEADER_FILE}")
endforeach()
set(BELLEMSRP_HEADER_FILES ${BELLEMSRP_HEADER_FILES} PARENT_SCOPE)
install(FILES ${BELLEMSRP_HEADER_FILES}
DESTINATION include/BELLEMSRP
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
############################################################################
# CMakeLists.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
set(HEADER_FILES
belle-msrp.hpp
belle-msrp_parser.hpp
msrp_grammar.hpp
)
set(BELMSRP_HEADER_FILES )
foreach(HEADER_FILE ${HEADER_FILES})
list(APPEND BELMSRP_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/belle-msrp/${HEADER_FILE}")
endforeach()
set(BELMSRP_HEADER_FILES ${BELMSRP_HEADER_FILES} PARENT_SCOPE)
install(FILES ${BELMSRP_HEADER_FILES}
DESTINATION include/belle-msrp
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
############################################################################
# CMakeLists.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
set(BELLEMSRP_HEADER_FILES )
set(BELLEMSRP_SOURCE_FILES_C )
set(BELLEMSRP_SOURCE_FILES_CXX
)
apply_compile_flags(BELLEMSRP_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(BELLEMSRP_SOURCE_FILES_CXX "CPP" "CXX")
if(ENABLE_STATIC)
add_library(belle-msrp STATIC ${BELLEMSRP_HEADER_FILES} ${BELLEMSRP_SOURCE_FILES_C} ${BELLEMSRP_SOURCE_FILES_CXX})
else()
add_library(belle-msrp SHARED ${BELLEMSRP_HEADER_FILES} ${BELLEMSRP_SOURCE_FILES_C} ${BELLEMSRP_SOURCE_FILES_CXX})
set_target_properties(belle-msrp PROPERTIES VERSION ${BELLEMSRP_SO_VERSION})
endif()
if(APPLE)
target_compile_features(belle-msrp PRIVATE cxx_auto_type cxx_variadic_macros)
endif()
target_link_libraries(belle-msrp ${BELR_LIBRARIES})
install(TARGETS belle-msrp EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
install(FILES ${BELLEMSRP_HEADER_FILES}
DESTINATION include/belle-msrp
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
############################################################################
# CMakeLists.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
set(BELMSRP_HEADER_FILES )
set(BELMSRP_SOURCE_FILES_C )
set(BELMSRP_SOURCE_FILES_CXX
belle-msrp.cpp
belle-msrp_parser.cpp
msrp_grammar.cpp
)
apply_compile_flags(BELMSRP_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(BELMSRP_SOURCE_FILES_CXX "CPP" "CXX")
if(ENABLE_STATIC)
add_library(belmsrp-static STATIC ${BELMSRP_HEADER_FILES} ${BELMSRP_SOURCE_FILES_C} ${BELMSRP_SOURCE_FILES_CXX})
set_target_properties(belmsrp-static PROPERTIES OUTPUT_NAME belmsrp)
target_link_libraries(belmsrp-static ${BELR_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
endif()
if(ENABLE_SHARED)
add_library(belmsrp SHARED ${BELMSRP_HEADER_FILES} ${BELMSRP_SOURCE_FILES_C} ${BELMSRP_SOURCE_FILES_CXX})
if(APPLE)
set_target_properties(belmsrp PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
set_target_properties(belmsrp PROPERTIES VERSION ${BELMSRP_SO_VERSION})
target_link_libraries(belmsrp PRIVATE ${BELR_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/belmsrp.pdb
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
endif()
if(ENABLE_STATIC)
install(TARGETS belmsrp-static EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
if(ENABLE_SHARED)
install(TARGETS belmsrp EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(FILES ${BELMSRP_HEADER_FILES}
DESTINATION include/belle-msrp
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
############################################################################
# CMakeLists.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
set(SOURCE_FILES_C
common/bc_tester_utils.c
)
set(SOURCE_FILES_CXX
belcard-addressing-tester.cpp
belcard-calendar-tester.cpp
belcard-communication-tester.cpp
belcard-explanatory-tester.cpp
belcard-general-tester.cpp
belcard-geographical-tester.cpp
belcard-identification-tester.cpp
belcard-organizational-tester.cpp
belcard-rfc6474-tester.cpp
belcard-security-tester.cpp
belcard-tester.cpp
belcard-vcard-tester.cpp
)
apply_compile_flags(SOURCE_FILES_C "CPP" "C")
apply_compile_flags(SOURCE_FILES_CXX "CPP" "CXX")
add_definitions(-DBC_CONFIG_FILE="config.h")
add_executable(belcard-tester ${SOURCE_FILES_C} ${SOURCE_FILES_CXX})
set_target_properties(belcard-tester PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(belcard-tester PUBLIC ${CUNIT_INCLUDE_DIRS} PRIVATE common)
target_link_libraries(belcard-tester belcard ${CUNIT_LIBRARIES})
\ No newline at end of file
############################################################################
# CMakeLists.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
if(ENABLE_SHARED)
set(BELMSRP_LIBRARIES_FOR_TESTER belmsrp)
else()
set(BELMSRP_LIBRARIES_FOR_TESTER belmsrp-static)
endif()
set(HEADER_FILES_CXX bellemsrp-tester.hpp)
set(SOURCE_FILES_CXX
bellemsrp-header_test.cpp
bellemsrp-header_test.cpp
bellemsrp-response_test.cpp
bellemsrp-request_test.cpp
bellemsrp-tester.cpp
)
apply_compile_flags(SOURCE_FILES_CXX "CPP" "CXX")
add_executable(belmsrp_tester ${SOURCE_FILES_CXX} ${HEADER_FILES_CXX})
set_target_properties(belmsrp_tester PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(belmsrp_tester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
target_link_libraries(belmsrp_tester ${BELMSRP_LIBRARIES_FOR_TESTER} ${BCTOOLBOX_TESTER_LIBRARIES})
if(APPLE)
set_target_properties(belmsrp_tester PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
if(NOT IOS)
install(TARGETS belmsrp_tester
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
......@@ -3,20 +3,20 @@
static void testToPath() {
auto* toPath = testProperty<bellemsrp::Path>
("To-Path: msrp://bob.example.com:8888/9di4eae923wzd;tcp", "To-Path");
BC_ASSERT_EQUAL_FATAL(toPath->uris.size(), 1, int, "%d");
BC_ASSERT_EQUAL(toPath->uris.size(), 1, int, "%d");
BC_ASSERT_EQUAL(toPath->uris[0]->scheme, bellemsrp::Scheme::msrp, int, "%d");
}
static void testFromPath() {
auto* fromPath = testProperty<bellemsrp::Path>
("From-Path: msrps://bob.example.com:8888/9di4eae923wzd;tcp", "From-Path");
BC_ASSERT_EQUAL_FATAL(fromPath->uris.size(), 1, int, "%d");
BC_ASSERT_EQUAL(fromPath->uris.size(), 1, int, "%d");
BC_ASSERT_EQUAL(fromPath->uris[0]->scheme, bellemsrp::Scheme::msrps, int, "%d");
}
static test_t tests[] = {
{ "To-Path", testToPath },
{ "From-Path", testFromPath },
TEST_NO_TAG("To-Path", testToPath),
TEST_NO_TAG("From-Path", testFromPath),
};
test_suite_t header_properties_test_suite = {
......@@ -27,4 +27,4 @@ test_suite_t header_properties_test_suite = {
NULL,
sizeof(tests) / sizeof(tests[0]),
tests
};
\ No newline at end of file
};
......@@ -9,10 +9,10 @@ static void testHeaders() {
auto* headers = testProperty<bellemsrp::Headers>
(input, "headers");
BC_ASSERT_PTR_NOT_NULL_FATAL(headers);
BC_ASSERT_PTR_NOT_NULL_FATAL(headers->to);
BC_ASSERT_PTR_NOT_NULL_FATAL(headers->from);
BC_ASSERT_PTR_NOT_NULL_FATAL(headers->messageID);
BC_ASSERT_PTR_NOT_NULL(headers);
BC_ASSERT_PTR_NOT_NULL(headers->to);
BC_ASSERT_PTR_NOT_NULL(headers->from);
BC_ASSERT_PTR_NOT_NULL(headers->messageID);
BC_ASSERT_STRING_EQUAL(headers->messageID, "12339sdqwer");
BC_ASSERT_EQUAL(headers->byteRange.start, 1, int, "%d");
BC_ASSERT_EQUAL(headers->byteRange.end, 16, int, "%d");
......@@ -29,9 +29,9 @@ static void testContentStuff() {
auto* content = testProperty<bellemsrp::Content>
(input, "content-stuff");
BC_ASSERT_PTR_NOT_NULL_FATAL(content);
BC_ASSERT_PTR_NOT_NULL(content);
BC_ASSERT_STRING_EQUAL(content->type, "text/plain");
BC_ASSERT_PTR_NOT_NULL_FATAL(content->data);
BC_ASSERT_PTR_NOT_NULL(content->data);
// data contains both data and endLine
BC_ASSERT_STRING_EQUAL(content->data, "Hi, I'm Alice!\r\n" "-------d93kswow$\r\n");
}
......@@ -50,22 +50,22 @@ static void testRequestSend() {
auto* request = testProperty<bellemsrp::Request>
(input, "msrp-request");
BC_ASSERT_PTR_NOT_NULL_FATAL(request);
BC_ASSERT_PTR_NOT_NULL(request);
BC_ASSERT_STRING_EQUAL(request->transactionID, "d93kswow");
BC_ASSERT_STRING_EQUAL(request->method, "SEND");
BC_ASSERT_PTR_NOT_NULL_FATAL(request->headers);
BC_ASSERT_PTR_NOT_NULL(request->headers);
BC_ASSERT_STRING_EQUAL(request->headers->messageID, "12339sdqwer");
BC_ASSERT_EQUAL(request->headers->byteRange.start, 1, int, "%d");
BC_ASSERT_EQUAL(request->headers->byteRange.end, 16, int, "%d");
BC_ASSERT_EQUAL(request->headers->byteRange.total, 16, int, "%d");
BC_ASSERT_PTR_NOT_NULL_FATAL(request->endLine);
BC_ASSERT_PTR_NOT_NULL(request->endLine);
BC_ASSERT_STRING_EQUAL(request->endLine, "-------d93kswow$\r\n");
}
static test_t tests[] = {
{ "headers", testHeaders },
{ "content-stuff", testContentStuff },
{ "Send request", testRequestSend },
TEST_NO_TAG( "headers", testHeaders ),
TEST_NO_TAG( "content-stuff", testContentStuff),
TEST_NO_TAG( "Send request", testRequestSend),
};
test_suite_t request_test_suite = {
......
......@@ -8,13 +8,13 @@ static void testOkResponse() {
auto* response = testProperty<bellemsrp::Response>
(input, "msrp-response");
BC_ASSERT_PTR_NOT_NULL_FATAL(response);
BC_ASSERT_TRUE(response!=NULL);
BC_ASSERT_STRING_EQUAL(response->transactionID, "d93kswow");
BC_ASSERT_EQUAL(response->status.code, 200, int, "%d");
}
static test_t tests[] = {
{ "OK response", testOkResponse },
TEST_NO_TAG("OK response", testOkResponse),
};
test_suite_t response_test_suite = {
......@@ -25,4 +25,4 @@ test_suite_t response_test_suite = {
NULL,
sizeof(tests) / sizeof(tests[0]),
tests
};
\ No newline at end of file
};
......@@ -68,7 +68,7 @@ static void log_handler(int lev, const char *fmt, va_list args) {
void bellemsrp_tester_init(void(*ftester_printf)(int level, const char *fmt, va_list args)) {
if (ftester_printf == NULL) ftester_printf = log_handler;
bc_tester_init(ftester_printf, MESSAGE, ERROR);
bc_tester_init(ftester_printf, MESSAGE, ERROR, "msrp");
bc_tester_add_suite(&header_properties_test_suite);
bc_tester_add_suite(&response_test_suite);
......
......@@ -19,7 +19,7 @@
#pragma once
#include "belle-msrp/belle-msrp_parser.hpp"
#include "common/bc_tester_utils.h"
#include <bctoolbox/tester.h>
#include <string>
......@@ -42,11 +42,11 @@ template<typename T>
T* testProperty(const std::string& input, const std::string& rule) {
bellemsrp::Parser parser;
bellemsrp::Element* result = parser.parse(input, rule);
BC_ASSERT_PTR_NOT_NULL_FATAL(result);
BC_ASSERT_TRUE(result!=NULL);
std::string str = result->toString();
BC_ASSERT_STRING_EQUAL(str.c_str(), input.c_str());
T* casted = dynamic_cast<T*> (result);
BC_ASSERT_PTR_NOT_NULL_FATAL(casted);
BC_ASSERT_TRUE(casted!=NULL);
return casted;
}
# Copyright (C) 2012 Belledonne Comunications, Grenoble, France
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Created by Gautier Pelloux-Prayer on 2014/10/24.
# This script adds auto-completion for liblinphone_tester binary for Bash and
# Zsh. To use it, just type: `source liblinphone_completion`, then for each
# supported exectuable (see end of file), you will get auto-completions.
# To use it permanently, source this file in your .rc file (.bashrc or .zshrc).
_liblinphone_complete() {
local completions command_requiring_argument prev_arg latest_arg available_tasks has_not_set_suite suite_name
if [ -n "$BASH_VERSION" ]; then
set -- "${COMP_WORDS[@]}" #convert them to arguments (eg $1,$#,$@,etc.)
elif [ -n "$ZSH_VERSION" ]; then
local args
read -cA args #read list of arguments user entered
set -- "${args[@]}" #convert them to arguments (eg $1,$#,$@,etc.)
fi
#skip program name
program=$1
shift
# if user required help, do not complete anything
if ! grep -q -- "--help" <<< "$@"; then
# retrieve the last argument
latest_arg=""
prev_arg=""
latest_is_empty=0
for arg in "$@"; do
if [ ! -z "$arg" ]; then
prev_arg="$latest_arg"
latest_arg="$arg"
else
latest_is_empty=1
fi
done
# get the tasks available, from --help
available_tasks="$($program 2>&1 --help | sed -nE "s/.*--([^ ]*).*/--\\1/p")"
# these commands expect an argument
command_requiring_argument="$($program 2>&1 --help | sed -nE "s/.*--(.*) <.*/--\\1/p")"
# remove all already provided tasks (it's useless to provide them twice)
if [[ ! -z "$@" ]]; then
current_tasks=$(echo $@ | grep -Eo -- "--([^ ])*" | tr '\n' '|' | sed 's/|/$|/g')--$
if [ ! -z "$current_tasks" ]; then
available_tasks=$(echo "$available_tasks" | grep -vE -- "(${current_tasks})")
fi
fi
# remove --test option if --suite is not provided yet!
has_not_set_suite=$(grep -q -- "--suite" <<< "$@"; echo $?)
if [ $has_not_set_suite = 1 ]; then
available_tasks=$(echo "$available_tasks" | grep -v -- --test)
fi
# if latest arg does not start with '--', it is a custom value
if [ $latest_is_empty = 0 ] && ! grep -q -- '^--' <<< "$latest_arg"; then
if [ "$prev_arg" = "--test" ] && [ $has_not_set_suite = 0 ]; then
suite_name=$(echo $@ | sed -nE 's/.*--suite ([^(--)]*) (--.*)$/\1/p' |sed "s@\\\\@@g")
completions="$($program --list-tests $suite_name)"
elif [ "$prev_arg" = "--suite" ] || [ "$prev_arg" = "--list-tests" ]; then
completions="$($program --list-suites)"
fi
elif [ "$latest_arg" = "--test" ]; then
# list available tests if --suite was provided
if [ $has_not_set_suite = 0 ]; then
suite_name=$(echo $@ | sed -nE 's/.*--suite ([^(--)]*) (--.*)/\1/p' |sed "s@\\\\@@g")
completions="$($program --list-tests $suite_name)"
fi
elif [ "$latest_arg" = "--suite" ] || [ "$latest_arg" = "--list-tests" ]; then
completions="$($program --list-suites)"
# we are waiting for a custom value, so do not hint anything
elif [[ ! -z "$latest_arg" ]] && grep -q -- "^$latest_arg$" <<< "$command_requiring_argument"; then
completions=""
else
completions="$available_tasks"
fi
fi
if [ ! -z "$completions" ]; then
if [ -n "$BASH_VERSION" ]; then
IFS=$'\n' #if that even necessary?
COMPREPLY=($(compgen -W "${completions}" -- ${COMP_WORDS[COMP_CWORD]}))
elif [ -n "$ZSH_VERSION" ]; then
reply=( "${(ps:\n:)completions}" )
fi
fi
}
for tester in belcard-tester; do
if [ -n "$BASH_VERSION" ]; then
complete -F _liblinphone_complete $tester
elif [ -n "$ZSH_VERSION" ]; then
compctl -K _liblinphone_complete $tester
else
echo "Your shell might be not supported! Only bash and zsh tested."
fi
done
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