public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* Patch: New java.io.FilePermission.implies action tests
@ 2005-11-16 17:46 Gary Benson
  2005-11-16 17:49 ` Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Gary Benson @ 2005-11-16 17:46 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 258 bytes --]

Hi,

This patch adds tests for java.io.FilePermission.implies for all
possible combinations of actions.  It passes 100% with the patch
I mailed to classpath-patches this morning entitled "Patch:
java.io.FilePermission.implies checks reversed".

Cheers,
Gary

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1304 bytes --]

Index: gnu/testlet/java/io/FilePermission/simple.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/io/FilePermission/simple.java,v
retrieving revision 1.3
diff -u -r1.3 simple.java
--- gnu/testlet/java/io/FilePermission/simple.java	12 May 2004 13:43:21 -0000	1.3
+++ gnu/testlet/java/io/FilePermission/simple.java	16 Nov 2005 17:39:56 -0000
@@ -151,5 +151,32 @@
     catch (java.lang.IllegalArgumentException ex) {
       harness.check(true);
     }
+
+    harness.checkPoint("implies() action checking");
+    for (int i = 1; i < 1 << actions.length; i++) { 
+      for (int j = 1; j < 1 << actions.length; j++) {
+	FilePermission pi = new FilePermission("/tmp/p", makeActions(i));
+	FilePermission pj = new FilePermission("/tmp/p", makeActions(j));
+
+	harness.check(pi.implies(pj) == ((i & j) == j));
+      }
+    }
+  }
+
+  // stuff for implies action checking
+  private static String[] actions = {"read", "write", "execute", "delete"};
+  private static String makeActions(int mask)
+  {
+    String result = "";
+    for (int i = 0; i < actions.length; i++)
+      {
+	if ((mask & (1 << i)) != 0)
+	  {
+	    if (result.length() > 0)
+	      result += ",";
+	    result += actions[i];
+	  }
+      }
+    return result;
   }
 }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: New java.io.FilePermission.implies action tests
  2005-11-16 17:46 Patch: New java.io.FilePermission.implies action tests Gary Benson
@ 2005-11-16 17:49 ` Tom Tromey
  2005-11-16 17:55   ` Gary Benson
  2005-11-16 17:54 ` Gary Benson
  2005-11-17 16:45 ` FYI: New java.lang.SecurityManager tests Gary Benson
  2 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2005-11-16 17:49 UTC (permalink / raw)
  To: Gary Benson; +Cc: mauve-patches

>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:

Gary> This patch adds tests for java.io.FilePermission.implies for all
Gary> possible combinations of actions.  It passes 100% with the patch
Gary> I mailed to classpath-patches this morning entitled "Patch:
Gary> java.io.FilePermission.implies checks reversed".

Awesome.  I gave you mauve write access.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: New java.io.FilePermission.implies action tests
  2005-11-16 17:46 Patch: New java.io.FilePermission.implies action tests Gary Benson
  2005-11-16 17:49 ` Tom Tromey
@ 2005-11-16 17:54 ` Gary Benson
  2005-11-17 16:45 ` FYI: New java.lang.SecurityManager tests Gary Benson
  2 siblings, 0 replies; 6+ messages in thread
From: Gary Benson @ 2005-11-16 17:54 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

Gary Benson wrote:
> This patch adds tests for java.io.FilePermission.implies for all
> possible combinations of actions.  It passes 100% with the patch
> I mailed to classpath-patches this morning entitled "Patch:
> java.io.FilePermission.implies checks reversed".

Oops, forgot the ChangeLog entry...

Cheers,
Gary

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 542 bytes --]

Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.1234
diff -u -r1.1234 ChangeLog
--- ChangeLog	16 Nov 2005 12:34:03 -0000	1.1234
+++ ChangeLog	16 Nov 2005 17:54:08 -0000
@@ -1,3 +1,8 @@
+2005-11-16  Gary Benson <gbenson@redhat.com>
+
+	* gnu/testlet/java/io/FilePermission/simple.java: Added tests
+	for implies() action checking.
+
 2005-11-16  Ito Kazumitsu  <kaz@maczuka.gcd.org>
 
 	* gnu/testlet/java/io/PrintStream/encodings.java: Removed

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: New java.io.FilePermission.implies action tests
  2005-11-16 17:49 ` Tom Tromey
@ 2005-11-16 17:55   ` Gary Benson
  2005-11-16 17:56     ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Gary Benson @ 2005-11-16 17:55 UTC (permalink / raw)
  To: mauve-patches

Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
> 
> Gary> This patch adds tests for java.io.FilePermission.implies for all
> Gary> possible combinations of actions.  It passes 100% with the patch
> Gary> I mailed to classpath-patches this morning entitled "Patch:
> Gary> java.io.FilePermission.implies checks reversed".
> 
> Awesome.  I gave you mauve write access.

Should I just commit it then?

Cheers,
Gary

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: New java.io.FilePermission.implies action tests
  2005-11-16 17:55   ` Gary Benson
@ 2005-11-16 17:56     ` Tom Tromey
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2005-11-16 17:56 UTC (permalink / raw)
  To: Gary Benson; +Cc: mauve-patches

Gary> Should I just commit it then?

Yeah.  Mauve doesn't require approvals, just use your best judgment.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* FYI: New java.lang.SecurityManager tests
  2005-11-16 17:46 Patch: New java.io.FilePermission.implies action tests Gary Benson
  2005-11-16 17:49 ` Tom Tromey
  2005-11-16 17:54 ` Gary Benson
@ 2005-11-17 16:45 ` Gary Benson
  2 siblings, 0 replies; 6+ messages in thread
From: Gary Benson @ 2005-11-17 16:45 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

Hi,

I just spotted that the thread and thread group access permissions
checks were broken in Classpath so I added a regression test.  This
will fail under Classpath without the patch I just mailed there.

Cheers,
Gary

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3349 bytes --]

Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.1238
diff -u -r1.1238 ChangeLog
--- ChangeLog   16 Nov 2005 21:30:34 -0000      1.1238
+++ ChangeLog   17 Nov 2005 16:38:58 -0000
@@ -1,3 +1,8 @@
+2005-11-16  Gary Benson <gbenson@redhat.com>
+
+       * gnu/testlet/java/lang/SecurityManager: New directory.
+       * gnu/testlet/java/lang/SecurityManager/thread.java: New test.
+
 2005-11-16  Anthony Balkissoon  <abalkiss@redhat.com>

        * gnu/testlet/javax/swing/JSplitPane/Constructor.java: Added several
Index: gnu/testlet/java/lang/SecurityManager/thread.java
===================================================================
RCS file: gnu/testlet/java/lang/SecurityManager/thread.java
diff -N gnu/testlet/java/lang/SecurityManager/thread.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/lang/SecurityManager/thread.java   17 Nov 2005 16:38:58 -0000
@@ -0,0 +1,67 @@
+// Copyright (C) 2005, Red Hat, Inc.
+//
+// This file is part of Mauve.
+//
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+//
+// Tags: JDK1.2
+
+package gnu.testlet.java.lang.SecurityManager;
+
+import java.security.Permission;
+
+import gnu.testlet.Testlet;
+import gnu.testlet.TestHarness;
+import gnu.testlet.TestSecurityManager2;
+
+public class thread implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    // The 1.4.2 javadoc for SecurityManager.checkAccess(Thread) says
+    // that checkAccess will check RuntimePermission("modifyThread")
+    // for system threads, and do nothing for other threads. It
+    // defines a system thread as one belonging to a thread group
+    // with a null parent.  SecurityManager.checkAccess(ThreadGroup)
+    // similarly performs checks only when the group's parent is null.
+
+    harness.checkPoint("checkAccess");
+
+    // Get ourselves a system thread and group
+    Thread thread = Thread.currentThread();
+
+    ThreadGroup group = thread.getThreadGroup();
+    harness.check(group != null);
+
+    while (group.getParent() != null)
+      group = group.getParent();
+    if (thread.getThreadGroup() != group)
+      thread = new Thread(group, "dummy");
+
+    // Check we're checking
+    TestSecurityManager2 sm = new TestSecurityManager2(harness);
+
+    sm.prepareChecks(new Permission[] {
+      new RuntimePermission("modifyThread")}, new Permission[] {});
+    sm.checkAccess(thread);
+    sm.checkAllChecked(harness);
+
+    sm.prepareChecks(new Permission[] {
+      new RuntimePermission("modifyThreadGroup")}, new Permission[] {});
+    sm.checkAccess(group);
+    sm.checkAllChecked(harness);
+  }
+}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-11-17 16:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-16 17:46 Patch: New java.io.FilePermission.implies action tests Gary Benson
2005-11-16 17:49 ` Tom Tromey
2005-11-16 17:55   ` Gary Benson
2005-11-16 17:56     ` Tom Tromey
2005-11-16 17:54 ` Gary Benson
2005-11-17 16:45 ` FYI: New java.lang.SecurityManager tests Gary Benson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).