Author: fireball
Date: Mon Jun 7 22:04:18 2010
New Revision: 47669
URL:
http://svn.reactos.org/svn/reactos?rev=47669&view=rev
Log:
[SYSREG]
- Initial commit of a Windows-based sysreg tool by popular demand. Platform is .NET, and
the only supported virtual machine is VirtualBox. WIP.
Added:
trunk/tools/sysreg3/ (with props)
trunk/tools/sysreg3/Program.cs
trunk/tools/sysreg3/Properties/ (with props)
trunk/tools/sysreg3/Properties/AssemblyInfo.cs (with props)
trunk/tools/sysreg3/sysreg3.csproj (with props)
trunk/tools/sysreg3/sysreg3.sln (with props)
Propchange: trunk/tools/sysreg3/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Mon Jun 7 22:04:18 2010
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/tools/sysreg3/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/tools/sysreg3/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Added: trunk/tools/sysreg3/Program.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg3/Program.cs?rev=47669…
==============================================================================
--- trunk/tools/sysreg3/Program.cs (added)
+++ trunk/tools/sysreg3/Program.cs [iso-8859-1] Mon Jun 7 22:04:18 2010
@@ -1,0 +1,252 @@
+/*
+ * PROJECT: ReactOS System Regression Testing Utility, Windows/VirtualBox version
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software
Foundation
+ * PURPOSE: Processing the incoming debugging data
+ * COPYRIGHT: Copyright Aleksey Bragin <aleksey(a)reactos.org>rg>. Based around ideas
and code from
+ * sysreg created by Christoph von Wittich <christoph_vw(a)reactos.org>
and
+ * Colin Finck <colin(a)reactos.org>
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.IO;
+using VirtualBox;
+
+namespace sysreg3
+{
+ class RegTester
+ {
+ string machineName = "ReactOS";
+ int maxRetries = 3;
+ int numStages = 3;
+ int vmTimeout = 5 * 1000; // 120 secs
+
+ IMachine rosVM;
+ IVirtualBox vBox;
+
+ enum ContinueType
+ {
+ EXIT_CHECKPOINT_REACHED,
+ EXIT_CONTINUE,
+ EXIT_DONT_CONTINUE
+ }
+
+ const String stageCheckpoint = "SYSREG_CHECKPOINT:THIRDBOOT_COMPLETE";
+
+ public RegTester()
+ {
+ /* Create VBox instance */
+ vBox = new VirtualBox.VirtualBox();
+ }
+
+ private ContinueType ProcessDebugOutput(ISession vmSession, int stage)
+ {
+ ContinueType Result = ContinueType.EXIT_DONT_CONTINUE;
+
+ /* Get the serial port */
+ ISerialPort dbgPort = vmSession.Machine.GetSerialPort(0);
+
+ Stream stream = new FileStream(dbgPort.Path, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite);
+ StreamReader sr = new StreamReader(stream);
+
+ try
+ {
+ string line;
+ int kdbgHit = 0;
+ bool quitLoop = false;
+
+ while (!quitLoop)
+ {
+ /* Poll the stream every 1 sec */
+ int waitingTime = 0;
+ while (sr.EndOfStream)
+ {
+ waitingTime += 1000;
+ Thread.Sleep(1000);
+
+ /* Peek a byte to update the EndOfStream value */
+ sr.Peek();
+
+ if (waitingTime >= vmTimeout)
+ {
+ /* We hit the timeout, quit */
+ Console.WriteLine("[SYSREG] Timeout");
+ Result = ContinueType.EXIT_CONTINUE;
+ quitLoop = true;
+ break;
+ }
+ }
+
+ while ((line = sr.ReadLine()) != null)
+ {
+ Console.WriteLine(line);
+
+ /* Check for magic sequences */
+ if (line == "kdb:> ")
+ {
+ kdbgHit++;
+
+ if (kdbgHit == 1)
+ {
+ /* It happened for the first time, backtrace */
+ vmSession.Console.Keyboard.PutScancode(0x30); // b make
+ vmSession.Console.Keyboard.PutScancode(0xb0); // b
release
+ vmSession.Console.Keyboard.PutScancode(0x14); // t make
+ vmSession.Console.Keyboard.PutScancode(0x94); // t
release
+ vmSession.Console.Keyboard.PutScancode(0x1c); // Enter
make
+ vmSession.Console.Keyboard.PutScancode(0x9c); // Enter
release
+
+ continue;
+ }
+ else
+ {
+ /* It happened once again, no reason to continue */
+ Console.WriteLine();
+ Result = ContinueType.EXIT_CONTINUE;
+ quitLoop = true;
+ break;
+ }
+ }
+ else if (line.Contains("--- Press q"))
+ {
+ /* Send Return to get more data from Kdbg */
+ vmSession.Console.Keyboard.PutScancode(0x1c); // Enter make
+ vmSession.Console.Keyboard.PutScancode(0x9c); // Enter
release
+ continue;
+ }
+ else if (line.Contains("SYSREG_ROSAUTOTEST_FAILURE"))
+ {
+ quitLoop = true;
+ break;
+ }
+ else if (stage == 2 && line.Contains(stageCheckpoint))
+ {
+ Result = ContinueType.EXIT_CHECKPOINT_REACHED;
+ quitLoop = true;
+ break;
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // Let the user know what went wrong.
+ Console.WriteLine("The file could not be read:");
+ Console.WriteLine(e.Message);
+ }
+ finally
+ {
+ sr.Close();
+ }
+
+ return Result;
+ }
+
+ public void RunTests()
+ {
+ IProgress vmProgress;
+
+ // TODO: Load settings
+
+ /* Open the testing machine */
+ Session vmSession = new Session();
+
+ try
+ {
+ rosVM = vBox.FindMachine(machineName);
+ }
+ catch (Exception exc)
+ {
+ /* Opening failed. Probably we need to create it */
+ Console.WriteLine("Opening the vm failed " + exc.ToString());
+ return;
+ }
+
+ vBox.OpenSession(vmSession, rosVM.Id);
+ //vmProgress.WaitForCompletion(-1);
+
+ // TODO: Empty the HDD, prepare for the first run
+
+ /* Empty the debug log file */
+ try
+ {
+ ISerialPort dbgPort = vmSession.Machine.GetSerialPort(0);
+ FileStream dbgFile = File.Open(dbgPort.Path, FileMode.Truncate);
+ dbgFile.Close();
+ }
+ catch
+ {
+ /* Don't care about the exceptions here */
+ }
+
+ /* Close VM session */
+ vmSession.Close();
+
+ /* Start main testing loop */
+ for (int stage = 0; stage < numStages; stage++)
+ {
+ for (int retries = 0; retries < maxRetries; retries++)
+ {
+ /* Start the VM */
+ try
+ {
+ vmProgress = vBox.OpenRemoteSession(vmSession, rosVM.Id,
"gui", null);
+ vmProgress.WaitForCompletion(-1);
+
+ if (vmProgress.ResultCode != 0)
+ {
+ /* Print out error's text */
+ Console.WriteLine("Error starting VM: " +
vmProgress.ErrorInfo.Text);
+
+ /* Close VM session */
+ vmSession.Close();
+ break;
+ }
+
+ Console.WriteLine(); Console.WriteLine(); Console.WriteLine();
+ Console.WriteLine("[SYSREG] Running stage {0}...",
stage + 1);
+ Console.WriteLine("[SYSREG] Domain {0} started.\n",
rosVM.Name);
+
+ ContinueType Ret = ProcessDebugOutput(vmSession, stage);
+
+ /* Kill the VM */
+ vmProgress = vmSession.Console.PowerDown();
+ vmProgress.WaitForCompletion(-1);
+
+ /* If we have a checkpoint to reach for success, assume that
+ the application used for running the tests (probably
"rosautotest")
+ continues with the next test after a VM restart. */
+ if (stage == 2 && Ret == ContinueType.EXIT_CONTINUE)
+ Console.WriteLine("[SYSREG] Rebooting VM (retry
{0})", retries + 1);
+ else
+ break;
+
+ /* Close VM session */
+ vmSession.Close();
+ }
+ catch (Exception exc)
+ {
+ Console.WriteLine("Running the VM failed with exception:
" + exc.ToString());
+ break;
+ }
+
+ break;
+ }
+
+ break;
+ }
+ }
+ }
+
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ RegTester regTester = new RegTester();
+ regTester.RunTests();
+ }
+ }
+}
Propchange: trunk/tools/sysreg3/Properties/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Mon Jun 7 22:04:18 2010
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/tools/sysreg3/Properties/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/tools/sysreg3/Properties/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Added: trunk/tools/sysreg3/Properties/AssemblyInfo.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg3/Properties/AssemblyI…
==============================================================================
--- trunk/tools/sysreg3/Properties/AssemblyInfo.cs (added)
+++ trunk/tools/sysreg3/Properties/AssemblyInfo.cs [iso-8859-1] Mon Jun 7 22:04:18 2010
@@ -1,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("sysreg3")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("sysreg3")]
+[assembly: AssemblyCopyright("Copyright © 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("6ce8d24a-bfa0-4d06-ab41-c87ce939d6a6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Propchange: trunk/tools/sysreg3/Properties/AssemblyInfo.cs
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/tools/sysreg3/sysreg3.csproj
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg3/sysreg3.csproj?rev=4…
==============================================================================
--- trunk/tools/sysreg3/sysreg3.csproj (added)
+++ trunk/tools/sysreg3/sysreg3.csproj [iso-8859-1] Mon Jun 7 22:04:18 2010
@@ -1,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == ''
">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == ''
">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{734E3803-E7D3-430A-947C-E44754CAD00F}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>sysreg3</RootNamespace>
+ <AssemblyName>sysreg3</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <UseVSHostingProcess>true</UseVSHostingProcess>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <COMReference Include="VirtualBox">
+ <Guid>{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}</Guid>
+ <VersionMajor>1</VersionMajor>
+ <VersionMinor>3</VersionMinor>
+ <Lcid>0</Lcid>
+ <WrapperTool>tlbimp</WrapperTool>
+ <Isolated>False</Isolated>
+ <EmbedInteropTypes>True</EmbedInteropTypes>
+ </COMReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and
uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
Propchange: trunk/tools/sysreg3/sysreg3.csproj
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/tools/sysreg3/sysreg3.sln
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg3/sysreg3.sln?rev=4766…
==============================================================================
--- trunk/tools/sysreg3/sysreg3.sln (added)
+++ trunk/tools/sysreg3/sysreg3.sln [iso-8859-1] Mon Jun 7 22:04:18 2010
@@ -1,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sysreg3",
"sysreg3.csproj", "{734E3803-E7D3-430A-947C-E44754CAD00F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {734E3803-E7D3-430A-947C-E44754CAD00F}.Debug|x86.ActiveCfg = Debug|x86
+ {734E3803-E7D3-430A-947C-E44754CAD00F}.Debug|x86.Build.0 = Debug|x86
+ {734E3803-E7D3-430A-947C-E44754CAD00F}.Release|x86.ActiveCfg = Release|x86
+ {734E3803-E7D3-430A-947C-E44754CAD00F}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Propchange: trunk/tools/sysreg3/sysreg3.sln
------------------------------------------------------------------------------
svn:eol-style = native