# HG changeset patch # User Evgeniy.Koshkin # Date 1393936644 -14400 # Node ID 2f96f552f1bd87dff02b5c82cb27e29dd04bfdbc # Parent 29c6049b8e06ac83c2d28951a5cf14235f5b632a# Parent 737ef280a5871499b7d3b173ca9a6cdfe4a1de97 merged 8.1.x diff -r 29c6049b8e06 -r 2f96f552f1bd .idea/ant.xml --- a/.idea/ant.xml Thu Feb 27 12:10:05 2014 +0400 +++ b/.idea/ant.xml Tue Mar 04 16:37:24 2014 +0400 @@ -1,15 +1,7 @@ - - - - - - - - - + diff -r 29c6049b8e06 -r 2f96f552f1bd .idea/libraries/Common_Api.xml --- a/.idea/libraries/Common_Api.xml Thu Feb 27 12:10:05 2014 +0400 +++ b/.idea/libraries/Common_Api.xml Tue Mar 04 16:37:24 2014 +0400 @@ -2,7 +2,6 @@ - diff -r 29c6049b8e06 -r 2f96f552f1bd .idea/libraries/TeamCity_server_runtime.xml --- a/.idea/libraries/TeamCity_server_runtime.xml Thu Feb 27 12:10:05 2014 +0400 +++ b/.idea/libraries/TeamCity_server_runtime.xml Tue Mar 04 16:37:24 2014 +0400 @@ -4,7 +4,13 @@ - + + + + + + + \ No newline at end of file diff -r 29c6049b8e06 -r 2f96f552f1bd .idea/modules.xml --- a/.idea/modules.xml Thu Feb 27 12:10:05 2014 +0400 +++ b/.idea/modules.xml Tue Mar 04 16:37:24 2014 +0400 @@ -3,6 +3,7 @@ + diff -r 29c6049b8e06 -r 2f96f552f1bd agent-tests/agent-tests.iml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent-tests/agent-tests.iml Tue Mar 04 16:37:24 2014 +0400 @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff -r 29c6049b8e06 -r 2f96f552f1bd agent-tests/src/jetbrains/buildServer/symbols/JetSymbolsExeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent-tests/src/jetbrains/buildServer/symbols/JetSymbolsExeTest.java Tue Mar 04 16:37:24 2014 +0400 @@ -0,0 +1,190 @@ +package jetbrains.buildServer.symbols; + +import jetbrains.buildServer.BaseTestCase; +import jetbrains.buildServer.BuildProblemData; +import jetbrains.buildServer.agent.BuildProgressLogger; +import jetbrains.buildServer.agent.FlowLogger; +import jetbrains.buildServer.agent.NullBuildProgressLogger; +import jetbrains.buildServer.messages.BuildMessage1; +import jetbrains.buildServer.symbols.tools.JetSymbolsExe; +import jetbrains.buildServer.util.FileUtil; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; + +/** + * @author Evgeniy.Koshkin + */ +public class JetSymbolsExeTest extends BaseTestCase implements BuildProgressLogger { + + private JetSymbolsExe myExe; + + @Override + @BeforeMethod + public void setUp() throws Exception { + super.setUp(); + File homeDir = new File("tools\\JetSymbols").getAbsoluteFile(); + assertTrue("Failed to find JetSymbolsExe home dir on path " + homeDir.getAbsolutePath(), homeDir.isDirectory()); + myExe = new JetSymbolsExe(homeDir); + } + + @Test + public void testCmdParametersLengthLimit() throws Exception { + myExe.dumpGuidsToFile(getFilesCollection(500), FileUtil.createTempFile("testCmdParametersLengthLimit", ".out"), this); + } + + private Collection getFilesCollection(int count) throws IOException { + Collection result = new HashSet(); + for (int i = 0; i < count; i++){ + result.add(FileUtil.createTempFile("foo", "boo")); + } + return result; + } + + public void activityStarted(String activityName, String activityType) { + + } + + public void activityStarted(String activityName, String activityDescription, String activityType) { + + } + + public void activityFinished(String activityName, String activityType) { + + } + + public void targetStarted(String targetName) { + + } + + public void targetFinished(String targetName) { + + } + + public void buildFailureDescription(String message) { + + } + + public void internalError(String type, String message, Throwable throwable) { + + } + + public void progressStarted(String message) { + + } + + public void progressFinished() { + + } + + public void logMessage(BuildMessage1 message) { + + } + + public void logTestStarted(String name) { + + } + + public void logTestStarted(String name, Date timestamp) { + + } + + public void logTestFinished(String name) { + + } + + public void logTestFinished(String name, Date timestamp) { + + } + + public void logTestIgnored(String name, String reason) { + + } + + public void logSuiteStarted(String name) { + + } + + public void logSuiteStarted(String name, Date timestamp) { + + } + + public void logSuiteFinished(String name) { + + } + + public void logSuiteFinished(String name, Date timestamp) { + + } + + public void logTestStdOut(String testName, String out) { + + } + + public void logTestStdErr(String testName, String out) { + + } + + public void logTestFailed(String testName, Throwable e) { + + } + + public void logComparisonFailure(String testName, Throwable e, String expected, String actual) { + + } + + public void logTestFailed(String testName, String message, String stackTrace) { + + } + + public void flush() { + + } + + public void ignoreServiceMessages(Runnable runnable) { + + } + + public FlowLogger getFlowLogger(String flowId) { + return null; + } + + public FlowLogger getThreadLogger() { + return null; + } + + public String getFlowId() { + return null; + } + + public void logBuildProblem(BuildProblemData buildProblem) { + + } + + public void message(String message) { + + } + + public void error(String message) { + fail(message); + } + + public void warning(String message) { + + } + + public void exception(Throwable th) { + if(th != null) { + fail(th.toString()); + } + } + + public void progressMessage(String message) { + + } +} diff -r 29c6049b8e06 -r 2f96f552f1bd agent/agent.iml --- a/agent/agent.iml Thu Feb 27 12:10:05 2014 +0400 +++ b/agent/agent.iml Tue Mar 04 16:37:24 2014 +0400 @@ -20,6 +20,7 @@ + diff -r 29c6049b8e06 -r 2f96f552f1bd agent/src/jetbrains/buildServer/symbols/tools/JetSymbolsExe.java --- a/agent/src/jetbrains/buildServer/symbols/tools/JetSymbolsExe.java Thu Feb 27 12:10:05 2014 +0400 +++ b/agent/src/jetbrains/buildServer/symbols/tools/JetSymbolsExe.java Tue Mar 04 16:37:24 2014 +0400 @@ -4,8 +4,10 @@ import jetbrains.buildServer.ExecResult; import jetbrains.buildServer.SimpleCommandLineProcessRunner; import jetbrains.buildServer.agent.BuildProgressLogger; +import jetbrains.buildServer.util.FileUtil; import java.io.File; +import java.io.IOException; import java.util.Collection; /** @@ -21,14 +23,12 @@ myExePath = new File(homeDir, SYMBOLS_EXE); } - public void dumpGuidsToFile(Collection files, File output, BuildProgressLogger buildLogger){ + public void dumpGuidsToFile(Collection files, File output, BuildProgressLogger buildLogger) throws IOException { final GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(myExePath.getPath()); commandLine.addParameter(DUMP_SYMBOL_SIGN_CMD); commandLine.addParameter(String.format("/o=\"%s\"", output.getPath())); - for(File file : files){ - commandLine.addParameter(file.getPath()); - } + commandLine.addParameter(String.format("/i=\"%s\"", dumpPathsToFile(files).getPath())); buildLogger.message(String.format("Running command %s", commandLine.getCommandLineString())); final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null); final String stdout = execResult.getStdout(); @@ -41,4 +41,14 @@ buildLogger.warning("Stderr: " + execResult.getStderr()); buildLogger.exception(execResult.getException()); } + + private File dumpPathsToFile(Collection files) throws IOException { + final File result = FileUtil.createTempFile(DUMP_SYMBOL_SIGN_CMD, ".input"); + StringBuilder contentBuilder = new StringBuilder(); + for(File file : files){ + contentBuilder.append(file.getPath()).append("\n"); + } + FileUtil.writeToFile(result, contentBuilder.toString().getBytes()); + return result; + } } diff -r 29c6049b8e06 -r 2f96f552f1bd server-tests/src/DownloadSymbolsControllerTest.java --- a/server-tests/src/DownloadSymbolsControllerTest.java Thu Feb 27 12:10:05 2014 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import jetbrains.buildServer.controllers.AuthorizationInterceptor; -import jetbrains.buildServer.controllers.BaseController; -import jetbrains.buildServer.controllers.BaseControllerTestCase; -import jetbrains.buildServer.controllers.interceptors.auth.HttpAuthenticationManager; -import jetbrains.buildServer.serverSide.RunningBuildEx; -import jetbrains.buildServer.serverSide.auth.Permission; -import jetbrains.buildServer.serverSide.auth.RoleScope; -import jetbrains.buildServer.symbols.AuthHelper; -import jetbrains.buildServer.symbols.DownloadSymbolsController; -import jetbrains.buildServer.users.SUser; -import org.apache.commons.httpclient.HttpStatus; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.io.File; -import java.io.IOException; - -/** - * @author Evgeniy.Koshkin - */ -public class DownloadSymbolsControllerTest extends BaseControllerTestCase { - - private MetadataStorageMock myBuildMetadataStorage; - - @Override - @BeforeMethod - public void setUp() throws Exception { - myBuildMetadataStorage = new MetadataStorageMock(); - super.setUp(); - myFixture.getServerSettings().setGuestLoginAllowed(true); - } - - @Override - protected BaseController createController() throws IOException { - AuthorizationInterceptor authInterceptor = myFixture.getSingletonService(AuthorizationInterceptor.class); - AuthHelper authHelper = new AuthHelper(myFixture.getServerSettings(), myFixture.getUserModel(), myFixture.getSingletonService(HttpAuthenticationManager.class)); - return new DownloadSymbolsController(myServer, myWebManager, authInterceptor, myFixture.getSecurityContext(), myBuildMetadataStorage, authHelper); - } - - @Test - public void request_pdb_simple() throws Throwable { - myFixture.getServerSettings().setPerProjectPermissionsEnabled(true); - SUser user = myFixture.getUserModel().getGuestUser(); - user.addRole(RoleScope.projectScope(myProject.getProjectId()), getProjectDevRole()); - assertTrue(user.isPermissionGrantedForProject(myProject.getProjectId(), Permission.VIEW_BUILD_RUNTIME_DATA)); - - myRequest.setRequestURI("mock", getRegisterPdbUrl("secur32.pdb", "8EF4E863187C45E78F4632152CC82FEB")); - doGet(); - assertEquals(HttpStatus.SC_OK, myResponse.getStatus()); - } - - @Test - public void request_pdb_two_slashes_in_url() throws Exception { - myRequest.setRequestURI("mock", "/app/symbols//index2.txt'"); - doGet(); - assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus()); - } - - @Test - public void request_pdb_invalid_url() throws Exception { - myRequest.setRequestURI("mock", "/app/symbols/foo"); - doGet(); - assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus()); - } - - @Test - public void request_not_existent_pdb() throws Exception { - myRequest.setRequestURI("mock", "/app/symbols/fileName/FileId2/fileName"); - doGet(); - assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus()); - } - - @Test - public void request_pdb_unauthorized() throws Exception { - myFixture.getServerSettings().setGuestLoginAllowed(false); - myRequest.setRequestURI("mock", getRegisterPdbUrl("secur32.pdb", "8EF4E863187C45E78F4632152CC82FEB")); - doGet(); - assertEquals(HttpStatus.SC_UNAUTHORIZED, myResponse.getStatus()); - } - - @Test - public void request_pdb_no_permissions_granted() throws Exception { - myRequest.setRequestURI("mock", getRegisterPdbUrl("secur32.pdb", "8EF4E863187C45E78F4632152CC82FEB")); - doGet(); - assertEquals(HttpStatus.SC_UNAUTHORIZED, myResponse.getStatus()); - } - - private String getRegisterPdbUrl(String fileName, String fileSignature) throws IOException { - final File artDirectory = createTempDir(); - new File(artDirectory, "foo").createNewFile(); - myBuildType.setArtifactPaths(artDirectory.getAbsolutePath()); - RunningBuildEx build = startBuild(); - myBuildMetadataStorage.addEntry(build.getBuildId(), fileName, fileSignature); - return String.format("/app/symbols/%s/%s/%s", fileName, fileSignature, fileName); - } -} diff -r 29c6049b8e06 -r 2f96f552f1bd server-tests/src/MetadataStorageMock.java --- a/server-tests/src/MetadataStorageMock.java Thu Feb 27 12:10:05 2014 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -import jetbrains.buildServer.serverSide.metadata.BuildMetadataEntry; -import jetbrains.buildServer.serverSide.metadata.MetadataStorage; -import jetbrains.buildServer.symbols.BuildSymbolsIndexProvider; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -class MetadataStorageMock implements MetadataStorage { - - private List myEntries = new ArrayList(); - - public void addEntry(final long buildId, final String fileName, final String fileSignature) { - myEntries.add(new BuildMetadataEntry() { - public long getBuildId() { - return buildId; - } - - @NotNull - public String getKey() { - return fileSignature; - } - - @NotNull - public Map getMetadata() { - HashMap map = new HashMap(); - map.put(BuildSymbolsIndexProvider.ARTIFACT_PATH_KEY, "foo"); - map.put(BuildSymbolsIndexProvider.FILE_NAME_KEY, fileName); - return map; - } - }); - } - - @NotNull - public Iterator getAllEntries(@NotNull String s) { - return myEntries.iterator(); - } - - @NotNull - public Iterator getEntriesByKey(@NotNull String s, @NotNull String s2) { - return myEntries.iterator(); - } - - @NotNull - public Iterator getBuildEntry(long l, @NotNull String s) { - return myEntries.iterator(); - } -} \ No newline at end of file diff -r 29c6049b8e06 -r 2f96f552f1bd server-tests/src/jetbrains/buildServer/symbols/DownloadSymbolsControllerTest.java --- a/server-tests/src/jetbrains/buildServer/symbols/DownloadSymbolsControllerTest.java Thu Feb 27 12:10:05 2014 +0400 +++ b/server-tests/src/jetbrains/buildServer/symbols/DownloadSymbolsControllerTest.java Tue Mar 04 16:37:24 2014 +0400 @@ -1,4 +1,18 @@ -package jetbrains.buildServer.symbols; +package jetbrains.buildServer.symbols;/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import jetbrains.buildServer.controllers.AuthorizationInterceptor; import jetbrains.buildServer.controllers.BaseController; @@ -50,6 +64,13 @@ } @Test + public void request_pdb_two_slashes_in_url() throws Exception { + myRequest.setRequestURI("mock", "/app/symbols//index2.txt'"); + doGet(); + assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus()); + } + + @Test public void request_pdb_invalid_url() throws Exception { myRequest.setRequestURI("mock", "/app/symbols/foo"); doGet(); diff -r 29c6049b8e06 -r 2f96f552f1bd tools/JetSymbols/JetBrains.CommandLine.Symbols.exe Binary file tools/JetSymbols/JetBrains.CommandLine.Symbols.exe has changed diff -r 29c6049b8e06 -r 2f96f552f1bd tools/JetSymbols/JetBrains.Platform.Symbols.Interop.WinApi.dll Binary file tools/JetSymbols/JetBrains.Platform.Symbols.Interop.WinApi.dll has changed diff -r 29c6049b8e06 -r 2f96f552f1bd tools/JetSymbols/JetBrains.Platform.Symbols.Metadata.dll Binary file tools/JetSymbols/JetBrains.Platform.Symbols.Metadata.dll has changed diff -r 29c6049b8e06 -r 2f96f552f1bd tools/JetSymbols/JetBrains.Platform.Symbols.Util.dll Binary file tools/JetSymbols/JetBrains.Platform.Symbols.Util.dll has changed