From a1b64080d1525a7a65e53f33d1a3fd257957e732 Mon Sep 17 00:00:00 2001 From: Gabriele Contini <contini.mailing@gmail.com> Date: 周日, 15 3月 2020 11:00:39 +0800 Subject: [PATCH] fix compilation errors --- test/library/Os_Linux_test.cpp | 30 ++++++------------------------ 1 files changed, 6 insertions(+), 24 deletions(-) diff --git a/test/library/Os_Linux_test.cpp b/test/library/Os_Linux_test.cpp index 21e94e0..527da44 100644 --- a/test/library/Os_Linux_test.cpp +++ b/test/library/Os_Linux_test.cpp @@ -10,13 +10,14 @@ #include "../../src/library/os/execution_environment.hpp" namespace license { -using namespace std; namespace test { +using namespace std; +using namespace os; BOOST_AUTO_TEST_CASE(read_disk_id) { - ExecutionEnvironment exec_env; - VIRTUALIZATION virt = exec_env.getVirtualization(); - if (virt == NONE || virt == VM) { + os::ExecutionEnvironment exec_env; + os::VIRTUALIZATION virt = exec_env.getVirtualization(); + if (virt == VIRTUALIZATION::NONE || virt == VIRTUALIZATION::VM) { DiskInfo *diskInfos = NULL; size_t disk_info_size = 0; FUNCTION_RETURN result = getDiskInfos(NULL, &disk_info_size); @@ -29,7 +30,7 @@ BOOST_CHECK_GT(mstrnlen_s(diskInfos[0].label, sizeof diskInfos[0].label), 0); BOOST_CHECK_GT(diskInfos[0].disk_sn[0], 0); free(diskInfos); - } else if (virt == CONTAINER) { + } else if (virt == VIRTUALIZATION::CONTAINER) { // docker or lxc diskInfo is not meaningful DiskInfo *diskInfos = NULL; size_t disk_info_size = 0; @@ -38,24 +39,5 @@ } } -// 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"); - ExecutionEnvironment exec_env; - if (env != NULL) { - if (strcmp(env, "CONTAINER") == 0) { - VIRTUALIZATION virt = exec_env.getVirtualization(); - BOOST_CHECK_MESSAGE(virt == CONTAINER, "container detected"); - } else if (strcmp(env, "VM") == 0) { - BOOST_FAIL("check for vm not implemented"); - } else if (strcmp(env, "NONE") == 0) { - VIRTUALIZATION virt = exec_env.getVirtualization(); - BOOST_CHECK_EQUAL(virt, NONE); - } else { - BOOST_FAIL(string("value ") + env + " not supported: VM,CONTAINER,NONE"); - } - } -} } // namespace test } // namespace license -- Gitblit v1.9.1