示例#1
0
        private SymbolStore BuildSymbolStore()
        {
            SymbolStore store = null;

            foreach (ServerInfo server in ((IEnumerable <ServerInfo>)SymbolServers).Reverse())
            {
                if (server.InternalSymwebServer)
                {
                    store = new SymwebHttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
                else
                {
                    store = new HttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
            }

            // Add default symbol cache if one wasn't set by the command line
            if (CacheDirectories.Count == 0)
            {
                CacheDirectories.Add(GetDefaultSymbolCache());
            }

            foreach (string cache in ((IEnumerable <string>)CacheDirectories).Reverse())
            {
                store = new CacheSymbolStore(Tracer, store, cache);
            }

            return(store);
        }
        public async Task FindFile_ConnectionIsUnencryptedAsync()
        {
            var store = new HttpSymbolStore(fakeFileSystem, httpClient, "http://example.com/");

            var fileReference = await store.FindFileAsync(FILENAME, BUILD_ID, true, log);

            StringAssert.Contains(Strings.ConnectionIsUnencrypted("example.com"), log.ToString());
        }
        public void DeepEquals_NotEqual()
        {
            var storeA = new HttpSymbolStore(fakeFileSystem, httpClient, STORE_URL);
            var storeB = new HttpSymbolStore(fakeFileSystem, httpClient, STORE_URL_B);

            Assert.False(storeA.DeepEquals(storeB));
            Assert.False(storeB.DeepEquals(storeA));
        }
示例#4
0
        private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool symweb, string symbolServerPath, string symbolCachePath)
        {
            bool internalServer = false;

            // Add symbol server URL if exists
            if (symbolServerPath == null)
            {
                if (msdl)
                {
                    symbolServerPath = MsdlsymbolServer;
                }
                else if (symweb)
                {
                    symbolServerPath = SymwebSymbolService;
                    internalServer   = true;
                }
            }
            else
            {
                // Use the internal symbol store for symweb
                internalServer = symbolServerPath.Contains("symweb");

                // Make sure the server Uri ends with "/"
                symbolServerPath = symbolServerPath.TrimEnd('/') + '/';
            }

            if (symbolServerPath != null)
            {
                if (!Uri.TryCreate(symbolServerPath, UriKind.Absolute, out Uri uri) || uri.IsFile)
                {
                    return(false);
                }

                // Create symbol server store
                if (internalServer)
                {
                    store = new SymwebHttpSymbolStore(s_tracer, store, uri);
                }
                else
                {
                    store = new HttpSymbolStore(s_tracer, store, uri);
                }
            }

            if (symbolCachePath != null)
            {
                store = new CacheSymbolStore(s_tracer, store, symbolCachePath);

                // Don't add the default cache later
                s_symbolCacheAdded = true;
            }

            return(true);
        }
示例#5
0
        private async Task DownloadFile(FileStream downloadStream, Stream compareStream, bool ms, bool mi, KeyTypeFlags flags)
        {
            SymbolStoreFile file = new SymbolStoreFile(downloadStream, downloadStream.Name);

            SymbolStores.SymbolStore store = null;
            if (ms)
            {
                Uri.TryCreate("http://msdl.microsoft.com/download/symbols/", UriKind.Absolute, out Uri uri);
                store = new HttpSymbolStore(_tracer, store, uri);
            }
            if (mi)
            {
                Uri.TryCreate("http://symweb.corp.microsoft.com/", UriKind.Absolute, out Uri uri);
                store = new SymwebHttpSymbolStore(_tracer, store, uri);
            }
            var generator = new FileKeyGenerator(_tracer, file);

            IEnumerable <SymbolStoreKey> keys = generator.GetKeys(flags);

            Assert.True(keys.Count() > 0);

            foreach (SymbolStoreKey key in keys)
            {
                if (key.FullPathName.Contains(".ni.pdb"))
                {
                    continue;
                }
                using (SymbolStoreFile symbolFile = await store.GetFile(key, CancellationToken.None))
                {
                    if (symbolFile != null)
                    {
                        Assert.True(downloadStream != symbolFile.Stream);
                        Assert.True(compareStream != symbolFile.Stream);

                        compareStream.Seek(0, SeekOrigin.Begin);
                        CompareStreams(compareStream, symbolFile.Stream);
                    }
                }
            }
        }
示例#6
0
        private SymbolStore BuildSymbolStore()
        {
            SymbolStore store = null;

            foreach (ServerInfo server in ((IEnumerable <ServerInfo>)SymbolServers).Reverse())
            {
                if (server.InternalSymwebServer)
                {
                    store = new SymwebHttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
                else
                {
                    store = new HttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
            }

            foreach (string cache in ((IEnumerable <string>)CacheDirectories).Reverse())
            {
                store = new CacheSymbolStore(Tracer, store, cache);
            }

            return(store);
        }
示例#7
0
        private async Task DownloadFile(string path, bool ms, bool mi, string cache)
        {
            using (Stream stream = TestUtilities.OpenCompressedFile(path))
            {
                SymbolStoreFile          file  = new SymbolStoreFile(stream, path);
                SymbolStores.SymbolStore store = null;
                if (ms)
                {
                    Uri.TryCreate("http://msdl.microsoft.com/download/symbols/", UriKind.Absolute, out Uri uri);
                    store = new HttpSymbolStore(_tracer, store, uri);
                }
                if (mi)
                {
                    Uri.TryCreate("http://symweb.corp.microsoft.com/", UriKind.Absolute, out Uri uri);
                    store = new SymwebHttpSymbolStore(_tracer, store, uri);
                }
                if (cache != null)
                {
                    store = new CacheSymbolStore(_tracer, store, cache);
                }
                KeyTypeFlags flags     = KeyTypeFlags.IdentityKey;
                var          generator = new FileKeyGenerator(_tracer, file);

                IEnumerable <SymbolStoreKey> keys = generator.GetKeys(flags);
                foreach (SymbolStoreKey key in keys)
                {
                    using (SymbolStoreFile symbolFile = await store.GetFile(key, CancellationToken.None))
                    {
                        if (symbolFile != null)
                        {
                            CompareStreams(file.Stream, symbolFile.Stream);
                        }
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Add symbol server to search path.
        /// </summary>
        /// <param name="msdl">if true, use the public Microsoft server</param>
        /// <param name="symweb">if true, use symweb internal server and protocol (file.ptr)</param>
        /// <param name="symbolServerPath">symbol server url (optional)</param>
        /// <param name="authToken"></param>
        /// <param name="timeoutInMinutes">symbol server timeout in minutes (optional)</param>
        /// <returns>if false, failure</returns>
        public bool AddSymbolServer(
            bool msdl,
            bool symweb,
            string symbolServerPath,
            string authToken,
            int timeoutInMinutes)
        {
            bool internalServer = false;

            // Add symbol server URL if exists
            if (symbolServerPath == null)
            {
                if (msdl)
                {
                    symbolServerPath = MsdlSymbolServer;
                }
                else if (symweb)
                {
                    symbolServerPath = SymwebSymbolServer;
                    internalServer   = true;
                }
            }
            else
            {
                // Use the internal symbol store for symweb
                internalServer = symbolServerPath.Contains("symweb");
            }

            // Return error if symbol server path is null and msdl and symweb are false.
            if (symbolServerPath == null)
            {
                return(false);
            }

            // Validate symbol server path
            if (!Uri.TryCreate(symbolServerPath.TrimEnd('/') + '/', UriKind.Absolute, out Uri uri))
            {
                return(false);
            }

            // Add a cache symbol store if file or UNC path
            if (uri.IsFile || uri.IsUnc)
            {
                AddCachePath(symbolServerPath);
            }
            else
            {
                Microsoft.SymbolStore.SymbolStores.SymbolStore store = _symbolStore;
                if (!IsDuplicateSymbolStore <HttpSymbolStore>(store, (httpSymbolStore) => uri.Equals(httpSymbolStore.Uri)))
                {
                    // Create http symbol server store
                    HttpSymbolStore httpSymbolStore;
                    if (internalServer)
                    {
                        httpSymbolStore = new SymwebHttpSymbolStore(Tracer.Instance, store, uri);
                    }
                    else
                    {
                        httpSymbolStore = new HttpSymbolStore(Tracer.Instance, store, uri, personalAccessToken: authToken);
                    }
                    if (timeoutInMinutes != 0)
                    {
                        httpSymbolStore.Timeout = TimeSpan.FromMinutes(timeoutInMinutes);
                    }
                    SetSymbolStore(httpSymbolStore);
                }
            }

            return(true);
        }