.travis.yml
@@ -21,6 +21,10 @@ - libboost-system-dev - libboost-thread-dev - libboost-date-time-dev script: - cmake --build . --target install - ctest - ctest -T memcheck - os: linux dist: xenial name: "Ubuntu 16.04 - Travis CI VM" @@ -39,64 +43,120 @@ - libboost-system-dev - libboost-thread-dev - libboost-date-time-dev - os: linux dist: bionic name: "Ubuntu 18.04 - Travis CI VM - Debug build" addons: apt: packages: - cmake - valgrind - libssl-dev - zlib1g-dev - libboost-dev - libboost-test-dev - libboost-filesystem-dev - libboost-iostreams-dev - libboost-program-options-dev - libboost-system-dev - libboost-thread-dev - libboost-date-time-dev before_script: - mkdir build - cd build && cmake -DCMAKE_INSTALL_PREFIX=../../install -DCMAKE_BUILD_TYPE=Debug .. script: - cmake --build . --target install - ctest - ctest -T memcheck - os: linux dist: bionic name: "CentOS-7 Docker" before_script: - docker run --name centos7_toconfigure -v `pwd`:/root/open-license-manager centos:centos7 /bin/bash -c "yum -y update && yum -y install cmake boost boost-devel boost-static openssl openssl-devel gcc-c++ valgrind valgrind-devel glibc-static centos-release-scl-rh && yum -y install devtoolset-3-gcc devtoolset-3-gcc-c++ && cd /root/open-license-manager && mkdir build && cd build && CC=/opt/rh/devtoolset-3/root/usr/bin/gcc XX=/opt/rh/devtoolset-3/root/usr/bin/g++ cmake .." "yum -y update && yum -y install install centos-release-scl && yum -y install cmake boost boost-devel boost-static openssl openssl-devel glibc-static devtoolset-7-toolchain devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-valgrind-devel && cd /root/open-license-manager && mkdir build && cd build && CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++ cmake .." - docker commit centos7_toconfigure centos7_configured script: - docker run --name centos7_make -v `pwd`:/root/open-license-manager centos7_configured /bin/bash -c "cd /root/open-license-manager/build && make && make install && VIRT_ENV=CONTAINER make test" - os: linux dist: bionic name: "Ubuntu 18.04 - MinGW cross-compile for Windows x64" addons: apt: packages: - cmake - binutils-mingw-w64 - mingw-w64 - mingw-w64-tools - mingw-w64-x86-64-dev - wine-development before_script: - mkdir build - cd build - wget -c https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.bz2 - tar xjf boost_1_71_0.tar.bz2 - sudo ln -s /usr/bin/x86_64-w64-mingw32-g++ /usr/local/bin/g++-mingw - cd boost_1_71_0 - ./bootstrap.sh - travis_wait 30 ./b2 toolset=gcc-mingw target-os=windows address-model=64 --with-date_time --with-test --with-filesystem --with-program_options --with-regex --with-serialization --with-system runtime-link=static --prefix=./dist release install - cd .. - cmake -DCMAKE_TOOLCHAIN_FILE=../modules/toolchain-ubuntu-mingw64.cmake -DCMAKE_INSTALL_PREFIX=../../install -DBOOST_ROOT=$PWD/boost_1_71_0/dist .. - os: windows name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MD)" env: - CACHE_NAME=boost cache: directories: - "/C/local/boost" before_script: #- Regsvr32.exe "C:\Widnows\System32\rsaenh.dll" #Not sure this is necessary let's leave it here for some time, see if there are #differences with the build (/MT) - sc stop CryptSvc - travis_wait 30 ./windows_download_boost.bat - cd "/C/Users/travis/build/open-license-manager/open-license-manager" - travis_wait 40 ./windows_download_boost.bat - cd "${TRAVIS_BUILD_DIR}" - mkdir build - cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" .. script: - cmake --build . --target install --config Release - ctest -C Release - os: windows name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MT)" before_script: - travis_wait 40 ./windows_download_boost.bat - cd "${TRAVIS_BUILD_DIR}" - mkdir build - cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" -DSTATIC_RUNTIME=1 .. - os: windows name: "Widnows server 1803 - MinGW Win64" env: - CACHE_NAME=boost - CACHE_NAME=boost-mingw cache: name: boost-mingw directories: - "/C/local/boost" before_script: - travis_wait 30 ./windows_download_boost.bat - cd "/C/Users/travis/build/open-license-manager/open-license-manager" - | if [ -d "/C/local/boost/lib" ]; then echo "Boost already installed" else echo "Boost not cached, compiling it" wget -q https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.7z echo "Boost downloaded" travis_wait 20 7z x boost_1_68_0.7z -oC:/local cd "C:/local/boost_1_68_0" ./bootstrap.bat gcc travis_wait 40 ./b2.exe -d0 --with-date_time --with-test --with-filesystem --with-program_options --with-regex --with-serialization --with-system runtime-link=static toolset=gcc --prefix=C:/local/boost install echo "Boost installed" cd /C/local/boost/lib dir fi - cd "${TRAVIS_BUILD_DIR}" - mkdir build - cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" -DSTATIC_RUNTIME=1 .. script: - cmake --build . --target install --config Release - ctest -C Release - cd build && cmake -G "MinGW Makefiles" --trace-expand -DBOOST_ROOT="C:/local/boost" -DBoost_ARCHITECTURE="-x64" -DCMAKE_CXX_COMPILER_ARCHITECTURE_ID="x64" -DCMAKE_SH="CMAKE_SH-NOTFOUND" .. env: - CTEST_OUTPUT_ON_FAILURE=1 before_script: - mkdir build - cd build && cmake -DCMAKE_INSTALL_PREFIX=../../install .. script: - make - make install - make test - cmake --build . --target install --config Release - ctest -C Release CMakeLists.txt
@@ -22,7 +22,7 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} _CMAKE_BUILD_TYPE) EVAL_CONDITION(RELEASE_BUILD ${_CMAKE_BUILD_TYPE} STREQUAL "release") else(CMAKE_BUILD_TYPE) set(RELEASE_BUILD 0) SET(RELEASE_BUILD 0) endif(CMAKE_BUILD_TYPE) if(MSVC) @@ -43,32 +43,19 @@ #SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES} add_definitions("/D _CRT_SECURE_NO_WARNINGS") else(MSVC) #GCC or Mingw SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -fmessage-length=0 -std=c++11 -Wuninitialized -fPIC") #-Wall SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -fmessage-length=0 -Wall -Wuninitialized -fPIC") if(RELEASE_BUILD) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) #.so for dynamic libraries else() SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) endif() set (CMAKE_EXE_LINKER_FLAGS "-pthread") SET(CMAKE_EXE_LINKER_FLAGS "-pthread -static-libstdc++") SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,--strip-all -static-libstdc++") #-static #you need to "force" the change in cmake_install_prefix after the project keyword IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix" FORCE) ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) #find a static version of openssl crypto library find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) if(MINGW) list(APPEND EXTERNAL_LIBS "-lcrypto -liphlpapi") else(MINGW) list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY}) list(APPEND EXTERNAL_LIBS "-lcrypt32 -lws2_32 -liphlpapi") SET(CMAKE_EXE_LINKER_FLAGS "-static") endif(MINGW) MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} ") #Zlib required when openssl version < 1.0.1f find_package(ZLIB REQUIRED) list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES}) if(USE_DBUS_IDENTIFIER) FIND_PACKAGE(Dbus REQUIRED) @@ -77,14 +64,28 @@ include_directories(${DBUS_ARCH_INCLUDE_DIR}) list(APPEND EXTERNAL_LIBS ${DBUS_LIBRARIES}) endif(USE_DBUS_IDENTIFIER) if(NOT MINGW) list(APPEND EXTERNAL_LIBS dl) endif(NOT MINGW) list(APPEND EXTERNAL_LIBS "-Wl,-Bdynamic") endif(MSVC) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>) if(UNIX) #this is true for all the linux systems but not for cross compiling #find a static version of openssl crypto library SET ( OPENSSL_USE_STATIC_LIBS ON ) find_package(OpenSSL REQUIRED COMPONENTS Crypto) include_directories(${OPENSSL_INCLUDE_DIR}) list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY}) MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} ") #Zlib required when openssl version < 1.0.1f SET ( ZLIB_USE_STATIC_LIBS ON ) find_package(ZLIB REQUIRED) list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES}) MESSAGE(STATUS "Found zlib version ${ZLIB_VERSION} ") if(NOT MINGW) list(APPEND EXTERNAL_LIBS "-ldl") endif(NOT MINGW) find_program( MEMORYCHECK_COMMAND valgrind ) set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" ) endif(UNIX) SET_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>) if(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(HAVE_64BIT_SIZE_T 1) @@ -92,7 +93,18 @@ SET(HAVE_64BIT_SIZE_T 0) endif(CMAKE_SIZEOF_VOID_P EQUAL 8) set( Boost_USE_STATIC_LIBS ON ) #bug in cmake win32 - can't find boost compiled with mingw if(WIN32 AND "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x") message(WARNING "WIN32 compiler does not specify CMAKE_CXX_COMPILER_ARCHITECTURE_ID -- filling in manually") if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x64") else() set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x86") endif() message(STATUS "Compiler architecture: ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") endif() SET( Boost_USE_STATIC_LIBS ON ) find_package(Boost REQUIRED COMPONENTS date_time unit_test_framework program_options system filesystem) #set below in case of dynamic linking in debug. #set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>) README.md
@@ -11,7 +11,7 @@ ## License The project is donated to the community. It comes with a very large freedom of use for everyone, and it will always be. It uses a [BSD 3 clauses](https://opensource.org/licenses/BSD-3-Clause) licensing schema, that allows the inclusion in commercial software. It uses a [BSD 3 clauses](https://opensource.org/licenses/BSD-3-Clause) licensing schema, that allows free modification and inclusion in commercial software. ## Project Structure @@ -33,8 +33,8 @@ Below an overview of the basic build procedure, you can find detailed instructions for each [supported environment](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) in the wiki. ## prerequisites * compilsers: GCC (Linux), MINGW or MSVC (Windows) * tools/libs: cmake, boost, openssl (Linux/MINGW). * compilsers: GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows) * tools/libs: cmake, boost. If target is linux openssl is necessary. ``` git clone https://github.com/open-license-manager/open-license-manager.git @@ -94,3 +94,7 @@ $ ./example licence OK ``` # How to contribute The project is not dead but we take our time to answer. The best interaction you can have with us is through the issue system. Have a look to the [contribution guidelines](blob/develop/CONTRIBUTING.md) We use [GitFlow](https://datasift.github.io/gitflow/IntroducingGitFlow.html) (or at least a subset of it). Remember to install the gitflow git plugin and use `develop` as default branch for your pull requests. example/CMakeLists.txt
@@ -10,7 +10,7 @@ SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) else(MSVC) set(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--exclude-libs,liblicense++_static.a") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--exclude-libs,liblicensepp_static.a") find_package(OpenSSL REQUIRED) endif(MSVC) @@ -18,7 +18,7 @@ add_executable(example example.cpp) target_link_libraries(example license++_static os base tools_base) target_link_libraries(example licensepp_static os base tools_base) if(NOT MSVC) target_link_libraries(example crypto pthread dl z) modules/toolchain-ubuntu-mingw64.cmake
New file @@ -0,0 +1,27 @@ # Sample toolchain file for building for Windows from an Ubuntu Linux system. # # Typical usage: # *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64` # *) cd build # *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw64.cmake .. set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_HOST_SYSTEM_NAME Linux) set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) # cross compilers to use for C and C++ set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) # target environment on the build host system # set 1st to dir with the cross compiler's C/C++ headers/libs set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) # modify default behavior of FIND_XXX() commands to # search for headers/libs in the target environment and # search for programs in the build host environment set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) #set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) #set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) src/library/CMakeLists.txt
@@ -2,19 +2,19 @@ add_subdirectory("base") add_subdirectory("ini") ADD_LIBRARY(license++_static STATIC ADD_LIBRARY(licensepp_static STATIC license++.cpp LicenseReader.cpp pc-identifiers.c ) target_link_libraries( license++_static licensepp_static ini os ) install(TARGETS license++_static ARCHIVE DESTINATION lib) install(TARGETS licensepp_static ARCHIVE DESTINATION lib) install(FILES api/datatypes.h api/license++.h DESTINATION include/api) install(FILES base/base.h DESTINATION include/base) install(FILES pc-identifiers.h DESTINATION include/) src/library/os/os-linux.c
@@ -2,16 +2,16 @@ #include <sys/stat.h> #include "os.h" #include "../base/logger.h" //#include <openssl/evp.h> //#include <openssl/bio.h> #include <openssl/pem.h> #include <openssl/err.h> #include <mntent.h> #include <dirent.h> #include <sys/utsname.h> #ifdef _DEBUG #include <valgrind/memcheck.h> #endif #ifdef USE_DBUS #include <dbus-1.0/dbus/dbus.h> #endif src/library/os/os.c
@@ -3,7 +3,7 @@ #include "public-key.h" #include <stdio.h> #ifndef _MSC_VER #ifdef __linux__ #include <openssl/pem.h> @@ -84,7 +84,7 @@ #else #include <iphlpapi.h> #include <Windows.h> #include <windows.h> #pragma comment(lib, "IPHLPAPI.lib") unsigned char* unbase64(const char* ascii, int len, int *flen); src/library/pc-identifiers.c
@@ -388,9 +388,12 @@ //found = false; for (i = 0; i < 2; i++) { current_strategy_id = strategy_from_pc_id(user_identifiers[i]); if (current_strategy_id == STRATEGY_UNKNOWN) { if (current_strategy_id == STRATEGY_UNKNOWN && previous_strategy_id == STRATEGY_UNKNOWN && i==1) { free(calculated_identifiers); printf("Comparing pc identifiers: %d %d %d %s\n",current_strategy_id,previous_strategy_id,i, str_code); return LICENSE_MALFORMED; } else if (current_strategy_id == STRATEGY_UNKNOWN ){ continue; } if (current_strategy_id != previous_strategy_id) { if (calculated_identifiers != NULL) { src/tools/base_lib/CMakeLists.txt
@@ -1,17 +1,17 @@ if(MSVC) if(WIN32) ADD_LIBRARY( tools_base STATIC CryptoHelper.cpp win/CryptoHelperWindows.cpp ) else(MSVC) else(WIN32) ADD_LIBRARY( tools_base STATIC CryptoHelper.cpp linux/CryptoHelperLinux.cpp ) ENDIF(MSVC) ENDIF(WIN32) target_link_libraries( tools_base src/tools/base_lib/CryptoHelper.cpp
@@ -1,8 +1,8 @@ #include <memory> #include "CryptoHelper.h" #ifndef _MSC_VER #ifdef __linux__ #include"linux/CryptoHelperLinux.h" #else #elif _WIN32 #include"win/CryptoHelperWindows.h" #endif @@ -10,11 +10,12 @@ namespace license { unique_ptr<CryptoHelper> CryptoHelper::getInstance() { #ifndef _MSC_VER #ifdef __linux__ unique_ptr<CryptoHelper> ptr((CryptoHelper*) new CryptoHelperLinux()); #else #elif _WIN32 unique_ptr<CryptoHelper> ptr((CryptoHelper*) new CryptoHelperWindows()); #endif return ptr; } } src/tools/base_lib/win/CryptoHelperWindows.cpp
@@ -71,6 +71,13 @@ string("Error generating keys ") + to_string(static_cast<long long>(dwErrCode))); } //double check the key is really generated if(m_hCryptKey == NULL) { dwErrCode = GetLastError(); throw logic_error( string("Error generating keys (2)") + to_string(static_cast<long long>(dwErrCode))); } } /* This method calls the CryptExportKey function to get the Public key src/tools/bootstrap/CMakeLists.txt
@@ -3,8 +3,7 @@ bootstrap.cpp ) SET_TARGET_PROPERTIES(bootstrap PROPERTIES LINK_SEARCH_START_STATIC ON) #SET_TARGET_PROPERTIES(bootstrap PROPERTIES LINK_SEARCH_START_STATIC ON) SET_TARGET_PROPERTIES(bootstrap PROPERTIES LINK_SEARCH_END_STATIC OFF) target_link_libraries( bootstrap @@ -12,14 +11,22 @@ ${EXTERNAL_LIBS} ) # add the command to generate the source code if(MINGW) #Cross compiling from linux host to windows IF( ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") AND CMAKE_CROSSCOMPILING) #this is to avoid to install binfmt_misc (for builds in docker, or LXC) add_custom_command ( OUTPUT "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h" COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.exe "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS bootstrap) ELSE() add_custom_command ( OUTPUT "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h" COMMAND ./bootstrap.exe "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS bootstrap) ENDIF() else(MINGW) add_custom_command ( OUTPUT "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h" @@ -27,7 +34,6 @@ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS bootstrap) endif(MINGW) add_custom_target(private_key DEPENDS "${CMAKE_BINARY_DIR}/private-key.h") add_custom_target(public_key DEPENDS "${CMAKE_BINARY_DIR}/public-key.h") src/tools/license-generator/CMakeLists.txt
@@ -1,8 +1,6 @@ include_directories(${Boost_INCLUDE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) link_directories ( ${Boost_LIBRARY_DIR} ) ADD_LIBRARY( license_generator_lib STATIC @@ -12,7 +10,7 @@ target_link_libraries( license_generator_lib tools_base license++_static licensepp_static $<$<CONFIG:Debug>:${Boost_PROGRAM_OPTIONS_LIBRARY_DEBUG}> $<$<NOT:$<CONFIG:Debug>>:${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE}> $<$<CONFIG:Debug>:${Boost_SYSTEM_LIBRARY_DEBUG}> @@ -33,5 +31,3 @@ install(TARGETS license_generator RUNTIME DESTINATION bin) #SET_TARGET_PROPERTIES(license_generator PROPERTIES LINK_SEARCH_START_STATIC ON) #SET_TARGET_PROPERTIES(license_generator PROPERTIES LINK_SEARCH_END_STATIC ON) src/tools/license-generator/license-generator.cpp
@@ -146,7 +146,7 @@ ostream& outputFile) { vector<FullLicenseInfo> licenseInfo = parseLicenseInfo(vm); const unique_ptr<CryptoHelper> helper = CryptoHelper::getInstance(); const char pkey[] = PRIVATE_KEY; const unsigned char pkey[] = PRIVATE_KEY; const size_t len = sizeof(pkey); for (auto it = licenseInfo.begin(); it != licenseInfo.end(); ++it) { const string license = it->printForSign(); test/functional/CMakeLists.txt
@@ -14,12 +14,10 @@ target_link_libraries( standard_license_test license++_static licensepp_static license_generator_snippet ${Boost_LIBRARIES} ) #SET_TARGET_PROPERTIES(standard_license_test PROPERTIES LINK_SEARCH_START_STATIC ON) #add_dependencies( standard_license_test boost_test boost_filesystem ) add_executable( date_test @@ -28,12 +26,10 @@ target_link_libraries( date_test license++_static licensepp_static license_generator_snippet ${Boost_LIBRARIES} ) #SET_TARGET_PROPERTIES(date_test PROPERTIES LINK_SEARCH_START_STATIC ON) #add_dependencies( date_test boost_test boost_filesystem ) add_executable( volid_test @@ -42,15 +38,21 @@ target_link_libraries( volid_test license++_static licensepp_static license_generator_snippet ${Boost_LIBRARIES} ) #SET_TARGET_PROPERTIES(volid_test PROPERTIES LINK_SEARCH_START_STATIC ON) #add_dependencies( volid_test boost_test boost_filesystem ) IF( ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") AND CMAKE_CROSSCOMPILING) #binfmt_misc doesn't work in my system :( ADD_TEST(NAME standard_license_test COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/standard_license_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ADD_TEST(NAME date_test COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/date_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ADD_TEST(NAME volid_test COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/volid_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ELSE() ADD_TEST(NAME standard_license_test COMMAND standard_license_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ADD_TEST(NAME date_test COMMAND date_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ADD_TEST(NAME volid_test COMMAND volid_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ENDIF() test/functional/volid_test.cpp
@@ -52,11 +52,11 @@ for (int i = 0; i < num_strategies; i++) { FUNCTION_RETURN generate_ok = generate_user_pc_signature(identifier_out, strategies[i]); BOOST_ASSERT(generate_ok == FUNC_RET_OK); if (generate_ok != FUNC_RET_OK) { BOOST_ERROR( "Generating identifier for strategy " << strategies[i] << " failed with: " << generate_ok); idfile << "0000-0000-0000-0000" << endl; BOOST_ASSERT(generate_ok == FUNC_RET_OK); } else idfile << identifier_out << endl; } @@ -66,12 +66,26 @@ BOOST_AUTO_TEST_CASE(generated_identifiers_stability) { const string idfileLocation(PROJECT_TEST_TEMP_DIR "/identifiers_file"); std::vector<IDENTIFICATION_STRATEGY> strategies; if (getVirtualization() != CONTAINER) { strategies = { DEFAULT, DISK_LABEL, DISK_NUM, ETHERNET }; size_t disk_num; getDiskInfos(NULL, &disk_num); if (disk_num >0) { strategies = { DEFAULT, DISK_NUM, DISK_LABEL }; } else { strategies = { DEFAULT, ETHERNET }; BOOST_TEST_CHECKPOINT("if no disk default strategy fails see #49"); //strategies = { DEFAULT }; strategies = {}; } size_t adapters; getAdapterInfos(nullptr, &adapters); if(adapters > 0){ strategies.push_back(ETHERNET); } int num_strategies = strategies.size(); if(num_strategies == 0) { //see issue #49 can't use default return; } std::ifstream test_idfile_exist(idfileLocation); if (!test_idfile_exist.good()) { generate_reference_file(idfileLocation, strategies.data(), test/library/CMakeLists.txt
@@ -2,17 +2,19 @@ license_reader_test LicenseReader_test.cpp ) #add_dependencies( license_reader_test boost_filesystem ) target_link_libraries( license_reader_test license++_static licensepp_static ${Boost_LIBRARIES} ) #SET_TARGET_PROPERTIES(license_reader_test PROPERTIES LINK_SEARCH_START_STATIC ON) #SET_TARGET_PROPERTIES(license_reader_test PROPERTIES LINK_SEARCH_END_STATIC OFF) IF( ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") AND CMAKE_CROSSCOMPILING) #binfmt_misc doesn't work in my system :( ADD_TEST(NAME license_reader_test COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/license_reader_test) ELSE() ADD_TEST(NAME license_reader_test COMMAND license_reader_test) ENDIF() IF(WIN32) #test windows @@ -28,8 +30,5 @@ ${Boost_LIBRARIES} ) #add_dependencies( os_linux_test ) #SET_TARGET_PROPERTIES(os_linux_test PROPERTIES LINK_SEARCH_START_STATIC ON) ADD_TEST(NAME os_linux_test COMMAND os_linux_test) ENDIF(WIN32) test/license-generator/CMakeLists.txt
@@ -10,6 +10,8 @@ ${Boost_LIBRARIES} ) #add_dependencies( license_generator_test boost_test boost_filesystem ) #SET_TARGET_PROPERTIES(license_generator_test PROPERTIES LINK_SEARCH_START_STATIC ON) IF( ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") AND CMAKE_CROSSCOMPILING) ADD_TEST(NAME license_generator_test COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/license_generator_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ELSE() ADD_TEST(NAME license_generator_test COMMAND license_generator_test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ENDIF()