public StateController(ISignboardRepository signboardRepository, IDeviceRepository deviceRepository, ICompanyRepository companyRepository, ILoggingComponent loggingComponent)
 {
     SignboardRepository = signboardRepository;
     DeviceRepository = deviceRepository;
     CompanyRepository = companyRepository;
     LoggingComponent = loggingComponent;
 }
Example #2
0
        private Debuggee(ILoggingComponent logger, ICompilerSettings settings, string debuggeeName, int debuggeeMoniker, string outputName, CompilerOutputType outputType)
        {
            Parameter.ThrowIfNull(logger, nameof(logger));
            Parameter.ThrowIfNullOrWhiteSpace(debuggeeName, nameof(debuggeeName));
            Parameter.ThrowIfNegativeOrZero(debuggeeMoniker, nameof(debuggeeMoniker));
            Parameter.ThrowIfNull(settings, nameof(settings));

            this.OutputHelper            = logger.OutputHelper;
            this.compilerDefineConstants = new Dictionary <string, string>();
            this.debuggeeName            = debuggeeName;
            this.debuggeeMoniker         = debuggeeMoniker;
            this.CompilerOptions         = CompilerOption.GenerateSymbols;
            this.libraries       = new List <string>();
            this.outputType      = outputType;
            this.settings        = settings;
            this.sourceFilePaths = new List <string>();

            if (String.IsNullOrEmpty(outputName))
            {
                // If the outputName was not provided, assume it is called "a.out" and update the extension
                outputName = Debuggee.UpdateOutputName("a.out", outputType);
            }
            else if (String.IsNullOrEmpty(Path.GetExtension(outputName)))
            {
                // If the outputName has no extension, add the appropriate extension
                outputName = Debuggee.UpdateOutputName(outputName, outputType);
            }

            this.outputName = outputName;
        }
Example #3
0
        /// <summary>
        /// Creates a new debuggee instance. This will copy the debuggee into a new folder based on the debuggeeMoniker.
        /// This should only be called once per debuggee.
        /// </summary>
        public static IDebuggee Create(ILoggingComponent logger, ICompilerSettings settings, string debuggeeName, int debuggeeMoniker, string outputName = null, CompilerOutputType outputType = CompilerOutputType.Executable)
        {
            Debuggee newDebuggee = new Debuggee(logger, settings, debuggeeName, debuggeeMoniker, outputName, outputType);

            newDebuggee.CopySource();
            return(newDebuggee);
        }
Example #4
0
 public BusinessService(ILoggingComponent loggingComponent,
                        IWebServiceProxy webServiceProxy,
                        IDataAccessComponent dataAccessComponent)
 {
     _loggingComponent = loggingComponent;
     _webServiceProxy = webServiceProxy;
     _dataAccessComponent = dataAccessComponent;
 }
Example #5
0
 public BusinessService(IDataAccessComponent dataAccessComponent,
                        IWebServiceProxy webServiceProxy,
                        ILoggingComponent loggingComponent)
 {
     _loggingComponent    = loggingComponent;
     _webServiceProxy     = webServiceProxy;
     _dataAccessComponent = dataAccessComponent;
 }
Example #6
0
 /// <summary>
 /// Open existing debuggee
 /// </summary>
 private static IDebuggee OpenDebuggee(ILoggingComponent logger, ITestSettings settings, int debuggeeMoniker)
 {
     lock (syncObject)
     {
         IDebuggee debuggee = Debuggee.Open(logger, settings.CompilerSettings, debuggeeName, debuggeeMoniker, outAppName);
         Assert.True(File.Exists(debuggee.OutputPath), "The debuggee was not compiled. Missing " + debuggee.OutputPath);
         return(debuggee);
     }
 }
Example #7
0
        public CompilerBase(ILoggingComponent logger, ICompilerSettings settings, bool addDebuggerDirToPath)
        {
            Parameter.ThrowIfNull(logger, nameof(logger));
            Parameter.ThrowIfNull(settings, nameof(settings));

            this.addDebuggerDirToPath = addDebuggerDirToPath;
            this.OutputHelper         = logger.OutputHelper;
            this.Settings             = settings;
        }
Example #8
0
 public static IDebuggee Open(ILoggingComponent logger, ICompilerSettings settings, int moniker, string name, string outputname)
 {
     lock (s_lock)
     {
         IDebuggee debuggee = Debuggee.Open(logger, settings, name, moniker, outputname);
         Assert.True(File.Exists(debuggee.OutputPath), "The debuggee was not compiled. Missing " + debuggee.OutputPath);
         return(debuggee);
     }
 }
Example #9
0
        /// <summary>
        /// Log a message commenting on what the overall purpose of the test
        /// </summary>
        public static void TestPurpose(this ILoggingComponent component, string message)
        {
            string timestamp   = GetTimestamp();
            string commentLine = new string('#', message.Length + timestamp.Length + 4);

            component.WriteLine(commentLine);
            component.WriteLine("# {0}{1} #", message, timestamp);
            component.WriteLine(commentLine);
        }
Example #10
0
 /// <summary>
 /// Create the debuggee and compile the application
 /// </summary>
 private static IDebuggee CompileApp(ILoggingComponent logger, ITestSettings settings, int debuggeeMoniker)
 {
     lock (syncObject)
     {
         IDebuggee debuggee = Debuggee.Create(logger, settings.CompilerSettings, debuggeeName, debuggeeMoniker, outAppName);
         debuggee.AddSourceFiles(srcClassName, srcAppName);
         debuggee.Compile();
         return(debuggee);
     }
 }
Example #11
0
        public static void WriteLines(this ILoggingComponent component, StreamReader reader)
        {
            Parameter.ThrowIfNull(reader, nameof(reader));

            string line = null;

            while (null != (line = reader.ReadLine()))
            {
                component.WriteLine(line);
            }
        }
Example #12
0
 public static IDebuggee OpenAndCompile(ILoggingComponent logger, ICompilerSettings settings, int moniker, string name, string outputname, Action <IDebuggee> addSourceFiles)
 {
     Assert.NotNull(addSourceFiles);
     lock (s_lock)
     {
         IDebuggee debuggee = Debuggee.Create(logger, settings, name, moniker, outputname);
         addSourceFiles(debuggee);
         debuggee.Compile();
         return(debuggee);
     }
 }
 public StructuresController(IDeviceRepository deviceRepository,
     ISignboardRepository signboardRepository,
     ISlideshowRepository slideshowRepository,
     IWidgetDefinitionRepository widgetDefinitionRepository,
     IAnnouncementRepository announcementRepository,
     IDiagnosticsComponent diagnosticsComponent,
     ILoggingComponent loggingComponent)
 {
     DeviceRepository = deviceRepository;
     SignboardRepository = signboardRepository;
     SlideshowRepository = slideshowRepository;
     WidgetDefinitionRepository = widgetDefinitionRepository;
     AnnouncementRepository = announcementRepository;
     DiagnosticsComponent = diagnosticsComponent;
     LoggingComponent = loggingComponent;
 }
Example #14
0
        private static CompilerBase CreateCompiler(ILoggingComponent logger, ICompilerSettings settings)
        {
            switch (settings.CompilerType)
            {
            case SupportedCompiler.GPlusPlus:
                return(new GppCompiler(logger, settings));

            case SupportedCompiler.ClangPlusPlus:
                return(new ClangCompiler(logger, settings));

            case SupportedCompiler.VisualCPlusPlus:
                return(new VisualCPlusPlusCompiler(logger, settings));

            default:
                throw new ArgumentOutOfRangeException(nameof(settings.CompilerType), "Unhandled compiler toolset: " + settings.CompilerType);
            }
        }
Example #15
0
        public static void WriteLine(this ILoggingComponent component, string message = "", params object[] args)
        {
            // Invalid XML characters cause xUnit not to write the whole results file
            // For now we only handle null characters since that's what's causing issues and
            // this is just a temporary workaround.
            // See https://github.com/xunit/xunit/issues/876#issuecomment-253337669
            if (!string.IsNullOrEmpty(message))
            {
                message = message.Replace("\0", "<null>");
            }

            if (args.Length > 0)
            {
                component?.OutputHelper?.WriteLine(message, args);
            }
            else
            {
                component?.OutputHelper?.WriteLine(message);
            }
        }
Example #16
0
        private DebuggerRunner(ILoggingComponent logger, ITestSettings testSettings, IEnumerable <Tuple <string, CallbackRequestHandler> > callbackHandlers)
        {
            Parameter.ThrowIfNull(testSettings, nameof(testSettings));
            this.OutputHelper     = logger.OutputHelper;
            this.DebuggerSettings = testSettings.DebuggerSettings;
#if DEBUG
            this.savedDebugFailUI = UDebug.DebugFailUI;
            UDebug.DebugFailUI    = new XUnitDefaultDebugFailUI(this.OutputHelper);
#endif

            this.WriteLine("Creating Debug Adapter Runner.");
            string adapterId = (this.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg) ? "cppvsdbg" : "cppdbg";
            string debugAdapterRelativePath = this.DebuggerSettings.DebuggerAdapterPath ?? "OpenDebugAD7";
            string debugAdapterFullPath     = Path.Combine(PathSettings.DebugAdaptersPath, debugAdapterRelativePath);

            Assert.True(Directory.Exists(Path.GetDirectoryName(debugAdapterFullPath)), "Debug Adapter Path {0} does not exist.".FormatInvariantWithArgs(debugAdapterFullPath));

            // Output engine log to temp folder if requested.
            this.engineLogPath = Path.Combine(PathSettings.TempPath, "EngineLog-{0}-{1}-{2}.log".FormatInvariantWithArgs(testSettings.Name, testSettings.DebuggerSettings.DebuggeeArchitecture.ToString(), testSettings.DebuggerSettings.DebuggerType.ToString()));
            this.WriteLine("Logging engine to: {0}", this.engineLogPath);

            this.DarRunner = new DarRunner(
                adapterPath: debugAdapterFullPath,
                traceDebugAdapterOutput: DiagnosticsSettings.LogDebugAdapter ? DebugAdapterRunner.TraceDebugAdapterMode.Memory : DebugAdapterRunner.TraceDebugAdapterMode.None,
                engineLogPath: this.engineLogPath,
                pauseForDebugger: false,
                isVsDbg: this.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg,
                isNative: true,
                responseTimeout: 5000);

            if (callbackHandlers != null)
            {
                foreach (Tuple <string, CallbackRequestHandler> handlerPair in callbackHandlers)
                {
                    this.DarRunner.AddCallbackRequestHandler(handlerPair.Item1, handlerPair.Item2);
                }
            }

            this.WriteLine("Initializing debugger.");
            this.initializeResponse = this.RunCommand(new InitializeCommand(adapterId));
        }
 public CompaniesController(ICompanyRepository companyRepository, ILoggingComponent loggingComponent)
 {
     CompanyRepository = companyRepository;
     LoggingComponent = loggingComponent;
 }
Example #18
0
 public static IDebuggee OpenAndCompile(ILoggingComponent logger, ICompilerSettings settings, int moniker)
 {
     return(DebuggeeHelper.OpenAndCompile(logger, settings, moniker, SinkHelper.Name, SinkHelper.OutputName, SinkHelper.AddSourceFiles));
 }
 public ScreenshotsController(IDeviceRepository deviceRepository, IScreenshotComponent screensaverComponent, ILoggingComponent loggingComponent)
 {
     DeviceRepository = deviceRepository;
     ScreensaverComponent = screensaverComponent;
     LoggingComponent = loggingComponent;
 }
 public VisualCPlusPlusCompiler(ILoggingComponent logger, ICompilerSettings settings)
     : base(logger, settings, addDebuggerDirToPath: false)
 {
 }
Example #21
0
 public ProcessCleanupHelper(ILoggingComponent logger, Process process)
 {
     this.logger = logger;
     this.process = process;
 }
Example #22
0
 /// <summary>
 /// Log a message commenting on what the test is currently trying to accomplish.
 /// </summary>
 public static void Comment(this ILoggingComponent component, string message, params object[] args)
 {
     component.WriteLine();
     component.WriteLine("# " + message + GetTimestamp(), args);
 }
Example #23
0
 public SqlProvider(ILoggingComponent logger)
 {
     _logger = logger;
 }
Example #24
0
 public OracleProvider(ILoggingComponent logger)
 {
     _logger = logger;
 }
 public ImagesController(IImageComponent imageComponent, ILoggingComponent loggingComponent)
 {
     ImageComponent = imageComponent;
     LoggingComponennt = loggingComponent;
 }
 public DiBusinessLibrary(IDbProvider dbProvider, IProxy proxy, ILoggingComponent logger)
 {
     _dbProvider = dbProvider;
     _proxy = proxy;
     _logger = logger;
 }
Example #27
0
 /// <summary>
 /// Log a message with details on the tests current settings
 /// </summary>
 public static void WriteSettings(this ILoggingComponent component, ITestSettings testSettings)
 {
     component.WriteLine("Test: {0}", testSettings.Name);
     component.WriteLine(testSettings.CompilerSettings.ToString());
     component.WriteLine(testSettings.DebuggerSettings.ToString());
 }
Example #28
0
 /// <summary>
 /// Provides a way to assure a process will is closed or killed when dispose is called
 /// </summary>
 public static IDisposable ProcessCleanup(ILoggingComponent logger, Process p)
 {
     return new ProcessCleanupHelper(logger, p);
 }
Example #29
0
 /// <summary>
 /// Opens an existing debuggee instance.
 /// </summary>
 public static IDebuggee Open(ILoggingComponent logger, ICompilerSettings settings, string debuggeeName, int debuggeeMoniker, string outputName = null, CompilerOutputType outputType = CompilerOutputType.Executable)
 {
     return(new Debuggee(logger, settings, debuggeeName, debuggeeMoniker, outputName, outputType));
 }
Example #30
0
 public OracleProvider(ILoggingComponent logger)
 {
     _logger = logger;
 }
Example #31
0
 public static IDebuggerRunner Create(ILoggingComponent logger, ITestSettings testSettings, IEnumerable <Tuple <string, CallbackRequestHandler> > callbackHandlers)
 {
     return(new DebuggerRunner(logger, testSettings, callbackHandlers));
 }
 public TimetablesController(ITimetableComponent timetableComponent, ILoggingComponent loggingComponent)
 {
     TimetableComponent = timetableComponent;
     LoggingComponent = loggingComponent;
 }
Example #33
0
 public StaticDependencyBusinessLibrary()
 {
     _logger     = new LoggingComponent();
     _dbProvider = new SqlProvider(_logger);
     _proxy      = new TestProxy();
 }
 public GlobalExceptionFilterAttribute(ILoggingComponent logging)
 {
     Logging = logging;
 }
 public StaticDependencyBusinessLibrary()
 {
     _logger = new LoggingComponent();
     _dbProvider = new SqlProvider(_logger);
     _proxy = new TestProxy();
 }
Example #36
0
        /// <summary>
        /// Runs a command against the debugger.
        /// </summary>
        /// <param name="command">The command to run.</param>
        /// <param name="expectedEvents">[OPTIONAL] If the command causes an event to occur, pass the expected event(s)</param>
        private void Run(DarRunner darRunner, ILoggingComponent log, params IEvent[] expectedEvents)
        {
            Parameter.ThrowIfNull(darRunner, nameof(darRunner));

            log?.WriteLine("Running command {0}", this.ToString());
            log?.WriteLine("Command '{0}' expecting response: {1}", this.Name, this.ExpectedResponse.ToString());

            DebugAdapterResponse darCommandResponse = GetDarResponse(this.ExpectedResponse);
            DebugAdapterCommand  darCommand         = new DebugAdapterCommand(
                this.Name,
                this.Args,
                new[] { darCommandResponse });
            List <Tuple <DebugAdapterResponse, IEvent> > darEventMap = new List <Tuple <DebugAdapterResponse, IEvent> >(expectedEvents.Length);

            // Add additional expected events to match if requested
            if (expectedEvents != null && expectedEvents.Length > 0)
            {
                if (expectedEvents.Length > 1)
                {
                    log?.WriteLine("Command '{0}' expecting {1} events:", this.Name, expectedEvents.Length);
                }

                foreach (var expectedEvent in expectedEvents)
                {
                    DebugAdapterResponse darEventResponse = GetDarResponse(expectedEvent);
                    darCommand.ExpectedResponses.Add(darEventResponse);
                    darEventMap.Add(Tuple.Create(darEventResponse, expectedEvent));

                    // Debug info for expected response
                    string eventMessage = expectedEvents.Length > 1 ? "  - {1}" : "Command '{0}' expecting event: {1}";
                    log?.WriteLine(eventMessage, this.Name, expectedEvent.ToString());
                }
            }

            // Allow the command to override the timeout
            int overrideTimeout = Convert.ToInt32(this.Timeout.TotalMilliseconds);
            int savedTimeout    = darRunner.ResponseTimeout;

            try
            {
                if (overrideTimeout > 0)
                {
                    darRunner.ResponseTimeout = overrideTimeout;
                    log?.WriteLine("Command '{0}' timeout set to {1:n0} seconds.", this.Name, this.Timeout.TotalSeconds);
                }

                darCommand.Run(darRunner);

                // Allow the command to retrieve properties from the actual matched response.
                string responseJson = JsonConvert.SerializeObject(darCommandResponse.Match);
                if (!string.IsNullOrWhiteSpace(responseJson))
                {
                    this.ProcessActualResponse(new ActualResponse(responseJson));
                }

                // Allow the events to retrieve properties from the actual event.
                foreach (var darEvent in darEventMap)
                {
                    string eventJson = JsonConvert.SerializeObject(darEvent.Item1.Match);
                    darEvent.Item2.ProcessActualResponse(new ActualResponse(eventJson));
                }
            }
            catch (Exception ex)
            {
                // Add information to the log when the exception occurs
                log?.WriteLine("ERROR: Running command '{0}'. Exception thrown.", this.Name);
                log?.WriteLine(UDebug.ExceptionToString(ex));

                // The DARException is not serializable, create a new exception
                if (ex is DARException)
                {
                    throw new RunnerException(ex.Message);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                if (overrideTimeout > 0)
                {
                    darRunner.ResponseTimeout = savedTimeout;
                }
            }
        }
Example #37
0
 public static IDebuggee Open(ILoggingComponent logger, ICompilerSettings settings, int moniker)
 {
     return(DebuggeeHelper.Open(logger, settings, moniker, SourceMappingHelper.Name, SourceMappingHelper.OutputName));
 }
Example #38
0
 public GppCompiler(ILoggingComponent logger, ICompilerSettings settings)
     : base(logger, settings)
 {
 }
Example #39
0
 public DbProvider(ILoggingComponent logger)
 {
     _logger = logger;
 }
Example #40
0
 public DiBusinessLibrary(IDbProvider dbProvider, IProxy proxy, ILoggingComponent logger)
 {
     _dbProvider = dbProvider;
     _proxy      = proxy;
     _logger     = logger;
 }
Example #41
0
 public GppStyleCompiler(ILoggingComponent logger, ICompilerSettings settings)
     : base(logger, settings, PlatformUtilities.IsWindows)
 {
 }
 public RequestsController(ISignboardRepository signboardRepository, IDeviceRepository deviceRepository, ILoggingComponent loggingComponent)
 {
     SignboardRepository = signboardRepository;
     DeviceRepository = deviceRepository;
     LoggingComponent = loggingComponent;
 }