/*
 * This function sets up all required test data with a Tpm2Response
 * object that has attributes indicating the response has a handle
 * in it.
 */
static void
tpm2_response_setup_with_handle (void **state)
{
    test_data_t *data;
    TPMA_CC attributes = {
        .val = 1 << 28,
    };

    tpm2_response_setup_base (state);
    data = (test_data_t*)*state;
    data->response = tpm2_response_new (data->connection,
                                        data->buffer,
                                        attributes);
    set_response_size (data->buffer, TPM_HEADER_SIZE + sizeof (TPM_HANDLE));
    data->buffer [TPM_RESPONSE_HEADER_SIZE]     = 0xde;
    data->buffer [TPM_RESPONSE_HEADER_SIZE + 1] = 0xad;
    data->buffer [TPM_RESPONSE_HEADER_SIZE + 2] = 0xbe;
    data->buffer [TPM_RESPONSE_HEADER_SIZE + 3] = 0xef;
}
/**
 * Tear down all of the data from the setup function. We don't have to
 * free the data buffer (data->buffer) since the Tpm2Response frees it as
 * part of its finalize function.
 */
static void
tpm2_response_teardown (void **state)
{
    test_data_t *data = (test_data_t*)*state;

    g_object_unref (data->connection);
    g_object_unref (data->response);
    free (data);
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
void dcl_message< msgEnqueueReadBuffer >::parse_request( const void* payload_ptr )
{
    const void* enqueue_ptr = enqueue_message::parse_enqueue_request( payload_ptr );

    const msgEnqueueReadBuffer_request* request_ptr = 
        reinterpret_cast< const msgEnqueueReadBuffer_request* >( enqueue_ptr );

    remote_id_ = network_to_host( request_ptr->id_ );
    size_ = network_to_host( request_ptr->size_ );
    offset_ = network_to_host( request_ptr->offset_ );

//    std::cerr << "read remote message id: " << remote_id_ << std::endl;

    set_response_size( size_ +
                       sizeof(msgEnqueueReadBuffer_response) - 1 );
}