From c79a4b0cea5be1fd69013b08bb89c13c4a5d64ce Mon Sep 17 00:00:00 2001 From: mindless Date: Wed, 10 Mar 2010 23:34:47 +0000 Subject: [PATCH] fix symlink test with long filename (got ENAMETOOLONG on Solaris 10).. if "ln failed: 78" is logged, try again with shorter name. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@28505 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/test/java/hudson/UtilTest.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/hudson/UtilTest.java b/core/src/test/java/hudson/UtilTest.java index 07dc35b228..1004def8c9 100644 --- a/core/src/test/java/hudson/UtilTest.java +++ b/core/src/test/java/hudson/UtilTest.java @@ -1,7 +1,8 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Daniel Dyer, Erik Ramfelt, Richard Bair, id:cactusman + * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, + * Daniel Dyer, Erik Ramfelt, Richard Bair, id:cactusman * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,6 +29,7 @@ import junit.framework.TestCase; import java.util.Map; import java.util.HashMap; import java.util.Locale; +import java.io.ByteArrayOutputStream; import java.io.File; import hudson.util.StreamTaskListener; @@ -145,7 +147,8 @@ public class UtilTest extends TestCase { public void testSymlink() throws Exception { if (Functions.isWindows()) return; - StreamTaskListener l = new StreamTaskListener(System.out); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + StreamTaskListener l = new StreamTaskListener(baos); File d = Util.createTempDir(); try { new FilePath(new File(d, "a")).touch(0); @@ -157,6 +160,19 @@ public class UtilTest extends TestCase { for( int i=0; i<768; i++) buf.append('0'+(i%10)); Util.createSymlink(d,buf.toString(),"x", l); + + String log = baos.toString(); + if (log.length() > 0) { + System.err.println("log output: " + log); + if (s.contains("ln failed: 78" /*ENAMETOOLONG*/)) { + buf.setLength(0); + // Try again with shorter name for this system + for( int i=0; i<254; i++) + buf.append('0'+(i%10)); + Util.createSymlink(d,buf.toString(),"x", l); + } + } + assertEquals(buf.toString(),Util.resolveSymlink(new File(d,"x"),l)); } finally { Util.deleteRecursive(d);