[commit] r2306 - in trunk/Tests/GPyUnit: . Leaks Leaks/TestGMELeaks

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Tue Aug 27 09:22:10 CDT 2013


Author: ksmyth
Date: Tue Aug 27 09:22:10 2013
New Revision: 2306

Log:
Automated leak test

Added:
   trunk/Tests/GPyUnit/Leaks/
   trunk/Tests/GPyUnit/Leaks/TestGMELeaks/
   trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.cpp
   trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.sln
   trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.vcxproj
   trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.vcxproj.filters
   trunk/Tests/GPyUnit/test_leaks.py

Added: trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.cpp	Tue Aug 27 09:22:10 2013	(r2306)
@@ -0,0 +1,70 @@
+
+#define UNICODE
+#define _UNICODE
+
+#if !defined(__INTELLISENSE__)
+#import "libid:9E9AAACF-28B8-11D3-B36C-0060082DF884" // Core
+#import "libid:0ADEEC71-D83A-11D3-B36B-005004D38590" // Meta
+#import "libid:270B4F86-B17C-11D3-9AD1-00AA00B6FE26" // Mga
+#else
+// IntelliSense has a known issue with the above lines.
+//  http://connect.microsoft.com/VisualStudio/feedback/details/533526/vc-2010-intellisense-import-directive-using-libid-does-not-work
+#ifdef _DEBUG
+// If IntelliSense reports "Cannot open source file", compile then reopen the project
+// KMS: VS intellisense has a hard time loading from typelib GUID. This fixes it:
+#include "Debug\Core.tlh"
+#include "Debug\Mga.tlh"
+#include "Debug\Meta.tlh"
+#else
+#include "Release\Core.tlh"
+#include "Release\Mga.tlh"
+#include "Release\Meta.tlh"
+#endif
+#endif
+
+#include <Windows.h>
+#include <comdef.h>
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+	setbuf(stdout, NULL);
+	char* gme_root = getenv("GME_ROOT");
+	if (gme_root == NULL)
+	{
+		printf("GME_ROOT not defined\n");
+		return 12;
+	}
+	CoInitialize(0);
+	for (int i = 0; i < 14; i++)
+	{
+		try
+		{
+			using namespace MGALib;
+			IMgaProjectPtr project;
+			project.CreateInstance(L"MGA.MgaProject", 0, CLSCTX_INPROC);
+			project->OpenEx(_bstr_t("MGA=") + _bstr_t(gme_root) + L"\\Paradigms\\MetaGME\\MetaGME-model.mga", _bstr_t("MetaGME"), _variant_t());
+			project->BeginTransactionInNewTerr(TRANSACTION_GENERAL);
+			project->CommitTransaction();
+			project->Close(VARIANT_TRUE);
+		}
+		catch (_com_error& e)
+		{
+			wprintf(L"%s\n", e.ErrorMessage());
+			return 11;
+		}
+		if (i == 0)
+		{
+			wprintf(L"%S starting\n", argv[0]);
+			while (fgetc(stdin) != '\n')
+				;
+		}
+	}
+
+	CoFreeUnusedLibraries();
+	CoUninitialize();
+	wprintf(L"%S finished\n", argv[0]);
+	while (fgetc(stdin) != '\n')
+		;
+	return 0;
+}

Added: trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.sln
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.sln	Tue Aug 27 09:22:10 2013	(r2306)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestGMELeaks", "TestGMELeaks.vcxproj", "{AC29FFB3-C461-4D5F-9299-6C3CED1FD47F}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{AC29FFB3-C461-4D5F-9299-6C3CED1FD47F}.Debug|Win32.ActiveCfg = Debug|Win32
+		{AC29FFB3-C461-4D5F-9299-6C3CED1FD47F}.Debug|Win32.Build.0 = Debug|Win32
+		{AC29FFB3-C461-4D5F-9299-6C3CED1FD47F}.Release|Win32.ActiveCfg = Release|Win32
+		{AC29FFB3-C461-4D5F-9299-6C3CED1FD47F}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

Added: trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.vcxproj
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.vcxproj	Tue Aug 27 09:22:10 2013	(r2306)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{AC29FFB3-C461-4D5F-9299-6C3CED1FD47F}</ProjectGuid>
+    <RootNamespace>TestGMELeaks</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="TestGMELeaks.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file

Added: trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.vcxproj.filters
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.vcxproj.filters	Tue Aug 27 09:22:10 2013	(r2306)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="TestGMELeaks.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>
\ No newline at end of file

Added: trunk/Tests/GPyUnit/test_leaks.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Tests/GPyUnit/test_leaks.py	Tue Aug 27 09:22:10 2013	(r2306)
@@ -0,0 +1,45 @@
+import unittest
+import os
+
+def _adjacent_file(file):
+    import os.path
+    return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
+
+class TestLeaks(unittest.TestCase):
+    def test_Leaks(self):
+        import subprocess
+        def check_output_if_failed(*args, **kwargs):
+            kwargs['stdout'] = subprocess.PIPE
+            kwargs['stderr'] = subprocess.PIPE
+            sub = subprocess.Popen(*args, **kwargs)
+            (stdout, stderr) = sub.communicate()
+            if sub.returncode != 0:
+                print stdout
+                print stderr
+                raise subprocess.CalledProcessError(sub.returncode, args[0])
+        check_output_if_failed([r'c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe', 
+            _adjacent_file(r'Leaks\TestGMELeaks\TestGMELeaks.vcxproj'), '/p:Configuration=Release'])
+        check_output_if_failed([r'\Program Files (x86)\Debugging Tools for Windows (x86)\gflags.exe'] +
+            '-i TestGMELeaks.exe +ust'.split())
+        umdh = r"c:\Program Files (x86)\Debugging Tools for Windows (x86)\umdh.exe"
+        
+        os.environ['OANOCACHE'] = '1'
+        leak_sub = subprocess.Popen([_adjacent_file(r'Leaks\TestGMELeaks\Release\TestGMELeaks.exe')], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        print leak_sub.stdout.readline()
+        check_output_if_failed([umdh] + '-pn:TestGMELeaks.exe -f:LeakDump1.txt'.split())
+        leak_sub.stdin.write('\n')
+
+        print leak_sub.stdout.readline()
+        check_output_if_failed([umdh] + '-pn:TestGMELeaks.exe -f:LeakDump2.txt'.split())
+        leak_sub.stdin.write('\n')
+
+        check_output_if_failed([umdh] + 'LeakDump1.txt LeakDump2.txt -f:LeakDiff.txt'.split())
+
+        leak_sub.wait()
+        self.assertEqual(0, leak_sub.returncode)
+        
+        lines = open('LeakDiff.txt', 'rb').readlines()
+        self.assertTrue([line for line in lines[-3:] if line.find('Total decrease ==')], lines[-3:])
+        
+if __name__ == "__main__":
+        unittest.main()


More information about the gme-commit mailing list