From e47ba06a4a6d670708c5958f195cedb1dea738fe Mon Sep 17 00:00:00 2001
From: Toni Uhlig <matzeton@googlemail.com>
Date: Fri, 18 Oct 2019 04:38:31 +0200
Subject: minimal integration test added (test KI handshake/shutdown)

---
 IntegrationTest/IntegrationTest.cpp     | 41 +++++++++++++++++++++++----------
 IntegrationTest/IntegrationTest.vcxproj |  3 +++
 2 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/IntegrationTest/IntegrationTest.cpp b/IntegrationTest/IntegrationTest.cpp
index bbec9da..9a72488 100644
--- a/IntegrationTest/IntegrationTest.cpp
+++ b/IntegrationTest/IntegrationTest.cpp
@@ -2,20 +2,37 @@
 //
 
 #include "pch.h"
+#include "KInterface.h"
+
 #include <iostream>
 
 int main()
 {
-    std::cout << "Hello World!\n"; 
-}
-
-// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
-// Debug program: F5 or Debug > Start Debugging menu
+	std::cout << "IntegrationTest\n";
 
-// Tips for Getting Started: 
-//   1. Use the Solution Explorer window to add/manage files
-//   2. Use the Team Explorer window to connect to source control
-//   3. Use the Output window to see build output and other messages
-//   4. Use the Error List window to view errors
-//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
-//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
+	try {
+		KInterface &ki = KInterface::getInstance();
+		if (!ki.Init()) {
+			std::wcout << L"Kernel Interface Init() failed" << std::endl;
+			goto error;
+		}
+		if (!ki.Handshake()) {
+			std::wcout << L"Kernel Interface Handshake() failed" << std::endl;
+			goto error;
+		}
+		if (ki.RecvWait() == SRR_TIMEOUT) {
+			std::wcout << L"Ping -> ";
+			if (!ki.Ping()) {
+				std::wcout << L"Got no valid PONG, abort!" << std::endl;
+			}
+			else std::wcout << L"PONG!" << std::endl;
+		}
+		std::wcout << L"Driver shutdown .." << std::endl;
+		ki.Exit();
+	}
+	catch (std::runtime_error& err) {
+		std::wcout << err.what() << std::endl;
+	}
+error:
+	Sleep(3000);
+}
\ No newline at end of file
diff --git a/IntegrationTest/IntegrationTest.vcxproj b/IntegrationTest/IntegrationTest.vcxproj
index ef706b2..0213625 100644
--- a/IntegrationTest/IntegrationTest.vcxproj
+++ b/IntegrationTest/IntegrationTest.vcxproj
@@ -83,6 +83,7 @@
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <LinkIncremental>false</LinkIncremental>
+    <TargetName>$(ProjectName)-kmem</TargetName>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
@@ -145,6 +146,7 @@
       <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ConformanceMode>true</ConformanceMode>
       <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <SubSystem>Console</SubSystem>
@@ -152,6 +154,7 @@
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <AdditionalLibraryDirectories>$(VCToolsInstallDir)lib\x64;$(OutputPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;MemDriverLib.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-- 
cgit v1.2.3