Exemple #1
0
        public void Test_ProcessingAllO2AssembliesFromDirectory(ICirData cirData, string targetDirectory, bool verify,
                                                                bool verbose)
        {
            O2Timer checkTimer =
                new O2Timer("Test_ProcessingAllAssembliesFromDirectory " + targetDirectory + " took ").start();
            List <string> targetAssemblies = Files.getFilesFromDir_returnFullPath(targetDirectory, "*.exe");

            targetAssemblies.AddRange(Files.getFilesFromDir_returnFullPath(targetDirectory, "*.dll"));
            //targetAssemblies.AddRange();
            DI.log.debug("Testing processing of {0} dlls and exes directory {1}", targetAssemblies.Count,
                         targetDirectory);
            if (!verify)
            {
                DI.log.debug("Note, verification is disabled");
            }
            foreach (string targetDll in targetAssemblies)
            {
                if (CecilUtils.isDotNetAssembly(targetDll, false))
                {
                    Test_LoadingAssembly(cirData, targetDll, verify, verbose);
                }
            }
            CirFactoryUtils.showCirDataStats(cirData);
            checkTimer.stop();
        }
Exemple #2
0
        public void Test_processAssemblyDefinition()
        {
            ICirData           cirData      = new CirData();
            AssemblyDefinition testAssembly = getTestAssembly();

            cirFactory.processAssemblyDefinition(cirData, testAssembly, null);
            Assert.That(cirData.dClasses_bySignature.Count > 0, "cirData.dClasses_bySignature.Count == 0");

            // check that all functions from this assembly match
            checkThatAllFunctionsMatch(cirData, testAssembly);

            // check that the type is there
            TypeDefinition testTypeDefinition = CecilUtils.getType(testAssembly, "testType");

            Assert.That(
                cirData.dClasses_bySignature.ContainsKey(
                    CirFactoryUtils.getTypeUniqueSignatureFromTypeReference(testTypeDefinition)),
                "testTypeDefinition.FullName was not there");
            Assert.IsNotNull(cirData.getClass(testTypeDefinition.FullName),
                             "when using testTypeDefinition.FullName, cirClass was null");

            ICirClass cirClass = cirData.getClass("testType");

            Assert.IsNotNull(cirClass, "when using 'testType',  cirClass was null");
            Test_processTypeDefinition(cirData, cirClass);
        }
Exemple #3
0
        public void Test_ProcessingO2Kernel()
        {
            DI.log.info("Testing with O2Kernel");
            ICirData cirData     = new CirData();
            string   O2KernelExe = DI.config.ExecutingAssembly; // this gets O2_Kernel.Exe

            Test_LoadingAssembly(cirData, O2KernelExe, true /*verify*/, false /*verbose*/);
            CirFactoryUtils.showCirDataStats(cirData);
        }
Exemple #4
0
        public void createCirDataObject()
        {
            cirData = new CirData();
            DI.log.info("using assembly:{0} and O2_Kernel.dll", Assembly.GetExecutingAssembly().Location);
            cirFactory.processAssemblyDefinition(cirData, Assembly.GetExecutingAssembly().Location);
            cirFactory.processAssemblyDefinition(cirData, DI.config.ExecutingAssembly);

            /* // this will load all dlls in the O2 dir
             * foreach(var file in Files.getFilesFromDir_returnFullPath(DI.hardCodedO2DeploymentDir,"*.dll"))
             *  cirFactory.processAssemblyDefinition(cirData, CecilUtils.getAssembly(file));*/

            Assert.That(cirData.dClasses_bySignature.Count > 0, "There were no classes in cirData object");
            Assert.That(cirData.dFunctions_bySignature.Count > 0, "There were no function in cirData object");
            CirFactoryUtils.showCirDataStats(cirData);
        }
Exemple #5
0
        public void checkThatAllFunctionsMatch(ICirData cirData, AssemblyDefinition testAssembly)
        {
            //var assertChecks = true;
            foreach (MethodDefinition methodDefinition in CecilUtils.getMethods(testAssembly))
            {
                string functionSignature =
                    CirFactoryUtils.getFunctionUniqueSignatureFromMethodReference(methodDefinition);

                //if (assertChecks)
                //{
                Assert.That(cirData.dFunctions_bySignature.ContainsKey(functionSignature),
                            "Could not find functionSignature in cirData object: " + functionSignature);
                //}

                /*else if (cirData.dFunctions_bySignature.ContainsKey(functionSignature) == false)
                 * {
                 *  var BaseClass = methodDefinition.DeclaringType.FullName;
                 *
                 *  DI.log.error("    ****       Could not find functionSignature in cirData object: " +
                 *               functionSignature);
                 *  return;
                 * }*/


                ICirFunction cirFunction = cirData.dFunctions_bySignature[functionSignature];

                //if (assertChecks)
                {
                    Assert.That(CirCecilCompare.areEqual_MethodDefinitionAndCirFunction(methodDefinition, cirFunction),
                                "Function's didn't match: " + functionSignature);
                }

                /*else if (CirCecilCompare.areEqual_MethodDefinitionAndCirFunction(methodDefinition, cirFunction) == false)
                 * {
                 *  DI.log.error("    ****   Function's didn't match: " + functionSignature + "   for   " +
                 *               testAssembly.Name);
                 * }*/


                //
            }
        }