Ver código fonte

HADOOP-2368. Fix unit tests on Windows.
(Tsz Wo (Nicholas), SZE via dhruba)



git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@601920 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 17 anos atrás
pai
commit
45f61a986f

+ 3 - 0
CHANGES.txt

@@ -208,6 +208,9 @@ Trunk (unreleased changes)
     HADOOP-2349.  Improve code layout in file system transaction logging code.
     HADOOP-2349.  Improve code layout in file system transaction logging code.
     (Tsz Wo (Nicholas), SZE via dhruba)
     (Tsz Wo (Nicholas), SZE via dhruba)
 
 
+    HADOOP-2368.  Fix unit tests on Windows.
+    (Tsz Wo (Nicholas), SZE via dhruba)
+
 Branch 0.15 (unreleased)
 Branch 0.15 (unreleased)
 
 
   BUG FIXES
   BUG FIXES

+ 3 - 1
src/java/org/apache/hadoop/fs/ShellCommand.java

@@ -26,7 +26,9 @@ abstract public class ShellCommand {
   /** a Unix command to get the current user's name */
   /** a Unix command to get the current user's name */
   public final static String USER_NAME_COMMAND = "whoami";
   public final static String USER_NAME_COMMAND = "whoami";
   /** a Unix command to get the current user's groups list */
   /** a Unix command to get the current user's groups list */
-  public static final String GROUPS_COMMAND = "groups";
+  public static String[] getGROUPS_COMMAND() {
+    return new String[]{"bash", "-c", "groups"};
+  }
   /** a Unix command to set permission */
   /** a Unix command to set permission */
   public static final String SET_PERMISSION_COMMAND = "chmod";
   public static final String SET_PERMISSION_COMMAND = "chmod";
   /** a Unix command to set owner */
   /** a Unix command to set owner */

+ 1 - 1
src/java/org/apache/hadoop/security/UnixUserGroupInformation.java

@@ -303,7 +303,7 @@ public class UnixUserGroupInformation implements UserGroupInformation {
    * @throws IOException if encounter any error when running the command
    * @throws IOException if encounter any error when running the command
    */
    */
   private static String[] getUnixGroups() throws IOException {
   private static String[] getUnixGroups() throws IOException {
-    return executeShellCommand(new String[]{ShellCommand.GROUPS_COMMAND});
+    return executeShellCommand(ShellCommand.getGROUPS_COMMAND());
   }
   }
   
   
   /* Execute a command and return the result as an array of Strings */
   /* Execute a command and return the result as an array of Strings */

+ 1 - 1
src/test/org/apache/hadoop/fs/TestLocalFileSystemPermission.java

@@ -140,7 +140,7 @@ public class TestLocalFileSystemPermission extends TestCase {
 
 
   static List<String> getGroups() throws IOException {
   static List<String> getGroups() throws IOException {
     List<String> a = new ArrayList<String>();
     List<String> a = new ArrayList<String>();
-    String s = ShellCommand.execCommand(ShellCommand.GROUPS_COMMAND);
+    String s = ShellCommand.execCommand(ShellCommand.getGROUPS_COMMAND());
     for(StringTokenizer t = new StringTokenizer(s); t.hasMoreTokens(); ) {
     for(StringTokenizer t = new StringTokenizer(s); t.hasMoreTokens(); ) {
       a.add(t.nextToken());
       a.add(t.nextToken());
     }
     }