19个文件已修改
1个文件已添加
1 文件已重命名
| | |
| | | - os: linux |
| | | dist: bionic |
| | | name: "Ubuntu 18.04 - Travis CI VM" |
| | | env: |
| | | - VIRTUAL_ENV=VM |
| | | addons: |
| | | apt: |
| | | packages: |
| | |
| | | - os: linux |
| | | dist: bionic |
| | | name: "Ubuntu 18.04 - Travis CI VM - Debug build" |
| | | env: |
| | | - VIRTUAL_ENV=VM |
| | | addons: |
| | | apt: |
| | | packages: |
| | |
| | | script: |
| | | - cmake --build . --target install |
| | | - ctest |
| | | - ctest -T memcheck |
| | | after_success: |
| | | # Create lcov report |
| | | - lcov --capture --directory . --output-file coverage.info |
| | |
| | | - lcov --list coverage.info # debug info |
| | | # Uploading report to CodeCov |
| | | - bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports" |
| | | |
| | | - os: linux |
| | | dist: bionic |
| | | name: "CentOS-7 Docker" |
| | |
| | | - docker commit centos8_toconfigure centos8_configured |
| | | script: |
| | | - docker run --name centos8_make -v `pwd`:/root/open-license-manager centos8_configured /bin/bash -c \ |
| | | "cd /root/open-license-manager/build && make && make install && VIRT_ENV=CONTAINER make test" |
| | | "cd /root/open-license-manager/build && make && make install && VIRTUAL_ENV=DOCKER make test" |
| | | - os: linux |
| | | dist: bionic |
| | | name: "Ubuntu 18.04 - MinGW cross-compile for Windows x64" |
| | |
| | | ENDIF(${STATIC_RUNTIME}) |
| | | find_package(OpenSSL COMPONENTS Crypto QUIET) |
| | | IF(OPENSSL_FOUND) |
| | | MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION}") |
| | | MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} -licensecc") |
| | | ENDIF(OPENSSL_FOUND) |
| | | |
| | | if(UNIX) #this is true for all the linux systems but not for cross compiling "linux->windows" |
| | | IF(${STATIC_RUNTIME}) |
| | | set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") |
| | | #SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") |
| | | ENDIF(${STATIC_RUNTIME}) |
| | | IF(NOT OPENSSL_FOUND) |
| | | MESSAGE(SEND_ERROR "Openssl required in Linux, please install it or specify -DOPENSSL_ROOT") |
| | | ENDIF(NOT OPENSSL_FOUND) |
| | | |
| | | #Zlib required when openssl version < 1.0.1f (centos 7) |
| | | IF(OPENSSL_VERSION VERSION_LESS 1.0.2) |
| | | SET ( ZLIB_USE_STATIC_LIBS ON ) |
| | | find_package(ZLIB REQUIRED) |
| | | list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES}) |
| | | MESSAGE(STATUS "Found zlib version ${ZLIB_VERSION_STRING} - licensecc") |
| | | ENDIF(OPENSSL_VERSION VERSION_LESS 1.0.2) |
| | | find_package(Threads) |
| | | if(THREADS_HAVE_PTHREAD_ARG) |
| | | list(APPEND EXTERNAL_LIBS "-pthread") |
| | |
| | | endif() |
| | | endif(THREADS_HAVE_PTHREAD_ARG) |
| | | |
| | | #Zlib required when openssl version < 1.0.1f (centos 7) |
| | | IF(OPENSSL_VERSION VERSION_LESS_EQUAL 1.0.2) |
| | | SET ( ZLIB_USE_STATIC_LIBS ON ) |
| | | find_package(ZLIB REQUIRED) |
| | | list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES}) |
| | | MESSAGE(STATUS "Found zlib version ${ZLIB_VERSION_STRING} - licensecc") |
| | | ELSE(OPENSSL_VERSION VERSION_LESS_EQUAL 1.0.2) |
| | | MESSAGE(STATUS "openssl ${OPENSSL_VERSION} zlib not required - licensecc") |
| | | ENDIF(OPENSSL_VERSION VERSION_LESS_EQUAL 1.0.2) |
| | | |
| | | find_program( MEMORYCHECK_COMMAND valgrind ) |
| | | set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" ) |
| | | set(main_lib_dest "lib/${PROJECT_NAME}") |
| | |
| | | #include <licensecc/licensecc.h> |
| | | #include <fstream> |
| | | #include "../library/os/cpu_info.hpp" |
| | | #include "../library/os/execution_environment.hpp" |
| | | |
| | | using namespace std; |
| | | using namespace license::os; |
| | | |
| | | struct enum_hash { |
| | | template <typename T> |
| | | constexpr typename std::enable_if<std::is_enum<T>::value, std::size_t>::type operator()(T s) const noexcept { |
| | | return static_cast<std::size_t>(s); |
| | | } |
| | | }; |
| | | const map<int, string> stringByStrategyId = {{STRATEGY_DEFAULT, "DEFAULT"}, {STRATEGY_ETHERNET, "MAC"}, |
| | | {STRATEGY_IP_ADDRESS, "IP"}, {STRATEGY_DISK_NUM, "Disk1"}, |
| | | {STRATEGY_DISK_LABEL, "Disk2"}, {STRATEGY_NONE, "Custom"}}; |
| | | |
| | | const map<LCC_API_IDENTIFICATION_STRATEGY, string, enum_hash> stringByStrategyId = { |
| | | {STRATEGY_DEFAULT, "DEFAULT"}, {STRATEGY_ETHERNET, "MAC"}, {STRATEGY_IP_ADDRESS, "IP"}, |
| | | {STRATEGY_DISK_NUM, "Disk1"}, {STRATEGY_DISK_LABEL, "Disk2"}, {STRATEGY_NONE, "Custom"}}; |
| | | |
| | | const unordered_map<LCC_EVENT_TYPE, string, enum_hash> stringByEventType = { |
| | | const unordered_map<int, string> descByVirtDetail = {{BARE_TO_METAL, "No virtualization"}, |
| | | {VMWARE, "Vmware"}, |
| | | {VIRTUALBOX, "Virtualbox"}, |
| | | {V_XEN, "XEN"}, |
| | | {KVM, "KVM"}, |
| | | {HV, "Microsoft Hypervisor"}, |
| | | {V_OTHER, "Other type of vm"}}; |
| | | |
| | | const unordered_map<int, string> descByVirt = { |
| | | {VIRTUALIZATION::NONE, "No virtualization"}, {VIRTUALIZATION::VM, "VM"}, {VIRTUALIZATION::CONTAINER, "Container"}}; |
| | | |
| | | const unordered_map<int, string> stringByEventType = { |
| | | {LICENSE_OK, "OK "}, |
| | | {LICENSE_FILE_NOT_FOUND, "license file not found "}, |
| | | {LICENSE_SERVER_NOT_FOUND, "license server can't be contacted "}, |
| | |
| | | cout << "CpuVendor :" << cpu.vendor() << endl; |
| | | cout << "Virtual machine:" << cpu.cpu_virtual() << endl; |
| | | cout << "Cpu model : 0x" << std::hex << ((long)cpu.model()) << std::dec << endl; |
| | | cout << "Virt. detail cpu:" << descByVirtDetail.find(cpu.getVirtualizationDetail())->second << endl; |
| | | ExecutionEnvironment execEnv; |
| | | cout << "Running in cloud:" << execEnv.is_cloud() << endl; |
| | | cout << "Docker :" << execEnv.is_docker() << endl; |
| | | cout << "other container :" << execEnv.is_container() << endl; |
| | | cout << "Virtualiz. class:" << descByVirt.find(execEnv.getVirtualization())->second << endl; |
| | | |
| | | cout << "Bios vendor :" << execEnv.bios_vendor() << endl; |
| | | cout << "Bios description:" << execEnv.bios_description() << endl; |
| | | cout << "System vendor :" << execEnv.sys_vendor() << endl; |
| | | |
| | | char hw_identifier[LCC_API_PC_IDENTIFIER_SIZE + 1]; |
| | | size_t bufSize = LCC_API_PC_IDENTIFIER_SIZE + 1; |
| | | for (const auto& x : stringByStrategyId) { |
| | | if (identify_pc(x.first, hw_identifier, &bufSize)) { |
| | | if (identify_pc(static_cast<LCC_API_IDENTIFICATION_STRATEGY>(x.first), hw_identifier, &bufSize)) { |
| | | std::cout << x.second << ':' << hw_identifier << std::endl; |
| | | |
| | | } else { |
| | | std::cout << x.second << ": NA" << endl; |
| | | } |
| | |
| | | ++it; |
| | | } |
| | | std::string::const_reverse_iterator rit = string_to_trim.rbegin(); |
| | | while (rit.base() != it && isspace(*rit)) { |
| | | while (rit.base() != it && (isspace(*rit) || *rit == 0)) { |
| | | ++rit; |
| | | } |
| | | return std::string(it, rit.base()); |
| | |
| | | size_t disk_num = 0; |
| | | size_t available_disk_info = 0; |
| | | FUNCTION_RETURN result_diskinfos; |
| | | unsigned int i; |
| | | |
| | | result_diskinfos = getDiskInfos(nullptr, &disk_num); |
| | | if (result_diskinfos != FUNC_RET_OK && result_diskinfos != FUNC_RET_BUFFER_TOO_SMALL) { |
| | |
| | | free(diskInfos); |
| | | return result_diskinfos; |
| | | } |
| | | for (i = 0; i < disk_num; i++) { |
| | | for (unsigned int i = 0; i < disk_num; i++) { |
| | | char firstChar = use_id ? diskInfos[i].label[0] : diskInfos[i].disk_sn[0]; |
| | | available_disk_info += firstChar == 0 ? 0 : 1; |
| | | } |
| | |
| | | return FUNC_RET_NOT_AVAIL; |
| | | } |
| | | v_disk_id.reserve(available_disk_info); |
| | | //FIXME use preferred drive. |
| | | for (i = 0; i < disk_num; i++) { |
| | | for (int j = 0; j < 2; j++) { |
| | | int preferred = (j == 0 ? 1 : 0); |
| | | for (unsigned int i = 0; i < disk_num; i++) { |
| | | array<uint8_t, HW_IDENTIFIER_PROPRIETARY_DATA> a_disk_id; |
| | | a_disk_id.fill(0); |
| | | if (use_id) { |
| | | if (diskInfos[i].disk_sn[0] != 0) { |
| | | if (diskInfos[i].disk_sn[0] != 0 && diskInfos[i].preferred == preferred) { |
| | | size_t size = min(a_disk_id.size(), sizeof(&diskInfos[i].disk_sn)); |
| | | memcpy(&a_disk_id[0], diskInfos[i].disk_sn, size); |
| | | v_disk_id.push_back(a_disk_id); |
| | | } |
| | | } else { |
| | | if (diskInfos[i].label[0] != 0) { |
| | | if (diskInfos[i].label[0] != 0 && diskInfos[i].preferred == preferred) { |
| | | strncpy((char *)&a_disk_id[0], diskInfos[i].label, a_disk_id.size()-1); |
| | | v_disk_id.push_back(a_disk_id); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | FUNCTION_RETURN result = generate_disk_pc_id(data, m_use_id); |
| | | vector<HwIdentifier> identifiers; |
| | | if (result == FUNC_RET_OK) { |
| | | identifiers.resize(data.size()); |
| | | identifiers.reserve(data.size()); |
| | | for (auto &it : data) { |
| | | HwIdentifier pc_id; |
| | | pc_id.set_identification_strategy(identification_strategy()); |
| | |
| | | FUNCTION_RETURN result = generate_ethernet_pc_id(data, use_ip); |
| | | vector<HwIdentifier> identifiers; |
| | | if (result == FUNC_RET_OK) { |
| | | identifiers.resize(data.size()); |
| | | identifiers.reserve(data.size()); |
| | | for (auto &it : data) { |
| | | HwIdentifier pc_id; |
| | | pc_id.set_identification_strategy(identification_strategy()); |
| | |
| | | HwIdentifier pc_id; |
| | | FUNCTION_RETURN result = strategy_ptr->identify_pc(pc_id); |
| | | if (result != FUNC_RET_OK) { |
| | | /// FIXME |
| | | throw logic_error("strategy " + to_string(strategy_ptr->identification_strategy()) + " failed"); |
| | | } |
| | | os::ExecutionEnvironment exec; |
| | | os::VIRTUALIZATION virtualization = exec.getVirtualization(); |
| | |
| | | virtual ~HwIdentifierFacade(){}; |
| | | public: |
| | | static LCC_EVENT_TYPE validate_pc_signature(const std::string& str_code); |
| | | /** |
| | | * |
| | | * @throws logic_error if pc_identifier can't be generated. |
| | | * @param strategy |
| | | * @return |
| | | */ |
| | | static std::string generate_user_pc_signature(LCC_API_IDENTIFICATION_STRATEGY strategy); |
| | | }; |
| | | |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | std::unique_ptr<IdentificationStrategy> IdentificationStrategy::get_strategy(LCC_API_IDENTIFICATION_STRATEGY strategy) { |
| | | unique_ptr<IdentificationStrategy> result; |
| | | switch (strategy) { |
| | |
| | | } |
| | | return is_virtual; |
| | | } |
| | | |
| | | VIRTUALIZATION_DETAIL CpuInfo::getVirtualizationDetail() const { |
| | | string cpu_vendor = vendor(); |
| | | auto it = virtual_cpu_names.find(cpu_vendor); |
| | |
| | | |
| | | class ExecutionEnvironment { |
| | | private: |
| | | std::string sys_vendor; |
| | | std::string bios_vendor; |
| | | std::string bios_description; |
| | | // detect if it's a kind of container technology (docker or lxc) |
| | | bool is_container() const; |
| | | std::string m_sys_vendor; |
| | | std::string m_bios_vendor; |
| | | std::string m_bios_description; |
| | | |
| | | public: |
| | | ExecutionEnvironment(); |
| | |
| | | VIRTUALIZATION getVirtualization() const; |
| | | bool is_cloud() const; |
| | | bool is_docker() const; |
| | | // detect if it's a kind of container technology (docker or lxc) |
| | | bool is_container() const; |
| | | CLOUD_PROVIDER getCloudProvider() const; |
| | | const std::string& bios_vendor() const { return m_bios_vendor; }; |
| | | const std::string& sys_vendor() const { return m_sys_vendor; }; |
| | | const std::string& bios_description() const { return m_bios_description; }; |
| | | // VIRTUALIZATION_DETAIL getVirtualizationDetail() const; //as reported by the bios |
| | | }; |
| | | |
| | | } // namespace os |
| | |
| | | return result; |
| | | } |
| | | |
| | | bool ExecutionEnvironment::is_cloud() const { return getCloudProvider() != ON_PREMISE; } |
| | | bool ExecutionEnvironment::is_cloud() const { |
| | | CLOUD_PROVIDER prov = getCloudProvider(); |
| | | return prov != ON_PREMISE && prov != PROV_UNKNOWN; |
| | | } |
| | | |
| | | // TODO test and azure |
| | | CLOUD_PROVIDER ExecutionEnvironment::getCloudProvider() const { |
| | | CLOUD_PROVIDER result = PROV_UNKNOWN; |
| | | if (bios_description.size() > 0 || bios_vendor.size() > 0 || sys_vendor.size() > 0) { |
| | | if (bios_vendor.find("SEABIOS") != string::npos || bios_description.find("ALIBABA") != string::npos || |
| | | sys_vendor.find("ALIBABA") != string::npos) { |
| | | if (m_bios_description.size() > 0 || m_bios_vendor.size() > 0 || m_sys_vendor.size() > 0) { |
| | | if (m_bios_vendor.find("SEABIOS") != string::npos || m_bios_description.find("ALIBABA") != string::npos || |
| | | m_sys_vendor.find("ALIBABA") != string::npos) { |
| | | result = ALI_CLOUD; |
| | | } else if (sys_vendor.find("GOOGLE") != string::npos || bios_description.find("GOOGLE") != string::npos) { |
| | | } else if (m_sys_vendor.find("GOOGLE") != string::npos || m_bios_description.find("GOOGLE") != string::npos) { |
| | | result = GOOGLE_CLOUD; |
| | | } else if (bios_vendor.find("AWS") != string::npos || bios_description.find("AMAZON") != string::npos || |
| | | sys_vendor.find("AWS") != string::npos) { |
| | | } else if (m_bios_vendor.find("AWS") != string::npos || m_bios_description.find("AMAZON") != string::npos || |
| | | m_sys_vendor.find("AWS") != string::npos) { |
| | | result = AWS; |
| | | } else if (m_bios_description.find("HP-COMPAQ") != string::npos || m_bios_description.find("ASUS") || |
| | | m_bios_description.find("DELL")) { |
| | | result = ON_PREMISE; |
| | | } |
| | | } |
| | | return result; |
| | |
| | | #include "../cpu_info.hpp" |
| | | #include "../execution_environment.hpp" |
| | | #include "../../base/file_utils.hpp" |
| | | #include "../../base/StringUtils.h" |
| | | |
| | | namespace license { |
| | | namespace os { |
| | |
| | | |
| | | ExecutionEnvironment::ExecutionEnvironment() { |
| | | try { |
| | | bios_vendor = get_file_contents("/sys/class/dmi/id/sys_vendor", 256); |
| | | m_bios_vendor = toupper_copy(trim_copy(get_file_contents("/sys/class/dmi/id/sys_vendor", 256))); |
| | | |
| | | } catch (...) { |
| | | } |
| | | try { |
| | | bios_description = get_file_contents("/sys/class/dmi/id/modalias", 256); |
| | | m_bios_description = toupper_copy(trim_copy(get_file_contents("/sys/class/dmi/id/modalias", 256))); |
| | | char last_char = m_bios_description[m_bios_description.length() - 1]; |
| | | if (last_char == '\r' || last_char == '\n') { |
| | | m_bios_description = m_bios_description.erase(m_bios_description.length() - 1); |
| | | } |
| | | } catch (...) { |
| | | } |
| | | try { |
| | | sys_vendor = get_file_contents("/sys/class/dmi/id/sys_vendor", 256); |
| | | m_sys_vendor = get_file_contents("/sys/class/dmi/id/sys_vendor", 256); |
| | | char last_char = m_sys_vendor[m_sys_vendor.length() - 2]; |
| | | if (last_char == '\r' || last_char == '\n') { |
| | | m_sys_vendor = m_sys_vendor.erase(m_sys_vendor.length() - 1); |
| | | } |
| | | } catch (...) { |
| | | } |
| | | } |
| | |
| | | if (strcmp(ent->mnt_dir, "/") == 0) { |
| | | strcpy(tmpDrives[drive_found].label, "root"); |
| | | LOG_DEBUG("drive %s set to preferred\n", ent->mnt_fsname); |
| | | tmpDrives[drive_found].preferred = true; |
| | | tmpDrives[drive_found].preferred = 1; |
| | | } else { |
| | | tmpDrives[drive_found].preferred = 0; |
| | | } |
| | | } |
| | | } |
| | |
| | | } else { |
| | | result = FUNC_RET_BUFFER_TOO_SMALL; |
| | | } |
| | | /* |
| | | FILE *mounts = fopen(_PATH_MOUNTED, "r"); |
| | | if (mounts == NULL) { |
| | | return ERROR; |
| | | } |
| | | |
| | | while (fscanf(mounts, "%64s %64s %64s %1024[^\n]", device, name, type, |
| | | discard) != EOF) { |
| | | if (stat(device, &mount_stat) != 0) |
| | | continue; |
| | | if (filename_stat.st_dev == mount_stat.st_rdev) { |
| | | fprintf(stderr, "device: %s; name: %s; type: %s\n", device, name, |
| | | type); |
| | | } |
| | | } |
| | | */ |
| | | free(statDrives); |
| | | return result; |
| | | } |
| | |
| | | if (InitEntryPoints()) { |
| | | BIOSReader reader; |
| | | SystemInformation info = reader.readSystemInfo(); |
| | | sys_vendor = toupper_copy(info.Manufacturer); |
| | | bios_vendor = toupper_copy(info.ProductName); |
| | | bios_description = toupper_copy(info.SysVersion) + toupper_copy(info.family); |
| | | m_sys_vendor = toupper_copy(info.Manufacturer); |
| | | m_bios_vendor = toupper_copy(info.ProductName); |
| | | m_bios_description = toupper_copy(info.SysVersion) + toupper_copy(info.family); |
| | | } |
| | | } |
| | | |
| | |
| | | BCRYPT_ALG_HANDLE hSignAlg = nullptr; |
| | | |
| | | vector<uint8_t> signatureBlob = unbase64(signatureBuffer); |
| | | DWORD dwSigLen = signatureBlob.size(); |
| | | DWORD dwSigLen = (DWORD) signatureBlob.size(); |
| | | BYTE* sigBlob = &signatureBlob[0]; |
| | | |
| | | if (NT_SUCCESS(status = BCryptOpenAlgorithmProvider(&hSignAlg, BCRYPT_RSA_ALGORITHM, NULL, 0))) { |
| | |
| | | test_signature_verifier |
| | | licensecc_static |
| | | license_generator_snippet |
| | | ${EXTERNAL_LIBS} |
| | | Boost::unit_test_framework |
| | | Boost::filesystem |
| | | Boost::system |
| | |
| | | } |
| | | } |
| | | |
| | | // To test if virtualization is detected correctly define an env variable VIRT_ENV |
| | | // otherwise the test is skipped |
| | | BOOST_AUTO_TEST_CASE(test_virtualization) { |
| | | const char *env = getenv("VIRT_ENV"); |
| | | os::ExecutionEnvironment exec_env; |
| | | if (env != NULL) { |
| | | if (strcmp(env, "CONTAINER") == 0) { |
| | | os::VIRTUALIZATION virt = exec_env.getVirtualization(); |
| | | BOOST_CHECK_MESSAGE(virt == VIRTUALIZATION::CONTAINER, "container detected"); |
| | | } else if (strcmp(env, "VM") == 0) { |
| | | BOOST_FAIL("check for vm not implemented"); |
| | | } else if (strcmp(env, "NONE") == 0) { |
| | | os::VIRTUALIZATION virt = exec_env.getVirtualization(); |
| | | BOOST_CHECK_EQUAL(virt, VIRTUALIZATION::NONE); |
| | | } else { |
| | | BOOST_FAIL(string("value ") + env + " not supported: VM,CONTAINER,NONE"); |
| | | } |
| | | } |
| | | } |
| | | } // namespace test |
| | | } // namespace license |
| | |
| | | |
| | | ADD_TEST(NAME test_network COMMAND test_network) |
| | | |
| | | add_executable( test_execution_environment |
| | | execution_environment_test.cpp |
| | | ) |
| | | |
| | | target_link_libraries( test_execution_environment |
| | | licensecc_static |
| | | Boost::unit_test_framework |
| | | Boost::filesystem |
| | | Boost::system |
| | | ) |
| | | |
| | | ADD_TEST(NAME test_execution_environment COMMAND test_execution_environment) |
| | | if(CODE_COVERAGE AND UNIX) |
| | | target_compile_options(test_network PUBLIC -O0 -g --coverage) |
| | | target_compile_options(test_execution_environment PUBLIC -O0 -g --coverage) |
| | | endif(CODE_COVERAGE AND UNIX) |
New file |
| | |
| | | #define BOOST_TEST_MODULE network_test |
| | | #include <string> |
| | | #include <iostream> |
| | | #include <boost/test/unit_test.hpp> |
| | | |
| | | #include <licensecc_properties.h> |
| | | #include <licensecc_properties_test.h> |
| | | #include "../../src/library/base/StringUtils.h" |
| | | #include "../../src/library/os/network.hpp" |
| | | #include "../../src/library/os/execution_environment.hpp" |
| | | |
| | | namespace license { |
| | | namespace os { |
| | | namespace test { |
| | | |
| | | using namespace license::os; |
| | | using namespace std; |
| | | |
| | | // To test if virtualization is detected correctly define an env variable VIRT_ENV |
| | | // otherwise the test is skipped |
| | | BOOST_AUTO_TEST_CASE(test_virtualization) { |
| | | const char *env = getenv("VIRTUAL_ENV"); |
| | | os::ExecutionEnvironment exec_env; |
| | | bool docker = false; |
| | | if (env != nullptr) { |
| | | os::VIRTUALIZATION virt = exec_env.getVirtualization(); |
| | | if (strcmp(env, "CONTAINER") == 0 || (docker = (strcmp(env, "DOCKER") == 0))) { |
| | | BOOST_CHECK_MESSAGE(virt == VIRTUALIZATION::CONTAINER, "container detected"); |
| | | BOOST_CHECK_MESSAGE(exec_env.is_container(), "container detected"); |
| | | if (docker) { |
| | | BOOST_CHECK_MESSAGE(exec_env.is_docker(), "docker detected"); |
| | | } |
| | | } else if (strcmp(env, "VM") == 0) { |
| | | BOOST_CHECK_MESSAGE(virt == VIRTUALIZATION::VM, "VM detected"); |
| | | BOOST_CHECK_MESSAGE(!exec_env.is_container(), "VM is not a container"); |
| | | BOOST_CHECK_MESSAGE(!exec_env.is_docker(), "VM is not a docker"); |
| | | } else if (strcmp(env, "NONE") == 0) { |
| | | BOOST_CHECK_EQUAL(virt, VIRTUALIZATION::NONE); |
| | | BOOST_CHECK_MESSAGE(!exec_env.is_container(), "not a container"); |
| | | BOOST_CHECK_MESSAGE(!exec_env.is_docker(), "not a docker"); |
| | | } else { |
| | | BOOST_FAIL(string("value ") + env + " not supported: VM,DOCKER,CONTAINER,NONE"); |
| | | } |
| | | } |
| | | } |
| | | } // namespace test |
| | | } // namespace os |
| | | } // namespace license |