test_wait Subroutine

public subroutine test_wait()

Arguments

None

Calls

proc~~test_wait~~CallsGraph proc~test_wait test_wait add_message add_message proc~test_wait->add_message assertequal assertequal proc~test_wait->assertequal asserttrue asserttrue proc~test_wait->asserttrue none~add_ext_collection~2 ClientThread%add_ext_collection proc~test_wait->none~add_ext_collection~2 none~get_connection BaseThread%get_connection proc~test_wait->none~get_connection none~prefetch_data~2 ClientThread%prefetch_data proc~test_wait->none~prefetch_data~2 none~set_connection BaseThread%set_connection proc~test_wait->none~set_connection none~add_ext_collection~2->none~get_connection interface~mapl_assert MAPL_Assert none~add_ext_collection~2->interface~mapl_assert proc~mapl_return MAPL_Return none~add_ext_collection~2->proc~mapl_return proc~mapl_verify MAPL_Verify none~add_ext_collection~2->proc~mapl_verify receive receive none~add_ext_collection~2->receive send send none~add_ext_collection~2->send none~get_connection->interface~mapl_assert none~get_connection->proc~mapl_return none~prefetch_data~2->none~get_connection get get none~prefetch_data~2->get none~get_unique_request_id ClientThread%get_unique_request_id none~prefetch_data~2->none~get_unique_request_id none~insert_requesthandle BaseThread%insert_RequestHandle none~prefetch_data~2->none~insert_requesthandle none~prefetch_data~2->proc~mapl_return none~prefetch_data~2->proc~mapl_verify none~prefetch_data~2->receive none~prefetch_data~2->send none~set_connection->proc~mapl_return none~insert_requesthandle->proc~mapl_return none~insert~25 IntegerRequestMap%insert none~insert_requesthandle->none~insert~25 at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception none~insert_pair~3 IntegerRequestMap%insert_pair none~insert~25->none~insert_pair~3

Source Code

   subroutine test_wait()
      type (MockClientThread), target :: c
      class (AbstractSocket), pointer :: connection
      integer :: collection_id

      integer :: request_id1
      integer :: request_id2

      real(kind=REAL32), target :: q1
      real(kind=REAL32), target :: q2(3)
      real(kind=REAL32) :: q1_expected = 3.14
      real(kind=REAL32) :: q2_expected(3) = [1,2,3]

      character(len=:), allocatable :: expected_log
      type (MockSocketLog), target :: log
      type(MockSocket), target :: ms

      ms = MockSocket(log)
      call c%set_connection(ms)
      connection => c%get_connection()
      select type (connection)
      type is (MockSocket)
         call connection%add_message(IdMessage(1))
         call connection%add_message(IdMessage(1)) ! note value not used
         call connection%add_message(IdMessage(2))
         connection%q1 = q1_expected
         connection%q2 = q2_expected
      end select

      collection_id = c%add_ext_collection(template='foo')
      request_id1 = c%prefetch_data(collection_id, 'foo', 'q1', ArrayReference(q1))
      request_id2 = c%prefetch_data(collection_id, 'foo', 'q2', ArrayReference(q2))

      call c%wait(request_id1)
      call c%wait(request_id2)

      @assertTrue (request_id1 /= request_id2)

      expected_log = "send<AddExtCollection('foo')>"
      expected_log = expected_log // " :: send<PrefetchData('q1')>"
      expected_log = expected_log // " :: get()"
      expected_log = expected_log // " :: send<PrefetchData('q2')>"
      expected_log = expected_log // " :: get()"
      !write(str,'(i0)') request_id1
      !expected_log = expected_log // " :: send<Wait("//trim(str)//")>"
      !write(str,'(i0)') request_id2
      expected_log = expected_log // " :: wait()"
      !expected_log = expected_log // " :: send<Wait("//trim(str)//")>"
      expected_log = expected_log // " :: wait()"

      select type (connection)
      type is (MockSocket)
         @assertEqual(expected_log, log%log)
      end select

      @assertEqual(q1_expected, q1)
      @assertEqual(q2_expected, q2)
         
   end subroutine test_wait