Commit 4ca53c06 authored by Antonia Francis's avatar Antonia Francis

* Gqueue test finished with full documentation and 100% coverage

parent 4deeb350
......@@ -88,6 +88,20 @@ sent, but the previous one (inferior by 1). assert (reception !=
sent_level ); assert (reception == sent_level - 1); The other port
constitutes a control assay.
Test Sporadic 6 :
These tests are used to verify the behavior when working with IN DATA PORTS
and not IN EVENT DATA PORTS. It allows us to get a coverage of 100% of the code
with this test file.
Initially we verify that the reception has been done well.
First we use a get_value function, and then a next_value before verifying that
a get_count on a IN DATA PORT always gives back the value 1 and an used_size
always giving back the value 0.
Thay behavior awaited is illustrated by Beware Warnings.
We try a get_value on an empty port and finally we dequeue the event
sent from Period Port P2 to Sporad Port P1 to trigger the sporadic task.
## Periodic Test details
Each time messages are sent by the periodic task and received by itself.
......@@ -124,8 +138,13 @@ Test Periodic 2 :
This time two messages are as well sent to the periodic task to itself.
The goal is to verify whether, if the queue is full, an error message is well sent.
We set up a reception port with a size of 1 and we sent 2 messages to this port.
If a message is printed, then the test is passed.
The user is able to see it itself on the console.
The goal is to verify whether, if the queue is full, only a message is received
and it is the first one.The transport file must send an error message and prevent
the sending of the file.
The goal is then to verify whether the store_in function is also blocked
when the queue of the destined port isfull.
In both cases we verify that the message first sent is not erased by the other ones,
respectively supposedly not transmitted and not stored_in.
If messages are printed, then the test is passed.
In another hand, the goal is to verify that a get_value on an output port
gives right back an error message.
......@@ -17,6 +17,7 @@ public
P4 : in event data port int { Queue_Size => 42;};
P5 : out event data port int;
P6 : in event data port int {Queue_Size => 1;};
P7 : out data port int; -- XXX
properties
Dispatch_Protocol => Periodic;
Period => 1000 ms;
......@@ -31,9 +32,8 @@ public
thread Spo1
features
P1 : in event data port int { Queue_Size => 42;};
P2 : in event data port int { Queue_Size => 42;};
P3 : out event data port Int;
P4 : in event data port int { Queue_Size => 42;};
P2 : in event data port int { Queue_Size => 42;};
P3 : in data port int;
properties
Dispatch_Protocol => Sporadic; -- Concurrency configuration
Period => 100 ms;
......@@ -56,9 +56,9 @@ public
connections
C1 : port Per_thread.P2 -> Spo_thread.P1;
C2 : port Per_thread.P1 -> Spo_thread.P2;
C3 : port Spo_thread.P3 -> Spo_thread.P4;
C4 : port Per_thread.P3 -> Per_thread.P4;
C5 : port Per_thread.P5 -> Per_thread.P6;
C3 : port Per_thread.P3 -> Per_thread.P4;
C4 : port Per_thread.P5 -> Per_thread.P6;
C5 : port Per_thread.P7 -> Spo_thread.P3;
end Torture_Software.impl;
......
This diff is collapsed.
USER_CFLAGS=-g
USER_CFLAGS=-D__PO_HI_USE_GPROF
COVERAGE=gcov
......@@ -268,6 +268,7 @@ void __po_hi_gqueue_init (__po_hi_task_id id,
assert(__po_hi_gqueues_used_size[id][i] == 0);
assert(__po_hi_gqueues_most_recent_values[id][i].port == __PO_HI_GQUEUE_INVALID_PORT);
if (i > 0){
/* Usually HAS TO be right */
//assert(__po_hi_gqueues_first[id][i] >= 0);
}
}
......@@ -317,7 +318,6 @@ __po_hi_port_id_t __po_hi_gqueue_store_in (__po_hi_task_id id,
__DEBUGMSG ("__po_hi_gqueue_store_in : NULL POINTER\n");
}
#endif
/* Locking only a mutex */
__PO_HI_DEBUG_DEBUG ("\nWaiting on Store_in on task %d, port = %d, size of port = %d\n", id, port,__po_hi_gqueue_get_port_size(id, port));
int result = __po_hi_sem_mutex_wait_gqueue(__po_hi_gqueues_semaphores,id);
......@@ -327,6 +327,7 @@ __po_hi_port_id_t __po_hi_gqueue_store_in (__po_hi_task_id id,
if (__po_hi_gqueue_get_port_size(id,port) == __PO_HI_GQUEUE_FIFO_INDATA)
{
memcpy(ptr,request,sizeof(*request));
__PO_HI_DEBUG_CRITICAL ("[GQUEUE] BEWARE, for a FIFO_INDATA port, the used_size is always at 0 (not augmented in a store_in) task-id=%d, port=%d\n", id, port);
}
else
{
......@@ -386,7 +387,6 @@ __po_hi_port_id_t __po_hi_gqueue_store_in (__po_hi_task_id id,
int rel = __po_hi_sem_release_gqueue(__po_hi_gqueues_semaphores,id);
__DEBUGMSG("GQUEUE_SEM_RELEASE %d %d\n", id, rel);
assert(rel == __PO_HI_SUCCESS);
__DEBUGMSG ("[GQUEUE] store_in completed\n");
#ifdef __PO_HI_GQUEUE_ASSERTIONS
......@@ -460,6 +460,7 @@ int __po_hi_gqueue_get_count( __po_hi_task_id id, __po_hi_local_port_t port)
{
if (__po_hi_gqueue_get_port_size(id,port) == __PO_HI_GQUEUE_FIFO_INDATA)
{
__PO_HI_DEBUG_CRITICAL ("[GQUEUE] BEWARE a FIFO_INDATA port will always have a get_count of 1, even if empty, task-id=%d, port=%d\n", id, port);
return 1; /* data port are always of size 1 */
}
else
......@@ -488,15 +489,21 @@ int __po_hi_gqueue_get_value (__po_hi_task_id id,
* If the port is an OUTPUT, with no value queued, the function returns
* nothing.
*/
if (__po_hi_gqueue_get_port_size(id,port) == 0)
if (__po_hi_gqueue_get_port_size(id,port) == -2)
{
__PO_HI_DEBUG_CRITICAL ("[GQUEUE] OUTPUT PORT, REQUEST NOT SET UP, task-id=%d, port=%d\n", id, port);
__DEBUGMSG("THE PORT IS AN OUTPUT, REQUEST NOT SET UP");
return 0;
/* Releasing only the mutex of the semaphore*/
int rel = __po_hi_sem_mutex_release_gqueue(__po_hi_gqueues_semaphores,id);
__DEBUGMSG("GQUEUE_SEM_MUTEX_RELEASE %d %d\n", id, rel);
assert(rel == __PO_HI_SUCCESS);
return __PO_HI_INVALID;
}
/*
* If the port is an event port, with no value queued, then we block
* the thread.
*/
/* Empty port case 1 : NO FIFO INDATA */
if (__po_hi_gqueue_get_port_size(id,port) != __PO_HI_GQUEUE_FIFO_INDATA)
{
while (__po_hi_gqueues_port_is_empty[id][port] == 1)
......@@ -507,7 +514,8 @@ int __po_hi_gqueue_get_value (__po_hi_task_id id,
assert(res_sem == __PO_HI_SUCCESS);
}
}
if (__po_hi_gqueue_used_size(id,port) == 0)
/* Empty port case 2 : FIFO INDATA */
if ((__po_hi_gqueue_get_port_size(id,port) == __PO_HI_GQUEUE_FIFO_INDATA) && (__po_hi_gqueue_used_size(id,port) == 0))
{
memcpy (request, ptr, sizeof (__po_hi_request_t));
//update_runtime (id, port, ptr);
......@@ -536,7 +544,7 @@ int __po_hi_gqueue_get_value (__po_hi_task_id id,
assert(res == __PO_HI_SUCCESS);
__PO_HI_DEBUG_DEBUG("After get_value for task-id %d , port = %d, offset = %d, woffset = %d, history_offset = %d, history_woffset = %d, port size = %d, fifo size = %d, gqueues adress = %d \n\n", id, port, __po_hi_gqueues_offsets[id][port], __po_hi_gqueues_woffsets[id][port],__po_hi_gqueues_global_history_offset[id],__po_hi_gqueues_global_history_woffset[id], __po_hi_gqueues_sizes[id][port], __po_hi_gqueues_total_fifo_size[id], __po_hi_gqueues[id]);
return 0;
return __PO_HI_SUCCESS;
}
/******************************************************************************/
......@@ -550,11 +558,11 @@ int __po_hi_gqueue_next_value (__po_hi_task_id id, __po_hi_local_port_t port)
__po_hi_port_id_t nb_empty = __po_hi_gqueues_n_empty[id];
#endif
/* incomplete semantics, should discriminate and report whether
/* Incomplete semantics, Should discriminate and report whether
there is a next value or not */
/* XXX change and use assert ? */
if (__po_hi_gqueue_get_port_size(id,port) == __PO_HI_GQUEUE_FIFO_INDATA)
{
__PO_HI_DEBUG_CRITICAL ("[GQUEUE] BEWARE, for a FIFO_INDATA port, the used_size is always at 0 (not reduced in a next_value) task-id=%d, port=%d\n", id, port);
return 1;
}
......
......@@ -80,13 +80,16 @@ long int __po_hi_air_port[__PO_HI_NB_PORTS];
int __po_hi_xtratum_port[__PO_HI_NB_PORTS];
#endif
int __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port)
{
__po_hi_request_t* request;
__po_hi_uint8_t ndest;
__po_hi_uint8_t i;
__po_hi_local_port_t local_port;
__po_hi_port_t destination_port;
__po_hi_local_port_t destination_port_local;
__po_hi_entity_t destination_entity;
local_port = __po_hi_get_local_port_from_global_port (port);
......@@ -94,13 +97,13 @@ int __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port)
if (request->port == -1)
{
__PO_HI_DEBUG_DEBUG ("Send output task %d, port %d : no value to send\n", id, port);
__PO_HI_DEBUG_DEBUG ("Send output task %d, global port %d : no value to send\n", id, port);
return __PO_HI_SUCCESS;
}
ndest = __po_hi_gqueue_get_destinations_number (id, local_port);
assert(ndest);
__PO_HI_DEBUG_DEBUG ("Send value, emitter task %d, emitter port %d, emitter entity %d, destination ports :\n", id, port, __po_hi_port_global_to_entity[port]);
__PO_HI_DEBUG_DEBUG ("Send value, emitter task %d, emitter port %d, emitter port local %d, emitter entity %d, destination ports list:\n", id, port, local_port, __po_hi_port_global_to_entity[port]);
#if __PO_HI_DEBUG_LEVEL >= __PO_HI_DEBUG_LEVEL_INFO
__DEBUGMSG ("Packet to send: |");
......@@ -119,13 +122,18 @@ int __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port)
}
__DEBUGMSG ("|\n");
#endif
for (i=0 ; i < __po_hi_gqueue_get_destinations_number (id, local_port) ; i++)
{
destination_port = __po_hi_gqueue_get_destination (id, local_port, i);
destination_port_local = __po_hi_get_local_port_from_global_port (destination_port);
destination_entity = __po_hi_get_entity_from_global_port (destination_port);
assert(destination_entity != -1);
__PO_HI_DEBUG_DEBUG ("\t%d (entity=%d)", destination_port, destination_entity);
__PO_HI_DEBUG_DEBUG ("Destination number %d, global port \t%d, local port %d, (entity=%d)", i, destination_port, destination_port_local, destination_entity);
if ((__po_hi_gqueue_used_size(id, destination_port_local) == __po_hi_gqueue_get_port_size(id, destination_port_local)) && (__po_hi_gqueue_get_port_size(id, destination_port_local) != __PO_HI_GQUEUE_FIFO_INDATA)){
/* The gqueue on the destination port is full, error message transmitted */
__PO_HI_DEBUG_CRITICAL("[TRANSPORT] QUEUE FULL ON THE DESTINATION PORT, NOT TRANSMITTED, task-id=%d, port=%d", id, destination_port_local);
return __PO_HI_ERROR_QUEUE_FULL;
}
request->port = destination_port;
......@@ -219,7 +227,6 @@ int __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port)
(ANY, TRANSPORT_SEND, id, port, destination_port, local_port,
__po_hi_get_local_port_from_global_port (destination_port), request);
#endif
}
request->port = __PO_HI_GQUEUE_INVALID_PORT;
......@@ -231,6 +238,7 @@ int __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port)
return __PO_HI_SUCCESS;
}
__po_hi_node_t __po_hi_transport_get_node_from_entity (const __po_hi_entity_t entity)
{
return __po_hi_entity_table[entity];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment