[Mono-list] Corlib unit tests running now

Jean-Marc André jean-marc.andre@polymtl.ca
Tue, 25 Feb 2003 13:32:41 -0500


This is a multi-part message in MIME format.
--------------090505060808020602030605
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I try to run the unit tests on Linux so I update my installation from 
cvs. It runs well until I get some messages from the GC:
"Repeated allocation of very large blocs. It may leads to memory weak 
and poor performances"
Then, after a couple of minutes, it stops with the following message:
"Out of memory"
Where am I wrong ?

One other thing. There is a bug in the System.ActivatorTest.cs file.
I forgot to unregister a TcpChannel so please commit the 2 files in 
attachments.

Thanks,

JM

Nick Drochak wrote:

>All,
>
>Just thought I would let everyone know the corlib unit tests are running
>on mono on linux pretty well now.  Here's the result summary from my
>box:
>
>Tests run: 1186, Failures: 30
>
>Only 30 Failures is not too bad.  I'll be tracking down those and
>entering buzillas for the one's I can't fix.  I invite anyone else who
>wants to help to do the same.
>
>All you need is a recent mono install, and then do a 'make testcorlib'
>in the mcs module.
>
>Also looking for anyone who can help convert the rest of the unit tests
>for the other assemblies to Nunit version 2 format.  It's much nicer.
>Reply if you are interested.
>
>
>  
>

--------------090505060808020602030605
Content-Type: text/plain;
 name="MarshalByRefObjectTest.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="MarshalByRefObjectTest.cs"

// MarshalByRefObjectTest.cs Test class for
// System.MarshalByRefObject class
// 
// Jean-Marc Andre (jean-marc.andre@polymtl.ca)
//

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Lifetime;
using System.Runtime.Serialization;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

// Just an internal test namespace for
// the MarshalByRefObjectTest class
namespace MonoTests.System.MarshalByRefObjectTestInternal
  {

  // Object from this class can be marshaled
  public class MarshalObject: MarshalByRefObject
    {
    public MarshalObject(){}

    public MarshalObject(int id)
      {
      this.id = id;
      }

    // This method override the default one
    // so we can set some properties of the lifetime
    // of the remot object
    public override object InitializeLifetimeService()
      {
      ILease lease = (ILease) base.InitializeLifetimeService();

      // By default InitialLeaseTime is set to 5 minutes
      // we set it at 10 seconds
      if(lease.CurrentState == LeaseState.Initial)
	{
	lease.InitialLeaseTime = TimeSpan.FromSeconds(10);
	}
      return lease;
      }

    public int Id
      {
      get { return id;}
      }

    private int id = 0;
    } // MarshalObject

  } // MonoTests.System.MarshalByRefObjectTestInternal


namespace MonoTests.System
  {
  using MonoTests.System.MarshalByRefObjectTestInternal;
  using NUnit.Framework;

  // The main test class
  [TestFixture]
  public class MarshalByRefObjectTest
    {
    public MarshalByRefObjectTest()
      {

      }

    // This method test the CreateObjRef
    [Test]
      public void CreateObjRef()
      {
      MarshalObject objMarshal = new MarshalObject();

      RemotingServices.SetObjectUriForMarshal(objMarshal, "MarshalByRefObjectTest.objMarshal1");
      RemotingServices.Marshal(objMarshal);

      ObjRef objRef = objMarshal.CreateObjRef(typeof(MarshalObject));
      Assertion.AssertEquals("#A01", objRef.URI, RemotingServices.GetObjectUri(objMarshal));

      // TODO: When implemented in the mono RemotingServices class
      //RemotingServices.Disconnect(objMarshal);
      }

    [Test]
      [ExpectedException(typeof(RemotingException))]
      public void CreateObjRefThrowException()
      {
      MarshalObject objMarshal = new MarshalObject();

      ObjRef objRef = objMarshal.CreateObjRef(typeof(MarshalObject));
      }

    // This method both tests InitializeLifetimeService()
    // and GetLifetimeService()
    [Test]
      public void LifetimeService()
      {
      MarshalObject objMarshal = new MarshalObject();

      RemotingServices.SetObjectUriForMarshal(objMarshal, "MarshalByRefObjectTest.objMarshal2");
      RemotingServices.Marshal(objMarshal);
      
      objMarshal.InitializeLifetimeService();
      ILease lease = (ILease) objMarshal.GetLifetimeService();
      Assertion.AssertEquals("#A02", lease.InitialLeaseTime, TimeSpan.FromSeconds(10));
      
      // TODO: When implemented in the mono RemotingServices class
      //RemotingServices.Disconnect(objMarshal);
      }

    // Here we test if we a published object can be get 
    // through a TcpChannel
    [Test]
      public void GetObject()
      {
      MarshalObject objMarshal = new MarshalObject(1);

      RemotingServices.SetObjectUriForMarshal(objMarshal, "MarshalByRefObjectTest.objMarshal3");
      RemotingServices.Marshal(objMarshal);

      TcpChannel chn = new TcpChannel(1234);
      ChannelServices.RegisterChannel(chn);
      
      object objRem = Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1234/MarshalByRefObjectTest.objMarshal3");

      MarshalObject objMarshalRem = (MarshalObject) objRem;

      Assertion.AssertEquals("#A03", 1, objMarshalRem.Id);

      // TODO: When implemented in the mono RemotingServices class
      //RemotingServices.Disconnect(objMarshal);
//      chn.StopListening(null);
      ChannelServices.UnregisterChannel(chn);

      }
    }
  }

--------------090505060808020602030605
Content-Type: text/plain;
 name="ActivatorTest.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ActivatorTest.cs"

using System;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using NUnit.Framework;

// The class in this namespace is used by the
// main test class
namespace MonoTests.System.ActivatorTestInternal
  {
  // We need a COM class to test the Activator class
  [ComVisible(true)]
    
  public class COMTest: MarshalByRefObject
    {
    public COMTest()
      {
      id = 0;
      }
    // This property is visible
    [ComVisible(true)]
      public int Id
      {
      get { return id; }
      set { id = value; }
      }
    
    public COMTest(int id)
      {
      this.id = id;
      }
    
    private int id;
    public bool constructorFlag = false;
    }
  } // MonoTests.System.ActivatorTestInternal namespace

namespace MonoTests.System
  {
  using MonoTests.System.ActivatorTestInternal;

  [TestFixture]
  public class ActivatorTest
    {
    public ActivatorTest()
      {}
    
    [Test]
      [Ignore("Activator.CreateComInstanceForm is not yet implemented")]
      // This test is ignored for the moment because 
      // CreateComInstanceFrom() is not implemented yet
      // by the mono Activator class
      public void CreateComInstanceFrom()
      {
      ObjectHandle objHandle = Activator.CreateComInstanceFrom(strAssembly ,
"COMTest");
      COMTest objCOMTest = (COMTest) objHandle.Unwrap();
      objCOMTest.Id = 10;
      Assertion.AssertEquals("#A01",10,objCOMTest.Id);
      }

    [Test]
      // This method tests CreateInstance()
      public void CreateInstance()
      {
      COMTest objCOMTest;
      // object CreateInstance(Type type)
      objCOMTest = (COMTest) Activator.CreateInstance(typeof(COMTest));
      Assertion.AssertEquals("#A02",
"MonoTests.System.ActivatorTestInternal.COMTest",
(objCOMTest.GetType()).ToString());
      // ObjectHandle CreateInstance(string, string) 
       ObjectHandle objHandle;
       objHandle = Activator.CreateInstance(null ,
"MonoTests.System.ActivatorTestInternal.COMTest");
       objCOMTest = (COMTest) objHandle.Unwrap();
       objCOMTest.Id = 2;
       Assertion.AssertEquals("#A03", 2, objCOMTest.Id);
      // object CreateInstance(Type, bool)
       objCOMTest = (COMTest) Activator.CreateInstance((typeof(COMTest)), false);
       Assertion.AssertEquals("#A04",
"MonoTests.System.ActivatorTestInternal.COMTest",
(objCOMTest.GetType()).ToString());
//       // object CreateInstance(Type, object[])
       object[] objArray = new object[1];
       objArray[0] = 7;
       objCOMTest = (COMTest) Activator.CreateInstance((typeof(COMTest)), objArray);
       Assertion.AssertEquals("#A05", 7, objCOMTest.Id);
       // Todo: Implemente the test methods for
       // all the overriden functions using activationAttribute
      }

    // This method tests GetObject from the Activator class
    [Test]
      public void GetObject()
      {
      // object GetObject(Type, string)
      
      // This will provide a COMTest object on  tcp://localhost:1234/COMTestUri
      COMTest objCOMTest = new COMTest(8);
      TcpChannel chnServer = new TcpChannel(1234);
      ChannelServices.RegisterChannel(chnServer);
      RemotingServices.SetObjectUriForMarshal(objCOMTest, "COMTestUri");
      RemotingServices.Marshal(objCOMTest);
      
      // This will get the remoting object
      object objRem = Activator.GetObject(typeof(COMTest),
"tcp://localhost:1234/COMTestUri");
      Assertion.Assert("#A07",objRem != null);
      COMTest remCOMTest = (COMTest) objRem;
      Assertion.AssertEquals("#A08", 8, remCOMTest.Id);

      ChannelServices.UnregisterChannel(chnServer);
       // Todo: Implemente the test methods for
       // all the overriden function using activationAttribute
      }

    // This method tests the CreateInstanceFrom methods
    // of the Activator class
    [Test]
      public void CreateInstanceFrom()
      {
      ObjectHandle objHandle;
      objHandle = Activator.CreateInstanceFrom(strAssembly ,
"MonoTests.System.ActivatorTestInternal.COMTest");
      Assertion.Assert("#A09", objHandle != null);
		objHandle.Unwrap();
       // Todo: Implement the test methods for
       // all the overriden function using activationAttribute
      }
    
    // The name of the assembly file is incorrect.
    // I used it to test these classes but you should
    // replace it with the name of the mono tests assembly file
    // The name of the assembly is used to get an object through
    // Activator.CreateInstance(), Activator.CreateComInstanceFrom()...
    private string strAssembly = "corlib_test.dll";
    
    }
  
  }

--------------090505060808020602030605--