Commit b0829d24 authored by Greg Williams's avatar Greg Williams
Browse files

Added some missed files due at last commit :(

parent 9fbc3ba5
Loading
Loading
Loading
Loading
+31 −13
Original line number Diff line number Diff line
@@ -156,39 +156,57 @@ namespace :test_server do
      @port = port
      @server = nil
      @worker = nil
      @listeners = []
    end

    def start
      return unless @server.nil?

      # Start the werver
      @server = WEBrick::HTTPServer.new(:Port => @port)

      # Mount test server servlet
      @server.mount "/", KineticServlet
      @server = TCPServer.new @port
      @listeners = []

      # Setup handler for signaled shutdown (via ctrl+c)
      trap("INT") do
        report "INT triggered Kintic Test Server shutdown"
        report "Test server: INT triggered Kintic Test Server shutdown"
        shutdown
      end

      # Create worker thread for test server to run in so we can continue
      @worker = Thread.new do
        @server.start
        report "Test server: Listening for Kinetic clients..."
        loop do
          @listeners << Thread.start(@server.accept) do |client|
            report "Test server: Connected to #{client.inspect}"
            request = ""
            while request += client.getc # Read characters from socket
              request_match = request.match(/^read\((\d+)\)/)
              if request_match
                len = request_match[1].to_i
                response = "G"*len
                report "Test server: Responding to 'read(#{len})' w/ '#{response}'"
                client.write response
                request = ""
              end
            end
            # report "Test server: Client #{client.inspect} disconnected!"
          end
        end
      end

    end

    def shutdown
      return if @server.nil?
      if @worker
        report_banner "Kinetic Test Server shutting down..."
        @server.shutdown
        @worker.join(5)
      report_banner "Test server: Kinetic Test Server shutting down..."
      @listeners.each do |client|
        client.join(0.3) if client.alive?
      end
      @server = nil
      @listeners = []
      @worker.exit
      @worker = nil
      report "Kinetic Test Server shutdown complete"
      @server.close
      @server = nil
      report "Test server: Kinetic Test Server shutdown complete"
    end

  end
+12 −6
Original line number Diff line number Diff line
@@ -81,13 +81,13 @@ void test_KineticPDU_Init_should_populate_the_PDU_structure_and_PDU_buffer_with_
    // Validate 'value' field is empty
    TEST_ASSERT_EQUAL(0, PDU.valueLength);

    // // Validate proto buf size and packed content
    // ProtoBufferLength = KineticProto_get_packed_size(&Message.proto);
    // TEST_ASSERT_EQUAL_NBO_INT64(ProtoBufferLength, PDU.protoLength);
    // Validate proto buf size and packed content
    ProtoBufferLength = KineticProto_get_packed_size(&Message.proto);
    TEST_ASSERT_EQUAL_NBO_INT64(ProtoBufferLength, PDU.protoLength);

    // // Validate value field size (no content)
    // TEST_ASSERT_NULL(PDU.value);
    // TEST_ASSERT_EQUAL_NBO_INT64(0, PDU.valueLength);
    // Validate value field size (no content)
    TEST_ASSERT_NULL(PDU.value);
    TEST_ASSERT_NULL(PDU.valueLength);
}

void test_KineticPDU_Init_should_populate_the_PDU_structure_and_PDU_buffer_with_the_supplied_protocol_buffer_and_value_payload(void)
@@ -96,6 +96,12 @@ void test_KineticPDU_Init_should_populate_the_PDU_structure_and_PDU_buffer_with_

    KineticPDU_Init(&PDU, &Exchange, PDUBuffer, &Message, Value, ValueLength);

    // Validate KineticExchange associated
    TEST_ASSERT_EQUAL_PTR(&Exchange, PDU.exchange);

    // Validate KineticMessage associated
    TEST_ASSERT_EQUAL_PTR(&Message, PDU.message);

    // Valiate prefix
    TEST_ASSERT_EQUAL_HEX8('F', *PDU.prefix);