public override Test.Framework.TestResult Run() { DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; DDS.TopicQos topQosHolder = null; DDS.ITopic topic; mod.tstTypeSupport typeSupport = null; mod.tstDataReader datareader; test.sacs.MyDataReaderListener listener; DDS.ISubscriber subscriber; DDS.SubscriberQos sqosHolder = null; DDS.DataReaderQos dqosHolder = null; DDS.IPublisher publisher; DDS.PublisherQos pubQosHolder = null; mod.tstDataWriter datawriter; DDS.DataWriterQos wqosHolder = null; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "DataReaderListener test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result.Result = "DomainParticipantFactory could not be initialized."; return result; } if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DomainParticipantQos could not be resolved."; return result; } participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0); if (participant == null) { result.Result = "Creation of DomainParticipant failed."; return result; } typeSupport = new mod.tstTypeSupport(); if (typeSupport == null) { result.Result = "Creation of tstTypeSupport failed."; this.Cleanup(factory, participant); return result; } rc = typeSupport.RegisterType(participant, "my_type"); if (rc != DDS.ReturnCode.Ok) { result.Result = "Register type failed."; this.Cleanup(factory, participant); return result; } if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default TopicQos could not be resolved."; this.Cleanup(factory, participant); return result; } topQosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos; topic = participant.CreateTopic("my_topic_t", "my_type", topQosHolder);//, null, 0); if (topic == null) { result.Result = "Topic could not be created."; this.Cleanup(factory, participant); return result; } if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default PublisherQos could not be resolved."; this.Cleanup(factory, participant); return result; } publisher = participant.CreatePublisher(pubQosHolder);//, null, 0); if (publisher == null) { result.Result = "Publisher could not be created."; this.Cleanup(factory, participant); return result; } if (publisher.GetDefaultDataWriterQos(ref wqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DataWriterQos could not be resolved."; this.Cleanup(factory, participant); return result; } wqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos; datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, wqosHolder);//, null, 0); if (datawriter == null) { result.Result = "DataWriter could not be created."; this.Cleanup(factory, participant); return result; } mod.tst t = new mod.tst(); t.long_1 = 1; t.long_2 = 2; t.long_3 = 3; rc = datawriter.Write(t, DDS.InstanceHandle.Nil); if (rc != DDS.ReturnCode.Ok) { result.Result = "Data could not be written."; this.Cleanup(factory, participant); return result; } if (participant.GetDefaultSubscriberQos(ref sqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default SubscriberQos could not be resolved."; this.Cleanup(factory, participant); return result; } subscriber = participant.CreateSubscriber(sqosHolder);//, null, 0); if (subscriber == null) { result.Result = "Subscriber could not be created."; this.Cleanup(factory, participant); return result; } if (subscriber.GetDefaultDataReaderQos(ref dqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DataReaderQos could not be resolved."; this.Cleanup(factory, participant); return result; } dqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos; listener = new test.sacs.MyDataReaderListener(); datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, dqosHolder, listener, DDS.StatusKind.Any); if (datareader == null) { result.Result = "DataReader could not be created."; this.Cleanup(factory, participant); return result; } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception e) { System.Console.WriteLine(e); } if (!listener.onLivelinessChangedCalled) { result.Result = "on_liveliness_changed does not work properly."; this.Cleanup(factory, participant); return result; } if (!listener.onDataAvailableCalled) { result.Result = "on_data_available does not work properly."; this.Cleanup(factory, participant); return result; } rc = participant.DeleteContainedEntities(); if (rc != DDS.ReturnCode.Ok) { result.Result = "Delete contained entities failed."; this.Cleanup(factory, participant); return result; } rc = factory.DeleteParticipant(participant); if (rc != DDS.ReturnCode.Ok) { result.Result = "Delete DomainParticipant failed."; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
private static void runListeners(Listener7 listener7, DDS.IEntity entity, int id) { DDS.ReturnCode rc = DDS.ReturnCode.Error; System.Console.Out.WriteLine("Thread {0} started...", id); System.Threading.Thread.Sleep(0); if (entity is DDS.IDomainParticipant) { DDS.IDomainParticipantListener listener = new test.sacs.MyParticipantListener(); DDS.IDomainParticipant domainEntity = (DDS.IDomainParticipant)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); } } } else { if (entity is DDS.IPublisher) { DDS.IPublisherListener listener = new test.sacs.MyPublisherListener(); DDS.IPublisher domainEntity = (DDS.IPublisher)entity; rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else { if (entity is DDS.IDataWriter) { DDS.DataWriterListener listener = new test.sacs.MyDataWriterListener(); DDS.IDataWriter domainEntity = (DDS.IDataWriter)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else { if (entity is DDS.IDataReader) { DDS.IDataReaderListener listener = new test.sacs.MyDataReaderListener(); DDS.IDataReader domainEntity = (DDS.IDataReader)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos); } } } else { if (entity is DDS.ITopic) { DDS.TopicListener listener = new test.sacs.MyTopicListener(); DDS.ITopic domainEntity = (DDS.ITopic)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic); } } } else { if (entity is DDS.ISubscriber) { DDS.ISubscriberListener listener = new test.sacs.MySubscriberListener(); DDS.ISubscriber domainEntity = (DDS.ISubscriber)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders); } } } else { System.Console.Out.WriteLine("Entity type: " + entity.ToString() + " not supported."); } } } } } } System.Console.Out.WriteLine("Thread " + id + " finished."); }
public override Test.Framework.TestResult Run() { DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; DDS.TopicQos topQosHolder = null; DDS.ITopic topic; mod.tstTypeSupport typeSupport = null; mod.tstDataReader datareader; test.sacs.MyDataReaderListener listener; DDS.ISubscriber subscriber; DDS.SubscriberQos sqosHolder = null; DDS.DataReaderQos dqosHolder = null; DDS.IPublisher publisher; DDS.PublisherQos pubQosHolder = null; mod.tstDataWriter datawriter; DDS.DataWriterQos wqosHolder = null; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "DataReaderListener test succeeded."; semaphores = new Dictionary <DDS.StatusKind, Semaphore>(); semaphores.Add(DDS.StatusKind.DataAvailable, new Semaphore(0, 1)); result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result.Result = "DomainParticipantFactory could not be initialized."; return(result); } if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DomainParticipantQos could not be resolved."; return(result); } participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0); if (participant == null) { result.Result = "Creation of DomainParticipant failed."; return(result); } typeSupport = new mod.tstTypeSupport(); if (typeSupport == null) { result.Result = "Creation of tstTypeSupport failed."; this.Cleanup(factory, participant); return(result); } rc = typeSupport.RegisterType(participant, "my_type"); if (rc != DDS.ReturnCode.Ok) { result.Result = "Register type failed."; this.Cleanup(factory, participant); return(result); } if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default TopicQos could not be resolved."; this.Cleanup(factory, participant); return(result); } topic = participant.CreateTopic("my_topic", "my_type", topQosHolder);//, null, //0); if (topic == null) { result.Result = "Topic could not be created."; this.Cleanup(factory, participant); return(result); } if (participant.GetDefaultSubscriberQos(ref sqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default SubscriberQos could not be resolved."; this.Cleanup(factory, participant); return(result); } subscriber = participant.CreateSubscriber(sqosHolder);//, null, 0); if (subscriber == null) { result.Result = "Subscriber could not be created."; this.Cleanup(factory, participant); return(result); } if (subscriber.GetDefaultDataReaderQos(ref dqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DataReaderQos could not be resolved."; this.Cleanup(factory, participant); return(result); } datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, dqosHolder);//, null, 0); if (datareader == null) { result.Result = "DataReader could not be created."; this.Cleanup(factory, participant); return(result); } if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default PublisherQos could not be resolved."; this.Cleanup(factory, participant); return(result); } publisher = participant.CreatePublisher(pubQosHolder);//, null, 0); if (publisher == null) { result.Result = "Publisher could not be created."; this.Cleanup(factory, participant); return(result); } if (publisher.GetDefaultDataWriterQos(ref wqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DataWriterQos could not be resolved."; this.Cleanup(factory, participant); return(result); } datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, wqosHolder);//, null, 0); if (datawriter == null) { result.Result = "DataWriter could not be created."; this.Cleanup(factory, participant); return(result); } listener = new test.sacs.MyDataReaderListener(semaphores); rc = datareader.SetListener(listener, DDS.StatusKind.LivelinessChanged | DDS.StatusKind.DataAvailable); if (rc != DDS.ReturnCode.Ok) { result.Result = "Set listener failed."; return(result); } mod.tst t = new mod.tst(); t.long_1 = 1; t.long_2 = 2; t.long_3 = 3; rc = datawriter.Write(t, DDS.InstanceHandle.Nil); if (rc != DDS.ReturnCode.Ok) { result.Result = "Data could not be written."; this.Cleanup(factory, participant); return(result); } if (semaphores[DDS.StatusKind.DataAvailable].WaitOne(10000)) { if (!listener.onDataAvailableCalled) { result.Result = "on_data_available does not work properly."; this.Cleanup(factory, participant); return(result); } } else { result.Result = "on_data_available did not trigger"; this.Cleanup(factory, participant); return(result); } listener.Reset(); rc = publisher.DeleteDataWriter(datawriter); if (rc != DDS.ReturnCode.Ok) { result.Result = "DataWriter could not be deleted."; this.Cleanup(factory, participant); return(result); } rc = participant.DeleteContainedEntities(); if (rc != DDS.ReturnCode.Ok) { result.Result = "Delete contained entities failed."; this.Cleanup(factory, participant); return(result); } rc = factory.DeleteParticipant(participant); if (rc != DDS.ReturnCode.Ok) { result.Result = "Delete DomainParticipant failed."; this.Cleanup(factory, participant); return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; DDS.TopicQos topQosHolder = null; DDS.ITopic topic; mod.tstTypeSupport typeSupport = null; mod.tstDataReader datareader; test.sacs.MyDataReaderListener listener; DDS.ISubscriber subscriber; DDS.SubscriberQos sqosHolder = null; DDS.DataReaderQos dqosHolder = null; DDS.IPublisher publisher; DDS.PublisherQos pubQosHolder = null; mod.tstDataWriter datawriter; DDS.DataWriterQos wqosHolder = null; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "DataReaderListener test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result.Result = "DomainParticipantFactory could not be initialized."; return(result); } if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DomainParticipantQos could not be resolved."; return(result); } participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0); if (participant == null) { result.Result = "Creation of DomainParticipant failed."; return(result); } typeSupport = new mod.tstTypeSupport(); if (typeSupport == null) { result.Result = "Creation of tstTypeSupport failed."; this.Cleanup(factory, participant); return(result); } rc = typeSupport.RegisterType(participant, "my_type"); if (rc != DDS.ReturnCode.Ok) { result.Result = "Register type failed."; this.Cleanup(factory, participant); return(result); } if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default TopicQos could not be resolved."; this.Cleanup(factory, participant); return(result); } topQosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos; topic = participant.CreateTopic("my_topic_t", "my_type", topQosHolder);//, null, 0); if (topic == null) { result.Result = "Topic could not be created."; this.Cleanup(factory, participant); return(result); } if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default PublisherQos could not be resolved."; this.Cleanup(factory, participant); return(result); } publisher = participant.CreatePublisher(pubQosHolder);//, null, 0); if (publisher == null) { result.Result = "Publisher could not be created."; this.Cleanup(factory, participant); return(result); } if (publisher.GetDefaultDataWriterQos(ref wqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DataWriterQos could not be resolved."; this.Cleanup(factory, participant); return(result); } wqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos; datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, wqosHolder);//, null, 0); if (datawriter == null) { result.Result = "DataWriter could not be created."; this.Cleanup(factory, participant); return(result); } mod.tst t = new mod.tst(); t.long_1 = 1; t.long_2 = 2; t.long_3 = 3; rc = datawriter.Write(t, DDS.InstanceHandle.Nil); if (rc != DDS.ReturnCode.Ok) { result.Result = "Data could not be written."; this.Cleanup(factory, participant); return(result); } if (participant.GetDefaultSubscriberQos(ref sqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default SubscriberQos could not be resolved."; this.Cleanup(factory, participant); return(result); } subscriber = participant.CreateSubscriber(sqosHolder);//, null, 0); if (subscriber == null) { result.Result = "Subscriber could not be created."; this.Cleanup(factory, participant); return(result); } if (subscriber.GetDefaultDataReaderQos(ref dqosHolder) != DDS.ReturnCode.Ok) { result.Result = "Default DataReaderQos could not be resolved."; this.Cleanup(factory, participant); return(result); } dqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos; listener = new test.sacs.MyDataReaderListener(); datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, dqosHolder, listener, DDS.StatusKind.Any); if (datareader == null) { result.Result = "DataReader could not be created."; this.Cleanup(factory, participant); return(result); } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception e) { System.Console.WriteLine(e); } if (!listener.onLivelinessChangedCalled) { result.Result = "on_liveliness_changed does not work properly."; this.Cleanup(factory, participant); return(result); } if (!listener.onDataAvailableCalled) { result.Result = "on_data_available does not work properly."; this.Cleanup(factory, participant); return(result); } rc = participant.DeleteContainedEntities(); if (rc != DDS.ReturnCode.Ok) { result.Result = "Delete contained entities failed."; this.Cleanup(factory, participant); return(result); } rc = factory.DeleteParticipant(participant); if (rc != DDS.ReturnCode.Ok) { result.Result = "Delete DomainParticipant failed."; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public void Run() { System.Console.Out.WriteLine("Thread " + this.id + " started..."); System.Threading.Thread.Sleep(0); if (this.entity is DDS.IDomainParticipant) { DDS.IDomainParticipantListener listener = new test.sacs.MyParticipantListener(); DDS.IDomainParticipant domainEntity = (DDS.IDomainParticipant) this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); } } } else if (this.entity is DDS.IPublisher) { DDS.IPublisherListener listener = new test.sacs.MyPublisherListener(); DDS.IPublisher domainEntity = (DDS.IPublisher) this.entity; this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else if (this.entity is DDS.IDataWriter) { DDS.DataWriterListener listener = new test.sacs.MyDataWriterListener(); DDS.IDataWriter domainEntity = (DDS.IDataWriter) this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else if (this.entity is DDS.IDataReader) { DDS.IDataReaderListener listener = new test.sacs.MyDataReaderListener(); DDS.IDataReader domainEntity = (DDS.IDataReader) this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos); } } } else if (this.entity is DDS.ITopic) { DDS.TopicListener listener = new test.sacs.MyTopicListener(); DDS.ITopic domainEntity = (DDS.ITopic) this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic); } } } else if (this.entity is DDS.ISubscriber) { DDS.ISubscriberListener listener = new test.sacs.MySubscriberListener(); DDS.ISubscriber domainEntity = (DDS.ISubscriber) this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders); } } } else { System.Console.Out.WriteLine("Entity type: " + this.entity.ToString() + " not supported."); } System.Console.Out.WriteLine("Thread " + this.id + " finished."); }
public override Test.Framework.TestResult Run() { DDS.IDomainParticipant participant; mod.tstDataWriter writer; mod.tstDataReader reader; mod.tst[] tstHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; test.sacs.MyParticipantListener listener; test.sacs.MyDataReaderListener listener2; string expResult = "DomainParticipantListener test succeeded."; DDS.ReturnCode rc; /* The code below should be replaced with the code following it as soon as scdds2162 is fixed. */ /* Start cutting here >>>>>>>>>>>>>>>>>>>> */ result = new Test.Framework.TestResult(expResult, "Crash by means of stackoverflow.", Test.Framework.TestVerdict.Fail, Test.Framework.TestVerdict.Fail); this.testFramework.TestMessage(Test.Framework.TestMessage.Note, "See scdds2162: Fix some remaining stability issues."); return result; /* Stop cutting here <<<<<<<<<<<<<<<<<<<< */ result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); participant = (DDS.IDomainParticipant)this.ResolveObject("participant"); writer = (mod.tstDataWriter)this.ResolveObject("datawriter"); reader = (mod.tstDataReader)this.ResolveObject("datareader"); listener = new test.sacs.MyParticipantListener(); listener2 = new test.sacs.MyDataReaderListener(); rc = participant.SetListener(listener, (DDS.StatusKind)0); if (rc != DDS.ReturnCode.Ok) { result.Result = "set_listener on DomainParticipant failed."; return result; } rc = participant.SetListener(null, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "Null Listener could not be attached."; return result; } rc = participant.SetListener(listener, (DDS.StatusKind)1012131412); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (2)."; return result; } rc = participant.SetListener(listener, DDS.StatusKind.DataAvailable); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (3)."; return result; } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0L); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return result; } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception e) { System.Console.WriteLine(e); } if (!listener.onDataAvailableCalled) { result.Result = "on_data_available not called."; return result; } listener.Reset(); tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return result; } rc = reader.SetListener(listener2, DDS.StatusKind.DataAvailable); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (4)."; return result; } rc = writer.Write(data, 0L); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return result; } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception e) { System.Console.WriteLine(e); } if (listener.onDataAvailableCalled) { result.Result = "on_data_available is called but shouldn't be."; return result; } if (!listener2.onDataAvailableCalled) { result.Result = "on_data_available not called (2)."; return result; } listener.Reset(); listener2.Reset(); result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public override Test.Framework.TestResult Run() { DDS.IDomainParticipant participant; mod.tstDataWriter writer; mod.tstDataReader reader; mod.tst[] tstHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; test.sacs.MyParticipantListener listener; test.sacs.MyDataReaderListener listener2; string expResult = "DomainParticipantListener test succeeded."; DDS.ReturnCode rc; semaphoresParticipant = new Dictionary <DDS.StatusKind, Semaphore>(); semaphoresParticipant.Add(DDS.StatusKind.DataAvailable, new Semaphore(0, 1)); semaphoresReader = new Dictionary <DDS.StatusKind, Semaphore>(); semaphoresReader.Add(DDS.StatusKind.DataAvailable, new Semaphore(0, 2)); result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); participant = (DDS.IDomainParticipant) this.ResolveObject("participant"); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); listener = new test.sacs.MyParticipantListener(semaphoresParticipant); listener2 = new test.sacs.MyDataReaderListener(semaphoresReader); rc = participant.SetListener(listener, (DDS.StatusKind) 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "set_listener on DomainParticipant failed."; return(result); } rc = participant.SetListener(null, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "Null Listener could not be attached."; return(result); } rc = participant.SetListener(listener, (DDS.StatusKind) 1012131412); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (2)."; return(result); } rc = participant.SetListener(listener, DDS.StatusKind.DataAvailable); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (3)."; return(result); } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0L); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } if (semaphoresParticipant[DDS.StatusKind.DataAvailable].WaitOne(10000)) { if (!listener.onDataAvailableCalled) { result.Result = "on_data_available not called."; return(result); } } else { result.Result = "on_data_available did not trigger"; return(result); } listener.Reset(); tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } rc = reader.SetListener(listener2, DDS.StatusKind.DataAvailable); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (4)."; return(result); } rc = writer.Write(data, 0L); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } try { System.Threading.Thread.Sleep(1000); } catch (System.Exception e) { System.Console.WriteLine(e); } if (listener.onDataAvailableCalled) { result.Result = "on_data_available is called but shouldn't be."; return(result); } if (!listener2.onDataAvailableCalled) { result.Result = "on_data_available not called (2)."; return(result); } listener.Reset(); listener2.Reset(); result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
private static void runListeners(Listener7 listener7, DDS.IEntity entity, int id) { DDS.ReturnCode rc = DDS.ReturnCode.Error; System.Console.Out.WriteLine("Thread {0} started...", id); System.Threading.Thread.Sleep(0); if (entity is DDS.IDomainParticipant) { DDS.IDomainParticipantListener listener = new test.sacs.MyParticipantListener(); DDS.IDomainParticipant domainEntity = (DDS.IDomainParticipant)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); } } } else { if (entity is DDS.IPublisher) { DDS.IPublisherListener listener = new test.sacs.MyPublisherListener(); DDS.IPublisher domainEntity = (DDS.IPublisher)entity; rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else { if (entity is DDS.IDataWriter) { DDS.DataWriterListener listener = new test.sacs.MyDataWriterListener(); DDS.IDataWriter domainEntity = (DDS.IDataWriter)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else { if (entity is DDS.IDataReader) { DDS.IDataReaderListener listener = new test.sacs.MyDataReaderListener(); DDS.IDataReader domainEntity = (DDS.IDataReader)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos); } } } else { if (entity is DDS.ITopic) { DDS.TopicListener listener = new test.sacs.MyTopicListener(); DDS.ITopic domainEntity = (DDS.ITopic)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic); } } } else { if (entity is DDS.ISubscriber) { DDS.ISubscriberListener listener = new test.sacs.MySubscriberListener(); DDS.ISubscriber domainEntity = (DDS.ISubscriber)entity; rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(null, 0); if (rc == DDS.ReturnCode.Ok) { rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders); } } } else { System.Console.Out.WriteLine("Entity type: " + entity.ToString() + " not supported."); } } } } } } System.Console.Out.WriteLine("Thread " + id + " finished."); }
public void Run() { System.Console.Out.WriteLine("Thread " + this.id + " started..."); System.Threading.Thread.Sleep(0); if (this.entity is DDS.IDomainParticipant) { DDS.IDomainParticipantListener listener = new test.sacs.MyParticipantListener(); DDS.IDomainParticipant domainEntity = (DDS.IDomainParticipant)this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); } } } else if (this.entity is DDS.IPublisher) { DDS.IPublisherListener listener = new test.sacs.MyPublisherListener(); DDS.IPublisher domainEntity = (DDS.IPublisher)this.entity; this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else if (this.entity is DDS.IDataWriter) { DDS.DataWriterListener listener = new test.sacs.MyDataWriterListener(); DDS.IDataWriter domainEntity = (DDS.IDataWriter)this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos); } } } else if (this.entity is DDS.IDataReader) { DDS.IDataReaderListener listener = new test.sacs.MyDataReaderListener(); DDS.IDataReader domainEntity = (DDS.IDataReader)this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos); } } } else if (this.entity is DDS.ITopic) { DDS.TopicListener listener = new test.sacs.MyTopicListener(); DDS.ITopic domainEntity = (DDS.ITopic)this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic); } } } else if (this.entity is DDS.ISubscriber) { DDS.ISubscriberListener listener = new test.sacs.MySubscriberListener(); DDS.ISubscriber domainEntity = (DDS.ISubscriber)this.entity; this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(null, 0); if (this.rc == DDS.ReturnCode.Ok) { this.rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders); } } } else { System.Console.Out.WriteLine("Entity type: " + this.entity.ToString() + " not supported."); } System.Console.Out.WriteLine("Thread " + this.id + " finished."); }
public override Test.Framework.TestResult Run() { DDS.IDomainParticipant participant; mod.tstDataWriter writer; mod.tstDataReader reader; mod.tst[] tstHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; test.sacs.MyParticipantListener listener; test.sacs.MyDataReaderListener listener2; string expResult = "DomainParticipantListener test succeeded."; DDS.ReturnCode rc; /* The code below should be replaced with the code following it as soon as scdds2162 is fixed. */ /* Start cutting here >>>>>>>>>>>>>>>>>>>> */ result = new Test.Framework.TestResult(expResult, "Crash by means of stackoverflow.", Test.Framework.TestVerdict.Fail, Test.Framework.TestVerdict.Fail); this.testFramework.TestMessage(Test.Framework.TestMessage.Note, "See scdds2162: Fix some remaining stability issues."); return(result); /* Stop cutting here <<<<<<<<<<<<<<<<<<<< */ result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); participant = (DDS.IDomainParticipant) this.ResolveObject("participant"); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); listener = new test.sacs.MyParticipantListener(); listener2 = new test.sacs.MyDataReaderListener(); rc = participant.SetListener(listener, (DDS.StatusKind) 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "set_listener on DomainParticipant failed."; return(result); } rc = participant.SetListener(null, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "Null Listener could not be attached."; return(result); } rc = participant.SetListener(listener, (DDS.StatusKind) 1012131412); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (2)."; return(result); } rc = participant.SetListener(listener, DDS.StatusKind.DataAvailable); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (3)."; return(result); } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0L); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception e) { System.Console.WriteLine(e); } if (!listener.onDataAvailableCalled) { result.Result = "on_data_available not called."; return(result); } listener.Reset(); tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } rc = reader.SetListener(listener2, DDS.StatusKind.DataAvailable); if (rc != DDS.ReturnCode.Ok) { result.Result = "Listener could not be attached (4)."; return(result); } rc = writer.Write(data, 0L); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception e) { System.Console.WriteLine(e); } if (listener.onDataAvailableCalled) { result.Result = "on_data_available is called but shouldn't be."; return(result); } if (!listener2.onDataAvailableCalled) { result.Result = "on_data_available not called (2)."; return(result); } listener.Reset(); listener2.Reset(); result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }