Beispiel #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestFstat()
        {
            FileOutputStream fos = new FileOutputStream(new FilePath(TestDir, "testfstat"));

            NativeIO.POSIX.Stat stat = NativeIO.POSIX.GetFstat(fos.GetFD());
            fos.Close();
            Log.Info("Stat: " + stat.ToString());
            string owner         = stat.GetOwner();
            string expectedOwner = Runtime.GetProperty("user.name");

            if (Path.Windows)
            {
                UserGroupInformation ugi = UserGroupInformation.CreateRemoteUser(expectedOwner);
                string adminsGroupString = "Administrators";
                if (Arrays.AsList(ugi.GetGroupNames()).Contains(adminsGroupString))
                {
                    expectedOwner = adminsGroupString;
                }
            }
            Assert.Equal(expectedOwner, owner);
            NUnit.Framework.Assert.IsNotNull(stat.GetGroup());
            Assert.True(!stat.GetGroup().IsEmpty());
            Assert.Equal("Stat mode field should indicate a regular file",
                         NativeIO.POSIX.Stat.SIfreg, stat.GetMode() & NativeIO.POSIX.Stat.SIfmt);
        }
Beispiel #2
0
            public override void Run()
            {
                long et = Time.Now() + 5000;

                while (Time.Now() < et)
                {
                    try
                    {
                        NativeIO.POSIX.Stat stat = NativeIO.POSIX.GetFstat(fos.GetFD());
                        Assert.Equal(Runtime.GetProperty("user.name"), stat.GetOwner()
                                     );
                        NUnit.Framework.Assert.IsNotNull(stat.GetGroup());
                        Assert.True(!stat.GetGroup().IsEmpty());
                        Assert.Equal("Stat mode field should indicate a regular file",
                                     NativeIO.POSIX.Stat.SIfreg, stat.GetMode() & NativeIO.POSIX.Stat.SIfmt);
                    }
                    catch (Exception t)
                    {
                        thrown.Set(t);
                    }
                }
            }