Ejemplo n.º 1
0
        public static int RunTest(String[] args)
        {
            ManualResetEvent _profilerDone = new ManualResetEvent(false);

            PassCallbackToProfiler(() => _profilerDone.Set());

            ProfilerControlHelpers.AttachProfilerToSelf(MultipleProfilerGuid, ProfilerPath);

            try
            {
                Console.WriteLine("Throwing exception");
                throw new Exception("Test exception!");
            }
            catch
            {
                // intentionally swallow the exception
                Console.WriteLine("Exception caught");
            }

            Console.WriteLine("Waiting for profilers to all detach");
            if (!_profilerDone.WaitOne(TimeSpan.FromMinutes(5)))
            {
                Console.WriteLine("Profiler did not set the callback, test will fail.");
            }

            return(100);
        }
Ejemplo n.º 2
0
        public unsafe static int RunTest(string[] args)
        {
            string profilerName;

            if (TestLibrary.Utilities.IsWindows)
            {
                profilerName = "Profiler.dll";
            }
            else if (TestLibrary.Utilities.IsLinux)
            {
                profilerName = "libProfiler.so";
            }
            else
            {
                profilerName = "libProfiler.dylib";
            }

            string rootPath     = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string profilerPath = Path.Combine(rootPath, profilerName);

            _profilerDone = new ManualResetEvent(false);
            Console.WriteLine($"Attaching profiler {profilerPath} to self.");
            ProfilerControlHelpers.AttachProfilerToSelf(ReleaseOnShutdownGuid, profilerPath);

            PassCallbackToProfiler(() => _profilerDone.Set());
            if (!_profilerDone.WaitOne(TimeSpan.FromMinutes(5)))
            {
                Console.WriteLine("Profiler did not set the callback, test will fail.");
            }

            return(100);
        }
Ejemplo n.º 3
0
        public unsafe static int RunTest(string[] args)
        {
            string profilerName;

            if (TestLibrary.Utilities.IsWindows)
            {
                profilerName = "Profiler.dll";
            }
            else if (TestLibrary.Utilities.IsLinux)
            {
                profilerName = "libProfiler.so";
            }
            else
            {
                profilerName = "libProfiler.dylib";
            }

            string rootPath     = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string profilerPath = Path.Combine(rootPath, profilerName);

            Console.WriteLine($"Attaching profiler {profilerPath} to self.");
            ProfilerControlHelpers.AttachProfilerToSelf(ReleaseOnShutdownGuid, profilerPath);

            // This warning is that the pointer to the volatile bool won't be treated as volatile,
            // but that's ok. The loop aboive in WastTime is what needs to read it as volatile.
            // The native part just sets it.
            #pragma warning disable CS0420
            fixed(bool *boolPtr = &_profilerDone)
            {
                PassBoolToProfiler(new IntPtr(boolPtr));

                WasteTime();
            }

            return(100);
        }