public bool runTest(ref String errorMessage)
        {
            NSFTime startTime = NSFTimerThread.PrimaryTimerThread.CurrentTime;

            for (int i = 0; i < NumberOfTraces; ++i)
            {
                NSFTraceLog.PrimaryTraceLog.addTrace(NSFTraceTags.InformationalTag, NSFTraceTags.SourceTag, Name);
            }

            NSFTime addEndTime = NSFTimerThread.PrimaryTimerThread.CurrentTime;

            while (!NSFTraceLog.PrimaryTraceLog.allTracesLogged())
            {
                NSFOSThread.sleep(1);
            }

            NSFTime logEndTime = NSFTimerThread.PrimaryTimerThread.CurrentTime;

            NSFTime addTime = ((addEndTime - startTime) * 1000) / NumberOfTraces;
            NSFTime logTime = ((logEndTime - startTime) * 1000) / NumberOfTraces;

            // Add results to name for test visibility
            Name += "; Add / Log Time = " + addTime.ToString() + " / " + logTime.ToString() + " uS";

            return(true);
        }
예제 #2
0
        public ContextSwitchTest(String name)
        {
            Name = name;

            signal1 = NSFOSSignal.create("Signal1");
            signal2 = NSFOSSignal.create("Signal2");

            thread1 = NSFOSThread.create("Thread1", thread1Loop, NSFOSThread.HighestPriority);
            thread2 = NSFOSThread.create("Thread2", thread2Loop, NSFOSThread.HighestPriority);
        }
예제 #3
0
        public bool runTest(ref String errorMessage)
        {
            ContinuouslyRunningTest test = new ContinuouslyRunningTest("StateMachineExercise", 100);

            test.runTest(ref errorMessage);

            NSFOSThread.sleep(20);

            test.terminate(true);
            return(true);
        }
예제 #4
0
        public bool runTest(ref String errorMessage)
        {
            bool returnValue = true;

            readyToTerminate = false;

            List <ContinuouslyRunningTest> tests     = new List <ContinuouslyRunningTest>();
            ContinuouslyRunningTest        firstTest = null;

            for (int i = 0; i < NumberOfInstances; ++i)
            {
                ContinuouslyRunningTest test = new ContinuouslyRunningTest(Name + ".SubTest" + i.ToString(), NumberOfCycles);
                if (i == 0)
                {
                    firstTest = test;
                    test.State1_2_2.EntryActions += terminateTest;
                }

                tests.Add(test);

                test.runTest(ref errorMessage);
            }

            while (!readyToTerminate)
            {
                NSFOSThread.sleep(1);
            }

            // terminate all the test
            foreach (ContinuouslyRunningTest test in tests)
            {
                test.terminate(false);
            }

            // Wait for all test to terminate
            foreach (ContinuouslyRunningTest test in tests)
            {
                test.terminate(true);
            }

            firstTest.State1_2_2.EntryActions -= terminateTest;

            NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("");

            return(returnValue);
        }
예제 #5
0
        public bool runTest(ref String errorMessage)
        {
            bool returnValue = true;

            // Record the if the trace log is enabled or not
            bool traceLogInitialStatus = NSFTraceLog.PrimaryTraceLog.Enabled;

            // get the memory usage at the start
            long initialMemoryUsage = Process.GetCurrentProcess().WorkingSet64;

            // Run the test once ... this will preload any statics
            TestToRepeat.runTest(ref errorMessage);

            // Give some time for everything to clean up
            NSFOSThread.sleep(1000);

            long startingMemoryUsage = Process.GetCurrentProcess().WorkingSet64;

            // Run the test over and over again ...
            for (int i = 0; i < NumberOfCycles; i++)
            {
                TestToRepeat.runTest(ref errorMessage);
            }

            // Give some time for everything to clean up
            NSFOSThread.sleep(1000);

            // Read the memory info at the end of the test.
            long endingMemoryUsage = Process.GetCurrentProcess().WorkingSet64;

            // If the memory has increased during the test then there may have been a problem.
            long delta         = endingMemoryUsage - startingMemoryUsage;
            int  percentChange = (int)((delta * 100) / startingMemoryUsage);

            if (percentChange >= 2)
            {
                errorMessage = "Increase in memory detected in " + TestToRepeat.Name + " Starting memory: " + startingMemoryUsage + ", Ending memory: " + endingMemoryUsage + ", Delta: " + delta + " bytes, " + percentChange + " %";
                returnValue  = false;
            }
            NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Memory Information: " + " Starting memory: " + startingMemoryUsage + ", Ending memory: " + endingMemoryUsage + ", Delta: " + delta + " bytes, " + percentChange + " %");

            // restore trace log enabled
            NSFTraceLog.PrimaryTraceLog.Enabled = traceLogInitialStatus;
            return(returnValue);
        }
예제 #6
0
        public bool runTest(ref String errorMessage)
        {
            eventHandler.addEventReaction(testEvent, testEventAction);

            // Schedule test event to fire every millisecond
            testEvent.schedule(0, 1);

            // Wait for test to end
            NSFOSThread.sleep(1000);

            // Unschedule test event
            testEvent.unschedule();

            // Add results to name for test visibility
            Name += "; Min / Max Delta Time = " + minDeltaTime.ToString() + " / " + maxDeltaTime.ToString() + " mS";

            return(true);
        }
예제 #7
0
        public bool runTest(ref String errorMessage)
        {
            NSFTime startTime = NSFTimerThread.PrimaryTimerThread.CurrentTime;

            thread1.startThread();
            thread2.startThread();

            while (contextSwitchCount < TotalContextSwitches)
            {
                NSFOSThread.sleep(1);
            }

            NSFTime endTime = NSFTimerThread.PrimaryTimerThread.CurrentTime;

            NSFTime contextSwitchTime = ((endTime - startTime) * 1000) / TotalContextSwitches;

            // Add time to name for test visibility
            Name += "; Switch time = " + contextSwitchTime.ToString() + " uS";

            return(true);
        }