예제 #1
0
		//---------Heuristics end----------//

		//---------Heuristics begin----------//
		protected void HandleAccessedBeforeOpen (string key, string resourceName)
		{
			IEnumerator enumerator = heuristicsBeforeOpened.Keys.GetEnumerator ();
			enumerator.Reset ();
			while (enumerator.MoveNext ()) {
				string enumKey = (string) enumerator.Current;
				int enumKeyIndex = enumKey.IndexOf (magickEntry2);
				if (enumKeyIndex != -1) {
					string enumUnknownKey = enumKey.Substring (0, enumKeyIndex);
					if (key == enumUnknownKey) {
						string newResourceName = key + enumKey.Substring (enumKeyIndex + 1);
						Holodeck.Resource resource = (Holodeck.Resource) heuristicsBeforeOpened[enumKey];

						string[] logEntry = new string[20];
						for (int i = 0; i < 20; i++) {
							logEntry[i] = "";
						}
						logEntry[(int) LogColumns.ErrorCode] = resource.ErrorCode;
						logEntry[(int) LogColumns.Function] = resource.LastFunction;
						// resource.processID; // TODO: figure out the process ID
						logEntry[(int) LogColumns.ReturnValue] = resource.ReturnValue;
						logEntry[(int) LogColumns.Thread] = resource.threadID.ToString ();
						logEntry[(int) LogColumns.TimeStamp] = resource.TimeStamp;

						IncreaseEntryTableCount (resourceName, logEntry, resource.NumHits);
					}
				} else {
					// we shouldn't be here
				}
			}
		}
예제 #2
0
		protected void IncreaseEntryTableCount (string resourceName, string[] logEntry, long incValue)
		{
			if (resourceName != null) {
				resourceName = resourceName.TrimEnd ('\\');

				if (!resourceName.StartsWith (magickEntry1)) { // if this is a known entry
					if (entryTable.Contains (resourceName)) {
						Holodeck.Resource resource = (Holodeck.Resource) entryTable[resourceName];
						entryTable.Remove (resourceName);
						ChangeHashtable (entryTable, resourceName, logEntry, resource.NumHits + incValue);
					} else {
						ChangeHashtable (entryTable, resourceName, logEntry, incValue);
					}
				} else { // this entry is unknown - probably an access before open
					//---------Heuristics begin----------//
					string tempResourceName = resourceName.Substring (magickEntry1.Length);
					if (heuristicsBeforeOpened.Contains (tempResourceName)) {
						Holodeck.Resource resource = (Holodeck.Resource) heuristicsBeforeOpened[tempResourceName];
						heuristicsBeforeOpened.Remove (resourceName);
						ChangeHashtable (heuristicsBeforeOpened, resourceName, logEntry, resource.NumHits + incValue);
					} else {
						ChangeHashtable (heuristicsBeforeOpened, resourceName, logEntry, incValue);
					}
					//---------Heuristics end----------//
				}
			} else {
				Log.printError ("ResourcesPaneTest.FileHelper.IncreaseEntryTableCount Error - function \"" + logEntry[(int) LogColumns.Function] + "\" is accessing unknown file entry at [" + logEntry[(int) LogColumns.TimeStamp] + "]");
			}
		}
예제 #3
0
        public override void executeTest( )
        {
            string applicationPath = GenerateTestApplication(TestCaseID);

            Holodeck.HolodeckProcess.Start();

            Holodeck.HolodeckPane.Reset();
            Holodeck.HolodeckPane.File_NewProject();
            Holodeck.NewProjectPane1.Reset();
            Holodeck.NewProjectPane1.SetProjectLocation("C:\\ResourcePaneTest.hdp");
            Holodeck.NewProjectPane1.Next();
            Holodeck.NewProjectPane2.Reset();

            Holodeck.NewProjectPane2.SetApplicationName(applicationPath);
            Holodeck.NewProjectPane2.Next();
            Holodeck.NewProjectPane3.Reset();
            Holodeck.NewProjectPane3.SetPauseApplication(true);
            Holodeck.NewProjectPane3.Finish();
            // TODO: make sure that "Project" -> "Active Log" is selected (it seems unnecessary...)
            Holodeck.HolodeckPane.Application_Resume();
            // TODO: change this to non-architecture dependant waiting
            System.Threading.Thread.Sleep(10000);
            Holodeck.HolodeckPane.Application_Pause();

            Holodeck.HolodeckPane.SelectResourcesPane();
            Holodeck.ResourcesPane.Reset();
            Holodeck.Resource[][] resources = new Holodeck.Resource[2][];
            resources[0] = Holodeck.ResourcesPane.GetFileResources();
            resources[1] = Holodeck.ResourcesPane.GetRegistryResources();
            Holodeck.HolodeckPane.SelectLogPane();
            string[][] logs   = Holodeck.LogPane.GetLogEntries();
            string[]   result = Helper.CompareResourcesWithLogs(resources, logs);

            if (result.Length != 0)
            {
                string errorMessage = "";
                foreach (string s in result)
                {
                    errorMessage += s + "\n";
                }

                throw new Exception(errorMessage);
            }
        }
예제 #4
0
        public override void executeTest( )
        {
            string applicationPath = GenerateTestApplication (TestCaseID);

            Holodeck.HolodeckProcess.Start ();

            Holodeck.HolodeckPane.Reset ();
            Holodeck.HolodeckPane.File_NewProject ();
            Holodeck.NewProjectPane1.Reset ();
            Holodeck.NewProjectPane1.SetProjectLocation ("C:\\ResourcePaneTest.hdp");
            Holodeck.NewProjectPane1.Next ();
            Holodeck.NewProjectPane2.Reset ();

            Holodeck.NewProjectPane2.SetApplicationName (applicationPath);
            Holodeck.NewProjectPane2.Next ();
            Holodeck.NewProjectPane3.Reset ();
            Holodeck.NewProjectPane3.SetPauseApplication (true);
            Holodeck.NewProjectPane3.Finish ();
            // TODO: make sure that "Project" -> "Active Log" is selected (it seems unnecessary...)
            Holodeck.HolodeckPane.Application_Resume ();
            // TODO: change this to non-architecture dependant waiting
            System.Threading.Thread.Sleep (10000);
            Holodeck.HolodeckPane.Application_Pause ();

            Holodeck.HolodeckPane.SelectResourcesPane ();
            Holodeck.ResourcesPane.Reset ();
            Holodeck.Resource[][] resources = new Holodeck.Resource[2][];
            resources[0] = Holodeck.ResourcesPane.GetFileResources ();
            resources[1] = Holodeck.ResourcesPane.GetRegistryResources ();
            Holodeck.HolodeckPane.SelectLogPane ();
            string[][] logs = Holodeck.LogPane.GetLogEntries ();
            string[] result = Helper.CompareResourcesWithLogs (resources, logs);

            if (result.Length != 0) {
                string errorMessage = "";
                foreach (string s in result) {
                    errorMessage += s + "\n";
                }

                throw new Exception (errorMessage);
            }
        }
예제 #5
0
        public override void executeTest( )
        {
            string applicationPath = GetApplicationPath(TestCaseID);

            string[] result = new string[0];

            ProcessTestSpecificArguments();


            Holodeck.HolodeckProcess.Start();

            Holodeck.HolodeckPane.Reset();
            Holodeck.HolodeckPane.File_NewProject();
            Holodeck.NewProjectPane1.Reset();
            Holodeck.NewProjectPane1.SetProjectLocation("C:\\ResourcePaneTest.hdp");
            Holodeck.NewProjectPane1.Next();
            Holodeck.NewProjectPane2.Reset();

            Holodeck.NewProjectPane2.SetApplicationName(applicationPath);
            Holodeck.NewProjectPane2.Next();
            Holodeck.NewProjectPane3.Reset();
            Holodeck.NewProjectPane3.SetPauseApplication(true);
            Holodeck.NewProjectPane3.Finish();
            // TODO: make sure that "Project" -> "Active Log" is selected (it seems unnecessary...)
            Holodeck.HolodeckPane.Application_Resume();
            // TODO: change this to non-architecture dependant waiting
            System.Threading.Thread.Sleep(10000);
            Holodeck.HolodeckPane.Application_Pause();

            switch (compareSwitch)
            {
            case "log": {
                Holodeck.HolodeckPane.SelectResourcesPane();
                Holodeck.ResourcesPane.Reset();
                Holodeck.Resource[][] resources = new Holodeck.Resource[2][];
                resources[0] = Holodeck.ResourcesPane.GetFileResources();
                resources[1] = Holodeck.ResourcesPane.GetRegistryResources();
                Holodeck.HolodeckPane.SelectLogPane();
                string[][] logs = Holodeck.LogPane.GetLogEntries();

                result = Helper.CompareResourcesWithLogs(resources, logs);
                break;
            }

            case "known": {
                Holodeck.HolodeckPane.SelectResourcesPane();
                Holodeck.ResourcesPane.Reset();
                string tempPath = System.Environment.GetEnvironmentVariable("TEMP");
                if (tempPath == string.Empty)
                {
                    tempPath = System.Environment.GetEnvironmentVariable("TMP");
                }
                string fileResourceFileName      = "resources" + TestCaseID + "reg.txt";
                Holodeck.Resource[][] resources2 = new Holodeck.Resource[2][];
                resources2[0] = new Holodeck.Resource[0];
                System.IO.StreamReader inFile = System.IO.File.OpenText(tempPath + "\\" + fileResourceFileName);
                resources2[1] = ReadResources(inFile);
                inFile.Close();
                Holodeck.Resource[][] resources = new Holodeck.Resource[2][];
                resources[0] = Holodeck.ResourcesPane.GetFileResources();
                resources[1] = Holodeck.ResourcesPane.GetRegistryResources();
                result       = Helper.CompareResourcesWithResources(resources, resources2);
                break;
            }

            default: {
                throw new ArgumentException("ResourcePaneTest" + TestCaseID + " error: custom option '" + compareSwitch + "' is unknown.");
            }
            }

            Holodeck.HolodeckPane.File_Exit(false);

            if (result.Length != 0)
            {
                string errorMessage = "";
                foreach (string s in result)
                {
                    errorMessage += s + "\n";
                }

                throw new Exception(errorMessage);
            }
        }
예제 #6
0
        public override void executeTest( )
        {
            string applicationPath = GetApplicationPath (TestCaseID);
            string[] result = new string[0];

            ProcessTestSpecificArguments ();

            Holodeck.HolodeckProcess.Start ();

            Holodeck.HolodeckPane.Reset ();
            Holodeck.HolodeckPane.File_NewProject ();
            Holodeck.NewProjectPane1.Reset ();
            Holodeck.NewProjectPane1.SetProjectLocation ("C:\\ResourcePaneTest.hdp");
            Holodeck.NewProjectPane1.Next ();
            Holodeck.NewProjectPane2.Reset ();

            Holodeck.NewProjectPane2.SetApplicationName (applicationPath);
            Holodeck.NewProjectPane2.Next ();
            Holodeck.NewProjectPane3.Reset ();
            Holodeck.NewProjectPane3.SetPauseApplication (true);
            Holodeck.NewProjectPane3.Finish ();
            // TODO: make sure that "Project" -> "Active Log" is selected (it seems unnecessary...)
            Holodeck.HolodeckPane.Application_Resume ();
            // TODO: change this to non-architecture dependant waiting
            System.Threading.Thread.Sleep (10000);
            Holodeck.HolodeckPane.Application_Pause ();

            switch (compareSwitch) {
                case "log": {
                    Holodeck.HolodeckPane.SelectResourcesPane ();
                    Holodeck.ResourcesPane.Reset ();
                    Holodeck.Resource[][] resources = new Holodeck.Resource[2][];
                    resources[0] = Holodeck.ResourcesPane.GetFileResources ();
                    resources[1] = Holodeck.ResourcesPane.GetRegistryResources ();
                    Holodeck.HolodeckPane.SelectLogPane ();
                    string[][] logs = Holodeck.LogPane.GetLogEntries ();

                    result = Helper.CompareResourcesWithLogs (resources, logs);
                    break;
                }
                case "known": {
                    Holodeck.HolodeckPane.SelectResourcesPane ();
                    Holodeck.ResourcesPane.Reset ();
                    string tempPath = System.Environment.GetEnvironmentVariable ("TEMP");
                    if (tempPath == string.Empty) {
                        tempPath = System.Environment.GetEnvironmentVariable ("TMP");
                    }
                    string fileResourceFileName = "resources" + TestCaseID + "reg.txt";
                    Holodeck.Resource[][] resources2 = new Holodeck.Resource[2][];
                    resources2[0] = new Holodeck.Resource[0];
                    System.IO.StreamReader inFile = System.IO.File.OpenText (tempPath + "\\" + fileResourceFileName);
                    resources2[1] = ReadResources (inFile);
                    inFile.Close ();
                    Holodeck.Resource[][] resources = new Holodeck.Resource[2][];
                    resources[0] = Holodeck.ResourcesPane.GetFileResources ();
                    resources[1] = Holodeck.ResourcesPane.GetRegistryResources ();
                    result = Helper.CompareResourcesWithResources (resources, resources2);
                    break;
                }
                default: {
                    throw new ArgumentException ("ResourcePaneTest" + TestCaseID + " error: custom option '" + compareSwitch + "' is unknown.");
                }
            }

            Holodeck.HolodeckPane.File_Exit (false);

            if (result.Length != 0) {
                string errorMessage = "";
                foreach (string s in result) {
                    errorMessage += s + "\n";
                }

                throw new Exception (errorMessage);
            }
        }
예제 #7
0
        protected virtual Holodeck.Resource[] ReadResources(System.IO.StreamReader file)
        {
            const string Name = "Name: ";
            const string Func = "Func: ";
            const string Proc = "Proc: ";
            const string Time = "Time: ";
            const string Retv = "Retv: ";
            const string Errc = "Errc: ";
            const string Exce = "Exce: ";

            Holodeck.Resource resource;
            System.Collections.Hashtable resources = new System.Collections.Hashtable (10);
            string stream = file.ReadToEnd ();
            try {
                int begIndex = 0;
                int endIndex = 0;
                while (true) {

                    begIndex = stream.IndexOf (Name, endIndex);
                    endIndex = stream.IndexOf ("\n", begIndex);
                    begIndex += Name.Length;
                    resource.Name = stream.Substring (begIndex, endIndex - begIndex - 1);

                    begIndex = stream.IndexOf (Func, endIndex);
                    endIndex = stream.IndexOf ("\n", begIndex);
                    begIndex += Func.Length;
                    resource.LastFunction = stream.Substring (begIndex, endIndex - begIndex - 1);

                    begIndex = stream.IndexOf (Proc, endIndex);
                    endIndex = stream.IndexOf ("\n", begIndex);
                    begIndex += Proc.Length;
                    resource.processID = Int64.Parse (stream.Substring (begIndex, endIndex - begIndex - 1));

                    begIndex = stream.IndexOf (Time, endIndex);
                    endIndex = stream.IndexOf ("\n", begIndex);
                    begIndex += Time.Length;
                    resource.TimeStamp = stream.Substring (begIndex, endIndex - begIndex - 1);

                    begIndex = stream.IndexOf (Retv, endIndex);
                    endIndex = stream.IndexOf ("\n", begIndex);
                    begIndex += Retv.Length;
                    resource.ReturnValue = stream.Substring (begIndex, endIndex - begIndex - 1);

                    begIndex = stream.IndexOf (Errc, endIndex);
                    endIndex = stream.IndexOf ("\n", begIndex);
                    begIndex += Errc.Length;
                    resource.ErrorCode = stream.Substring (begIndex, endIndex - begIndex - 1);

                    begIndex = stream.IndexOf (Exce, endIndex);
                    endIndex = stream.IndexOf ("\n", begIndex);
                    begIndex += Exce.Length;
            //					resource. = stream.Substring (begIndex, endIndex - begIndex - 1);

                    resource.NumHits = 1;
                    resource.threadID = 0;

                    if (resources.Contains (resource.Name)) {
                        Holodeck.Resource oldResource = (Holodeck.Resource) resources[resource.Name];
                        resource.NumHits += oldResource.NumHits;
                        resources.Remove (resource.Name);
                    }
                    resources.Add (resource.Name, resource);
                }
            } catch (Exception) {
            }

            Holodeck.Resource[] result = new Holodeck.Resource[resources.Count];
            System.Collections.IEnumerator iEnum = resources.Values.GetEnumerator ();
            int i = 0;
            while (iEnum.MoveNext ()) {
                result[i] = (Holodeck.Resource) iEnum.Current;
                i++;
            }

            return result;
        }
예제 #8
0
        protected virtual Holodeck.Resource[] ReadResources(System.IO.StreamReader file)
        {
            const string Name = "Name: ";
            const string Func = "Func: ";
            const string Proc = "Proc: ";
            const string Time = "Time: ";
            const string Retv = "Retv: ";
            const string Errc = "Errc: ";
            const string Exce = "Exce: ";

            Holodeck.Resource            resource;
            System.Collections.Hashtable resources = new System.Collections.Hashtable(10);
            string stream = file.ReadToEnd();

            try {
                int begIndex = 0;
                int endIndex = 0;
                while (true)
                {
                    begIndex      = stream.IndexOf(Name, endIndex);
                    endIndex      = stream.IndexOf("\n", begIndex);
                    begIndex     += Name.Length;
                    resource.Name = stream.Substring(begIndex, endIndex - begIndex - 1);

                    begIndex  = stream.IndexOf(Func, endIndex);
                    endIndex  = stream.IndexOf("\n", begIndex);
                    begIndex += Func.Length;
                    resource.LastFunction = stream.Substring(begIndex, endIndex - begIndex - 1);

                    begIndex           = stream.IndexOf(Proc, endIndex);
                    endIndex           = stream.IndexOf("\n", begIndex);
                    begIndex          += Proc.Length;
                    resource.processID = Int64.Parse(stream.Substring(begIndex, endIndex - begIndex - 1));

                    begIndex           = stream.IndexOf(Time, endIndex);
                    endIndex           = stream.IndexOf("\n", begIndex);
                    begIndex          += Time.Length;
                    resource.TimeStamp = stream.Substring(begIndex, endIndex - begIndex - 1);

                    begIndex             = stream.IndexOf(Retv, endIndex);
                    endIndex             = stream.IndexOf("\n", begIndex);
                    begIndex            += Retv.Length;
                    resource.ReturnValue = stream.Substring(begIndex, endIndex - begIndex - 1);

                    begIndex           = stream.IndexOf(Errc, endIndex);
                    endIndex           = stream.IndexOf("\n", begIndex);
                    begIndex          += Errc.Length;
                    resource.ErrorCode = stream.Substring(begIndex, endIndex - begIndex - 1);

                    begIndex  = stream.IndexOf(Exce, endIndex);
                    endIndex  = stream.IndexOf("\n", begIndex);
                    begIndex += Exce.Length;
//					resource. = stream.Substring (begIndex, endIndex - begIndex - 1);


                    resource.NumHits  = 1;
                    resource.threadID = 0;

                    if (resources.Contains(resource.Name))
                    {
                        Holodeck.Resource oldResource = (Holodeck.Resource)resources[resource.Name];
                        resource.NumHits += oldResource.NumHits;
                        resources.Remove(resource.Name);
                    }
                    resources.Add(resource.Name, resource);
                }
            } catch (Exception) {
            }

            Holodeck.Resource[]            result = new Holodeck.Resource[resources.Count];
            System.Collections.IEnumerator iEnum  = resources.Values.GetEnumerator();
            int i = 0;

            while (iEnum.MoveNext())
            {
                result[i] = (Holodeck.Resource)iEnum.Current;
                i++;
            }

            return(result);
        }
예제 #9
0
		/// <summary>
		/// Comapres two hash table containing resources
		/// </summary>
		/// <param name="logTable">a hash table; usually the one created from the logs</param>
		/// <param name="resourceTable">another hash table; usually the one gathered from one of the subpanes of the "Resources" pane</param>
		/// <returns>an ArrayList containing strings of error messages produced during the comparison</returns>
		protected static System.Collections.ArrayList CompareResourceTables (Hashtable logTable, Hashtable resourceTable, bool allInclusive)
		{
			System.Collections.ArrayList reportArray = new System.Collections.ArrayList (10);
			IEnumerator logTableEnumerator = logTable.Keys.GetEnumerator ();
			logTableEnumerator.Reset ();
			while (logTableEnumerator.MoveNext ())
			{
				string resourceName = (string) logTableEnumerator.Current;
				Holodeck.Resource logResource = (Holodeck.Resource) logTable[resourceName];
				// TODO: make the comparison case-insensitive
				if (resourceTable.Contains (resourceName))
				{
					Holodeck.Resource resource = (Holodeck.Resource) resourceTable[resourceName];
					if ((logResource.NumHits != 0) &&
						(logResource.NumHits != resource.NumHits)) 
					{
						if (allInclusive ||
							(!allInclusive && logResource.NumHits > resource.NumHits)) {
							reportArray.Add ("Mismatching hit numbers for [" + resourceName + "] - reported: " + resource.NumHits + ", calculated: " + logResource.NumHits);
						}
					}

					if (allInclusive &&
						(logResource.ErrorCode != resource.ErrorCode))
					{
						reportArray.Add ("Mismatching error codes for [" + resourceName + "] - reported: " + resource.ErrorCode + ", calculated: " + logResource.ErrorCode);
					}

					if (logResource.LastFunction != resource.LastFunction) {
						reportArray.Add ("Mismatching last functions for [" + resourceName + "] - reported: " + resource.LastFunction + ", calculated: " + logResource.LastFunction);
					}

					// TODO: compare process ID

					if (allInclusive &&
						(logResource.ReturnValue != resource.ReturnValue)) {
						reportArray.Add ("Mismatching return values for [" + resourceName + "] - reported: " + resource.ReturnValue + ", calculated: " + logResource.ReturnValue);
					}

					if (allInclusive &&
						(logResource.threadID != resource.threadID)) {
						reportArray.Add ("Mismatching thread IDs for [" + resourceName + "] - reported: " + resource.threadID + ", calculated: " + logResource.threadID);
					}

					if (allInclusive &&
						(logResource.TimeStamp != resource.TimeStamp)) {
						reportArray.Add ("Mismatching time stamps for [" + resourceName + "] - reported: " + resource.TimeStamp + ", calculated: " + logResource.TimeStamp);
					}

					resourceTable.Remove (logTableEnumerator.Current);
				} 
				else if (logResource.NumHits != 0) 
				{
					reportArray.Add ("Missing resource in \"Resources\" pane [" + resourceName + "], calculated hit number: " + logResource.NumHits);
				}
			}

			if (resourceTable.Count != 0) 
			{
				IEnumerator resourceTableEnumerator = resourceTable.Keys.GetEnumerator ();
				resourceTableEnumerator.Reset ();
				while (resourceTableEnumerator.MoveNext ())
				{
					string resourceName = (string) resourceTableEnumerator.Current;
					Holodeck.Resource resource = (Holodeck.Resource) resourceTable[resourceName];
					if (allInclusive) {
						reportArray.Add ("Unlogged resource appears in \"Resources\" pane [" + resourceName + "], reported hit number:" + resource.NumHits);
					} else if (resourceName.StartsWith ("Name: ") ||
							   resourceName.StartsWith ("Func: ") ||
							   resourceName.StartsWith ("Proc: ") ||
							   resourceName.StartsWith ("Time: ") ||
							   resourceName.StartsWith ("Retv: ") ||
							   resourceName.StartsWith ("Errc: ") ||
							   resourceName.StartsWith ("Exce: ")) {
						reportArray.Add ("Unknown resource appears in \"Resources\" pane [" + resourceName + "], reported hit number:" + resource.NumHits);
					}
				}
			}

			return reportArray;
		}