From 79b1b57045e86d9845e352c3f2aa0efbab6111a9 Mon Sep 17 00:00:00 2001
From: gcontini <1121667+gcontini@users.noreply.github.com>
Date: 周六, 14 3月 2020 10:19:09 +0800
Subject: [PATCH] tests and improvements

---
 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