Esempio n. 1
0
        public static void LogTestStart(TestContext testContext)
        {
            // save and restore the p4config env variable and the cwd
            SaveP4Prefs();
            allocs = P4Debugging.GetStringAllocs();
            frees  = P4Debugging.GetStringReleases();

            cwd = System.IO.Directory.GetCurrentDirectory();

            logDelegate     = new P4CallBacks.LogMessageDelegate(LogFunction);
            logFileDelegate = new LogFile.LogMessageDelgate(LogFileFunction);

            LogFile.SetLoggingFunction(logFileDelegate);

            P4Debugging.SetBridgeLogFunction(logDelegate);
            preTestObjectCount = new int[P4Debugging.GetAllocObjectCount()];

            for (int i = 0; i < preTestObjectCount.Length; i++)
            {
                preTestObjectCount[i] = P4Debugging.GetAllocObject(i);
            }

            // reset the p4d_cmd variable to the default
            p4d_cmd = _p4d_cmd;

            testCount++;
            logger.Info("====== TestName: {0}", testContext.TestName);
            stopWatch = Stopwatch.StartNew();
            if (stopWatchAllTests == null)
            {
                stopWatchAllTests = Stopwatch.StartNew();
            }
        }
Esempio n. 2
0
        public static void LogTestFinish(TestContext testContext)
        {
            System.IO.Directory.SetCurrentDirectory(cwd);
            RestoreP4Prefs();

            logger.Info("------ {0}: {1}, {2} ms", testContext.TestName, testContext.CurrentTestOutcome, stopWatch.ElapsedMilliseconds);

            int iExtraObjects = 0;

            for (int i = 0; i < P4Debugging.GetAllocObjectCount(); i++)
            {
                int postTest = P4Debugging.GetAllocObject(i);
                if (preTestObjectCount[i] != postTest)
                {
                    iExtraObjects += postTest - preTestObjectCount[i];
                    logger.Info(String.Format("<<<<*** Item count for {0} mismatch: {1}/{2}",
                                              P4Debugging.GetAllocObjectName(i), preTestObjectCount[i], postTest));
                }
            }

            long postAllocs = P4Debugging.GetStringAllocs();
            long postFrees  = P4Debugging.GetStringReleases();

            if (postAllocs - allocs != postFrees - frees)
            {
                logger.Info(String.Format("<<<<*** String alloc mismatch: {0}/{1}", postAllocs - allocs, postFrees - frees));
                Assert.AreEqual(postAllocs - allocs, postFrees - frees);
            }

            Assert.AreEqual(0, iExtraObjects);
        }
Esempio n. 3
0
 public static void stopDebugLogging(string action)
 {
     logDelegate = null;
     P4Debugging.SetBridgeLogFunction(logDelegate);
     if (diagnosticLogging())
     {
         LogMessage(4, action, Properties.Resources.FileLogger_EndDiagLogging);
     }
 }
Esempio n. 4
0
        public static void startDebugLogging(string action)
        {
            if (diagnosticLogging())
            {
                LogMessage(4, action, Properties.Resources.FileLogger_BeginDiagLogging);
                logDelegate = new P4CallBacks.LogMessageDelegate(LogFunction);

                P4Debugging.SetBridgeLogFunction(logDelegate);
                debugObjectCount = new int[P4Debugging.GetAllocObjectCount()];

                for (int i = 0; i < debugObjectCount.Length; i++)
                {
                    debugObjectCount[i] = P4Debugging.GetAllocObject(i);
                }
            }
        }