Author: gert
Date: 2007-12-07 16:22:22 -0500 (Fri, 07 Dec 2007)
New Revision: 90961

Added:
   trunk/gert/standalone/bug325299/
   trunk/gert/standalone/bug325299/default.build
   trunk/gert/standalone/bug325299/test.cs
Log:
Added test for bug #325299.


Added: trunk/gert/standalone/bug325299/default.build
===================================================================
--- trunk/gert/standalone/bug325299/default.build       2007-12-07 20:43:57 UTC 
(rev 90960)
+++ trunk/gert/standalone/bug325299/default.build       2007-12-07 21:22:22 UTC 
(rev 90961)
@@ -0,0 +1,32 @@
+<project name="bug325299" default="rebuild">
+       <include buildfile="../../build/common.build" />
+
+       <property name="frameworks" value="mono-1.0,mono-2.0" />
+
+       <target name="clean">
+               <delete>
+                       <fileset>
+                               <include name="file.tmp" />
+                               <include name="out" />
+                               <include name="test.exe" />
+                       </fileset>
+               </delete>
+       </target>
+
+       <target name="compile" depends="init">
+               <csc target="exe" define="${csc.defines}" output="test.exe" 
warnaserror="true" warninglevel="4">
+                       <sources>
+                               <include name="../../build/common/Assert.cs" />
+                               <include name="test.cs" />
+                       </sources>
+                       <references>
+                               <include name="Mono.Posix.dll" />
+                       </references>
+               </csc>
+       </target>
+
+       <target name="run-test" depends="compile">
+               <exec program="test.exe" managed="true" output="out" />
+               <fail if="${file::exists('out')}" />
+       </target>
+</project>


Property changes on: trunk/gert/standalone/bug325299/default.build
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gert/standalone/bug325299/test.cs
===================================================================
--- trunk/gert/standalone/bug325299/test.cs     2007-12-07 20:43:57 UTC (rev 
90960)
+++ trunk/gert/standalone/bug325299/test.cs     2007-12-07 21:22:22 UTC (rev 
90961)
@@ -0,0 +1,48 @@
+using System;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+
+using Mono.Unix;
+
+class Program
+{
+       static void Main ()
+       {
+               Process p = new Process ();
+               p.StartInfo = new ProcessStartInfo ();
+               p.StartInfo.FileName = "/bin/sh";
+               p.StartInfo.Arguments = "-c umask";
+               p.StartInfo.RedirectStandardOutput = true;
+               p.StartInfo.UseShellExecute = false;
+               p.Start ();
+               Assert.IsTrue (p.WaitForExit (1000), "#1");
+               Assert.AreEqual (0, p.ExitCode, "#2");
+
+               string output = p.StandardOutput.ReadLine ();
+               Assert.IsNotNull (output, "#3");
+
+               int umask = int.Parse (output, CultureInfo.InvariantCulture);
+               int expected = 666 & ~umask;
+
+               string fileName = Path.Combine 
(AppDomain.CurrentDomain.BaseDirectory,
+                       "file.tmp");
+
+               File.Create (fileName).Close ();
+
+               UnixFileInfo file = new UnixFileInfo (fileName);
+               FileAccessPermissions perm = file.FileAccessPermissions;
+
+               int actual = 0;
+               actual += (perm & FileAccessPermissions.UserRead) != 0 ? 400 : 
0;
+               actual += (perm & FileAccessPermissions.UserWrite) != 0 ? 200 : 
0;
+               actual += (perm & FileAccessPermissions.UserExecute) != 0 ? 100 
: 0;
+               actual += (perm & FileAccessPermissions.GroupRead) != 0 ? 40 : 
0;
+               actual += (perm & FileAccessPermissions.GroupWrite) != 0 ? 20 : 
0;
+               actual += (perm & FileAccessPermissions.GroupExecute) != 0 ? 10 
: 0;
+               actual += (perm & FileAccessPermissions.OtherRead) != 0 ? 4 : 0;
+               actual += (perm & FileAccessPermissions.OtherWrite) != 0 ? 2 : 
0;
+               actual += (perm & FileAccessPermissions.OtherExecute) != 0 ? 1 
: 0;
+               Assert.AreEqual (expected, actual, "#4");
+       }
+}


Property changes on: trunk/gert/standalone/bug325299/test.cs
___________________________________________________________________
Name: svn:executable
   + *

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to