From 2dfc55735589c04cc0aa7fd8653e205a3ad1c0e5 Mon Sep 17 00:00:00 2001 From: save Date: Wed, 14 Jan 2009 10:04:13 +0000 Subject: [CLEO][PLCDRV]Added hal unitary tests git-svn-id: svn+ssh://pessac/svn/cesar/trunk@3768 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cleopatre/plcdrv/arm/inc/hal.h | 18 +- cleopatre/plcdrv/arm/inc/registers.h | 2 +- cleopatre/plcdrv/arm/src/hal.c | 29 +- cleopatre/plcdrv/arm/utests/Makefile | 2 +- cleopatre/plcdrv/arm/utests/inc/hal_utests.h | 40 +++ cleopatre/plcdrv/arm/utests/inc/mailbox_utests.h | 4 +- cleopatre/plcdrv/arm/utests/src/hal_utests.c | 372 +++++++++++++++++++++++ 7 files changed, 449 insertions(+), 18 deletions(-) create mode 100644 cleopatre/plcdrv/arm/utests/inc/hal_utests.h create mode 100644 cleopatre/plcdrv/arm/utests/src/hal_utests.c (limited to 'cleopatre') diff --git a/cleopatre/plcdrv/arm/inc/hal.h b/cleopatre/plcdrv/arm/inc/hal.h index d9096e2ea3..3d1e58a73e 100644 --- a/cleopatre/plcdrv/arm/inc/hal.h +++ b/cleopatre/plcdrv/arm/inc/hal.h @@ -23,14 +23,21 @@ #define A2L_RING_MASK (A2L_RING_SIZE-1) #define L2A_RING_MASK (L2A_RING_SIZE-1) +#define MAX_MSG_SIZE 8 //in bytes + /** hal layer context structure */ struct halctx { uint32_t *A2L_ptr; uint32_t *L2A_ptr; - const uint32_t *A2L_head; - uint32_t *A2L_tail; uint32_t *L2A_head; +#ifdef __UTESTS__ + uint32_t *A2L_head; + uint32_t *L2A_tail; +#else + const uint32_t *A2L_head; const uint32_t *L2A_tail; +#endif + uint32_t *A2L_tail; uint32_t *A2L_it; uint32_t *L2A_it; uint32_t *L2A_it_mask; @@ -114,6 +121,13 @@ int halmbx_A2Lmail_update(struct halctx *ctx, int size); */ int halmbx_L2Amail_update(struct halctx *ctx, int size); +/** + * Enable the Arm to Leon Acknowledge Interrupt. + * + * \param ctx hal context. + */ +void A2La_it_enable(struct halctx *ctx); + /** * Enable the Leon to Arm Trigger Interrupt. * diff --git a/cleopatre/plcdrv/arm/inc/registers.h b/cleopatre/plcdrv/arm/inc/registers.h index c5e937543b..e2eea9ec93 100644 --- a/cleopatre/plcdrv/arm/inc/registers.h +++ b/cleopatre/plcdrv/arm/inc/registers.h @@ -8,7 +8,7 @@ * * }}} */ /** - * \file hardware.h + * \file registers.h * \brief all hardware definitions * \ingroup Cleopatre - PlcDrv * diff --git a/cleopatre/plcdrv/arm/src/hal.c b/cleopatre/plcdrv/arm/src/hal.c index 0bbeb7f83d..7d29f78bc2 100644 --- a/cleopatre/plcdrv/arm/src/hal.c +++ b/cleopatre/plcdrv/arm/src/hal.c @@ -13,6 +13,7 @@ * this layer provide all Hardware Abstraction: * registers, interrupts. */ +#include #ifndef __UTESTS__ #include "mailbox.h" @@ -87,7 +88,7 @@ void set_A2Lt_interrupt(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->A2L_it |= A2LT_MASK; + *ctx->A2L_it |= A2L_IT; }// set_A2Lt_interrupt /** @@ -100,7 +101,7 @@ void set_L2Aa_interrupt(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->A2L_it |= A2LA_MASK; + *ctx->A2L_it |= A2L_IT_ACK; }// set_L2Aa_interrupt /** @@ -113,7 +114,7 @@ void set_L2Aa_interrupt(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->L2A_it = L2AT_MASK; + *ctx->L2A_it = L2A_IT; }// clr_L2At_interrupt /** @@ -126,7 +127,7 @@ void clr_A2La_interrupt(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->L2A_it = L2AA_MASK; + *ctx->L2A_it = L2A_IT_ACK; }//clr_A2La_interrupt /** @@ -139,7 +140,7 @@ void A2La_it_enable(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->L2A_it_mask &= ~L2AA_EN_MASK; + *ctx->L2A_it_mask &= ~L2A_IT_ACK; }// A2La_it_enable /** @@ -152,7 +153,7 @@ void L2At_it_enable(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->L2A_it_mask &= ~L2AT_EN_MASK; + *ctx->L2A_it_mask &= ~L2A_IT; }// L2At_it_enable /** @@ -165,7 +166,7 @@ void A2La_it_disable(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->L2A_it_mask |= L2AA_EN_MASK; + *ctx->L2A_it_mask |= L2A_IT_ACK; }// A2La_it_disable /** @@ -178,7 +179,7 @@ void L2At_it_disable(struct halctx *ctx) if(ctx == NULL) return; else - *ctx->L2A_it_mask |= L2AT_EN_MASK; + *ctx->L2A_it_mask |= L2A_IT; }// L2At_it_disable /** @@ -215,10 +216,12 @@ int halmbx_A2Lmail_status_queue(struct halctx *ctx) if(ctx == NULL) return -1; - space = ((*ctx->A2L_head - *ctx->A2L_tail) & A2L_RING_MASK); + space = ((*ctx->A2L_tail - *ctx->A2L_head) & A2L_RING_MASK); if((space != 0) && (space <= MAX_MSG_SIZE)) return FULL; + else if ((space != 0) && (space <= (MAX_MSG_SIZE*2))) + return NEARLY_FULL; else return NOT_FULL; }// halmbx_A2Lmail_status_queue @@ -237,10 +240,12 @@ int halmbx_L2Amail_status_queue(struct halctx *ctx) if(ctx == NULL) return -1; - space = ((*ctx->L2A_head - *ctx->L2A_tail) & L2A_RING_MASK); + space = ((*ctx->L2A_tail - *ctx->L2A_head) & L2A_RING_MASK); if((space != 0) && (space <= MAX_MSG_SIZE)) return FULL; + else if ((space != 0) && (space <= (MAX_MSG_SIZE*2))) + return NEARLY_FULL; else return NOT_FULL; }// halmbx_L2Amail_status_queue @@ -264,7 +269,7 @@ int halmbx_copy_to_ring(struct halctx *ctx, uint32_t *message, int size) return -1; //Check size range and alignment on 32bits - if(size > A2L_RING_SIZE || size == 0 || size & 0x3) + if(size > MAX_MSG_SIZE || size == 0 || size & 0x3) return -1; //Check pointer and alignment on 32bits if(message == NULL || ((uint32_t)message & 0x3)) @@ -312,7 +317,7 @@ int halmbx_copy_from_ring(struct halctx *ctx, uint32_t *message, int size) return -1; //Check size range and alignment on 32bits - if(size > L2A_RING_SIZE || size == 0 || size & 0x3) + if(size > MAX_MSG_SIZE || size == 0 || size & 0x3) return -1; //Check pointer and alignment on 32bits if(message == NULL || ((uint32_t)message & 0x3)) diff --git a/cleopatre/plcdrv/arm/utests/Makefile b/cleopatre/plcdrv/arm/utests/Makefile index d861cbbf6a..fad83bbb8e 100644 --- a/cleopatre/plcdrv/arm/utests/Makefile +++ b/cleopatre/plcdrv/arm/utests/Makefile @@ -1,6 +1,6 @@ FILES = linux_drv FILES += processing FILES += mailbox -#FILES += hal +FILES += hal include ../../../common/make/utests_makerules diff --git a/cleopatre/plcdrv/arm/utests/inc/hal_utests.h b/cleopatre/plcdrv/arm/utests/inc/hal_utests.h new file mode 100644 index 0000000000..276cc0c846 --- /dev/null +++ b/cleopatre/plcdrv/arm/utests/inc/hal_utests.h @@ -0,0 +1,40 @@ +#ifndef hal_utests_h +#define hal_utests_h +/* Cleopatre project {{{ + * + * Copyright (C) 2008 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file hal_utests.h + * \brief interfaces for unitary tests of hal layer + * \ingroup Cleopatre - PlcDrv + * + * this file content interfaces and exported macros, variables... For the + * unitary tests of hal layer + */ + +#include +#include +#include +#include "common.h" +#include "registers.h" + +/****************************************************/ +/***** HARDWARE STUB *****/ +/****************************************************/ +static uint32_t MBX_ring[(A2L_RING_SIZE+L2A_RING_SIZE)/4]; //4 for sizeof(int) +static uint32_t MBX_registers[NB_MBX_REGISTERS]; + +/****************************************************/ +/***** LINUX STUB *****/ +/****************************************************/ +#define printk(...) + +/****************************************************/ +/***** SPECIFICS VARIABLES *****/ +/****************************************************/ + +#endif /* hal_utests_h */ diff --git a/cleopatre/plcdrv/arm/utests/inc/mailbox_utests.h b/cleopatre/plcdrv/arm/utests/inc/mailbox_utests.h index b69fb9f599..a0be1023d2 100644 --- a/cleopatre/plcdrv/arm/utests/inc/mailbox_utests.h +++ b/cleopatre/plcdrv/arm/utests/inc/mailbox_utests.h @@ -8,8 +8,8 @@ * * }}} */ /** - * \file processing_utests.h - * \brief interfaces for unitary tests of processing layer + * \file mailbox_utests.h + * \brief interfaces for unitary tests of mailbox layer * \ingroup Cleopatre - PlcDrv * * this file content interfaces and exported macros, variables... For the diff --git a/cleopatre/plcdrv/arm/utests/src/hal_utests.c b/cleopatre/plcdrv/arm/utests/src/hal_utests.c new file mode 100644 index 0000000000..e3f2b37edf --- /dev/null +++ b/cleopatre/plcdrv/arm/utests/src/hal_utests.c @@ -0,0 +1,372 @@ +/* Cleopatre project {{{ + * + * Copyright (C) 2008 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file hal_utests.c + * \brief Unitary tests for HAL layer + * \ingroup Cleopatre - PlcDrv + * + * This file content all the unitary tests for the hal layer, + * this layer will provide all mechanisms to manage hardware. + */ + +#include +#include +#include +#include "hal.h" + +/** local defines */ +#define L2A_RING_BASE_ADDR ((uint32_t)&MBX_ring[A2L_RING_SIZE/4]) +#define A2L_RING_BASE_ADDR ((uint32_t)&MBX_ring[0]) + +/** local variables */ +struct halctx *tstctx; + +struct init_info info = { + .ring_base_addr = (uint32_t)&MBX_ring[0], + .mbx_reg_base_addr = (uint32_t)&MBX_registers[0] +}; + +/** init test procedure */ +START_TEST (test_halmbx_init) +{ + //Check arguments + fail_if(halmbx_init(NULL) != NULL, "halmbx_init arguments error"); + + tstctx = halmbx_init(&info); + + //Check mailbox pointer initialization + fail_if(tstctx->A2L_ptr != &MBX_ring[0], "A2L ring pointer not initialize"); + fail_if(tstctx->L2A_ptr != &MBX_ring[A2L_RING_SIZE/4], "L2A ring pointer not initialize"); + fail_if(tstctx->A2L_head != &MBX_registers[5], "A2L_tail pointer not initialize"); + fail_if(tstctx->A2L_tail != &MBX_registers[4], "A2L_tail pointer not initialize"); + fail_if(tstctx->L2A_head != &MBX_registers[7], "L2A_head pointer not initialize"); + fail_if(tstctx->L2A_tail != &MBX_registers[6], "L2A_tail pointer not initialize"); + fail_if(tstctx->A2L_it != &MBX_registers[0], "A2L it pointer not initialize"); + fail_if(tstctx->L2A_it != &MBX_registers[2], "L2A it pointer not initialize"); + fail_if(tstctx->L2A_it_mask != &MBX_registers[3], "L2A it mask pointer not initialize"); +} +END_TEST + +START_TEST (test_set_A2Lt_interrupt) +{ + *tstctx->A2L_it = 0; + set_A2Lt_interrupt(tstctx); + fail_if(*tstctx->A2L_it != 0x01, "A2L trigger not set"); + *tstctx->A2L_it = 3; + set_A2Lt_interrupt(tstctx); + fail_if(*tstctx->A2L_it != 0x03, "A2L trigger not set"); +} +END_TEST + +START_TEST (test_set_L2Aa_interrupt) +{ + *tstctx->A2L_it = 0; + set_L2Aa_interrupt(tstctx); + fail_if(*tstctx->A2L_it != 0x02, "L2A acknowledge not set"); + *tstctx->A2L_it = 3; + set_L2Aa_interrupt(tstctx); + fail_if(*tstctx->A2L_it != 0x03, "L2A acknowledge not set"); +} +END_TEST + +START_TEST (test_clr_L2At_interrupt) +{ + *tstctx->L2A_it = 1; + clr_L2At_interrupt(tstctx); + fail_if(*tstctx->L2A_it != 0x01, "L2A trigger not clr"); + *tstctx->L2A_it = 2; + clr_L2At_interrupt(tstctx); + fail_if(*tstctx->L2A_it != 0x01, "L2A trigger not clr"); +} +END_TEST + +START_TEST (test_clr_A2La_interrupt) +{ + *tstctx->L2A_it = 2; + clr_A2La_interrupt(tstctx); + fail_if(*tstctx->L2A_it != 0x02, "A2L acknowledge not clr"); + *tstctx->L2A_it = 1; + clr_A2La_interrupt(tstctx); + fail_if(*tstctx->L2A_it != 0x02, "A2L acknowledge not clr"); +} +END_TEST + +START_TEST (test_A2La_it_enable) +{ + *tstctx->L2A_it_mask = 2; + A2La_it_enable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x00, "A2L acknowledge not enable"); + *tstctx->L2A_it_mask = 1; + A2La_it_enable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x01, "A2L acknowledge not enable"); +} +END_TEST + +START_TEST (test_L2At_it_enable) +{ + *tstctx->L2A_it_mask = 1; + L2At_it_enable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x00, "L2A trigger not enable"); + *tstctx->L2A_it_mask = 2; + L2At_it_enable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x02, "L2A trigger not enable"); +} +END_TEST + +START_TEST (test_A2La_it_disable) +{ + *tstctx->L2A_it_mask = 0; + A2La_it_disable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x02, "A2L acknowledge not disable"); + *tstctx->L2A_it_mask = 3; + A2La_it_disable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x03, "A2L acknowledge not disable"); +} +END_TEST + +START_TEST (test_L2At_it_disable) +{ + *tstctx->L2A_it_mask = 0; + L2At_it_disable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x01, "L2A trigger not disable"); + *tstctx->L2A_it_mask = 3; + L2At_it_disable(tstctx); + fail_if(*tstctx->L2A_it_mask != 0x03, "L2A trigger not disable"); +} +END_TEST + +START_TEST (test_halmbx_L2Amail_not_empty_queue) +{ + //The ring size for the test is 0x100 + *tstctx->L2A_tail = 0x5; + *tstctx->L2A_head = 0x5; + fail_if(halmbx_L2Amail_not_empty_queue(tstctx) != 0, "Error checking L2A not empty queue"); + *tstctx->L2A_tail = 0xA; + *tstctx->L2A_head = 0x7; + fail_if(halmbx_L2Amail_not_empty_queue(tstctx) == 0, "Error checking L2A not empty queue"); + *tstctx->L2A_tail = 0x0; + *tstctx->L2A_head = 0xFE; + fail_if(halmbx_L2Amail_not_empty_queue(tstctx) == 0, "Error checking L2A not empty queue"); +} +END_TEST + +START_TEST (test_halmbx_A2Lmail_status_queue) +{ + //The ring size for the test is 0x100 + *tstctx->A2L_tail = 0x05; + *tstctx->A2L_head = 0x05; + fail_if(halmbx_A2Lmail_status_queue(tstctx) != NOT_FULL, "Error checking A2L status queue"); + *tstctx->A2L_tail = 0x54; + *tstctx->A2L_head = 0x04; + fail_if(halmbx_A2Lmail_status_queue(tstctx) != NOT_FULL, "Error checking A2L status queue"); + *tstctx->A2L_tail = 0x20; + *tstctx->A2L_head = 0xF0; + fail_if(halmbx_A2Lmail_status_queue(tstctx) != NOT_FULL, "Error checking A2L status queue"); + *tstctx->A2L_tail = 0x1C; + *tstctx->A2L_head = 0x18; + fail_if(halmbx_A2Lmail_status_queue(tstctx) != FULL, "Error checking A2L status queue"); + *tstctx->A2L_tail = 0x04; + *tstctx->A2L_head = 0xFC; + fail_if(halmbx_A2Lmail_status_queue(tstctx) != FULL, "Error checking A2L status queue"); + *tstctx->A2L_tail = 0x14; + *tstctx->A2L_head = 0x08; + fail_if(halmbx_A2Lmail_status_queue(tstctx) != NEARLY_FULL, "Error checking A2L status queue"); +} +END_TEST + +START_TEST (test_halmbx_L2Amail_status_queue) +{ + //The ring size for the test is 0x100 + *tstctx->L2A_tail = 0x05; + *tstctx->L2A_head = 0x05; + fail_if(halmbx_L2Amail_status_queue(tstctx) != NOT_FULL, "Error checking L2A status queue"); + *tstctx->L2A_tail = 0x54; + *tstctx->L2A_head = 0x04; + fail_if(halmbx_L2Amail_status_queue(tstctx) != NOT_FULL, "Error checking L2A status queue"); + *tstctx->L2A_tail = 0x20; + *tstctx->L2A_head = 0xF0; + fail_if(halmbx_L2Amail_status_queue(tstctx) != NOT_FULL, "Error checking L2A status queue"); + *tstctx->L2A_tail = 0x1C; + *tstctx->L2A_head = 0x18; + fail_if(halmbx_L2Amail_status_queue(tstctx) != FULL, "Error checking L2A status queue"); + *tstctx->L2A_tail = 0x04; + *tstctx->L2A_head = 0xFC; + fail_if(halmbx_L2Amail_status_queue(tstctx) != FULL, "Error checking L2A status queue"); + *tstctx->L2A_tail = 0x14; + *tstctx->L2A_head = 0x08; + fail_if(halmbx_L2Amail_status_queue(tstctx) != NEARLY_FULL, "Error checking L2A status queue"); +} +END_TEST + +START_TEST (test_halmbx_copy_to_ring) +{ + uint32_t msg[] = {0x12345678, 0xFEDCBA98}; + uint32_t *res; + + //Check arguments + fail_if(halmbx_copy_to_ring(NULL,NULL,5) == 0, "Error with no context"); + fail_if(halmbx_copy_to_ring(tstctx,NULL,MAX_MSG_SIZE+5) == 0, "Error with a too big size"); + fail_if(halmbx_copy_to_ring(tstctx,NULL,0) == 0, "Error without size"); + fail_if(halmbx_copy_to_ring(tstctx,NULL,3) == 0, "Error with size not align"); + fail_if(halmbx_copy_to_ring(tstctx,NULL,4) == 0, "Error without pointer"); + fail_if(halmbx_copy_to_ring(tstctx,(uint32_t*)0x67546421,4) == 0, "Error with pointer not align"); + + //Check function + *tstctx->A2L_tail = 0x4; + *tstctx->A2L_head = 0x4; + fail_if(halmbx_copy_to_ring(tstctx,(uint32_t*)msg, sizeof(msg)) != 0, "Error during copy"); + res = (uint32_t*)(A2L_RING_BASE_ADDR + *tstctx->A2L_tail); + fail_if(*res++ != msg[0], "Error with copy"); + fail_if(*res != msg[1], "Error with copy"); + + *tstctx->A2L_tail = 0xFC; + *tstctx->A2L_head = 0xFC; + fail_if(halmbx_copy_to_ring(tstctx,(uint32_t*)msg, sizeof(msg)) != 0, "Error before copy"); + res = (uint32_t*)(A2L_RING_BASE_ADDR + *tstctx->A2L_tail); + fail_if(*res != msg[0], "Error with rollover copy"); //offset=FC to FF + res = (uint32_t*)A2L_RING_BASE_ADDR; + fail_if(*res != msg[1], "Error with rollover copy"); //offset=0 to 3 +} +END_TEST + +START_TEST (test_halmbx_copy_from_ring) +{ + uint32_t msg_origin[] = {0x87654321, 0x89ABCDEF}; + uint32_t msg[2]; + uint32_t *res; + + //Check arguments + fail_if(halmbx_copy_to_ring(NULL,NULL,5) == 0, "Error with no context"); + fail_if(halmbx_copy_from_ring(tstctx,NULL,MAX_MSG_SIZE+5) == 0, "Error with a too big size"); + fail_if(halmbx_copy_from_ring(tstctx,NULL,0) == 0, "Error without size"); + fail_if(halmbx_copy_from_ring(tstctx,NULL,3) == 0, "Error with size not align"); + fail_if(halmbx_copy_from_ring(tstctx,NULL,4) == 0, "Error without pointer"); + fail_if(halmbx_copy_from_ring(tstctx,(uint32_t*)0x67546421,4) == 0, "Error with pointer not align"); + + //Check function + *tstctx->L2A_tail = 0x4; + *tstctx->L2A_head = 0x4; + res = (uint32_t*)(L2A_RING_BASE_ADDR + *tstctx->L2A_head); + *res = msg_origin[0]; + *(res+1) = msg_origin[1]; + fail_if(halmbx_copy_from_ring(tstctx,(uint32_t*)msg, sizeof(msg_origin)) != 0, "Error before copy"); + fail_if(msg[0] != msg[0], "Error with copy"); + fail_if(msg[1] != msg[1], "Error with copy"); + + memset((char*)tstctx->L2A_head, 0, 4); + *tstctx->L2A_tail = 0xFC; + *tstctx->L2A_head = 0xFC; + res = (uint32_t*)(L2A_RING_BASE_ADDR + *tstctx->L2A_head); //offset=FC to FF + *res = msg_origin[0]; + res = (uint32_t*)L2A_RING_BASE_ADDR; //offset=0 to 3 + *(res+1) = msg_origin[1]; + fail_if(halmbx_copy_from_ring(tstctx,(uint32_t*)msg, sizeof(msg_origin)) != 0, "Error before copy"); + fail_if(msg[0] != msg[0], "Error with rollover copy"); + fail_if(msg[1] != msg[1], "Error with rollover copy"); +} +END_TEST + +START_TEST (test_halmbx_A2Lmail_update) +{ + //Check arguments + fail_if(halmbx_A2Lmail_update(NULL,5) == 0, "Error with no context"); + fail_if(halmbx_A2Lmail_update(tstctx,0) == 0, "Error without size"); + + //Check function + *tstctx->A2L_tail = 0x4; + *tstctx->A2L_head = 0x4; + fail_if(halmbx_A2Lmail_update(tstctx,8) != 0, "Error before update"); + fail_if(*tstctx->A2L_tail != 0xC, "Error with update"); + *tstctx->A2L_tail = 0xFC; + *tstctx->A2L_head = 0xFC; + fail_if(halmbx_A2Lmail_update(tstctx,8) != 0, "Error before update"); + fail_if(*tstctx->A2L_tail != 0x4, "Error with rollover update"); +} +END_TEST + +START_TEST (test_halmbx_L2Amail_update) +{ + //Check arguments + fail_if(halmbx_A2Lmail_update(NULL,5) == 0, "Error with no context"); + fail_if(halmbx_L2Amail_update(tstctx,0) == 0, "Error without size"); + + //Check function + *tstctx->L2A_tail = 0x4; + *tstctx->L2A_head = 0x4; + fail_if(halmbx_L2Amail_update(tstctx,4) != 0, "Error before update"); + fail_if(*tstctx->L2A_head != 0x8, "Error with update"); + *tstctx->L2A_tail = 0xFC; + *tstctx->L2A_head = 0xFC; + fail_if(halmbx_L2Amail_update(tstctx,0xC) != 0, "Error before update"); + fail_if(*tstctx->L2A_head != 0x8, "Error with rollover update"); +} +END_TEST + +extern Suite* processing_suite(void) +{ + Suite *s = suite_create("HAL"); + TCase *tc_core = tcase_create("Core"); + + //Test halmbx_init + tcase_add_test(tc_core, test_halmbx_init); + + //Test set_A2Lt_interrupt + tcase_add_test(tc_core, test_set_A2Lt_interrupt); + //Test set_L2Aa_interrupt + tcase_add_test(tc_core, test_set_L2Aa_interrupt); + //Test clr_L2At_interrupt + tcase_add_test(tc_core, test_clr_L2At_interrupt); + //Test clr_A2La_interrupt + tcase_add_test(tc_core, test_clr_A2La_interrupt); + + //Test en_A2La_interrupt + tcase_add_test(tc_core, test_A2La_it_enable); + //Test en_L2At_interrupt + tcase_add_test(tc_core, test_L2At_it_enable); + //Test dis_A2La_interrupt + tcase_add_test(tc_core, test_A2La_it_disable); + //Test dis_L2At_interrupt + tcase_add_test(tc_core, test_L2At_it_disable); + + //Test halmbx_L2Amail_not_empty_queue + tcase_add_test(tc_core, test_halmbx_L2Amail_not_empty_queue); + //Test halmbx_A2Lmail_status_queue + tcase_add_test(tc_core, test_halmbx_A2Lmail_status_queue); + //Test halmbx_L2Amail_status_queue + tcase_add_test(tc_core, test_halmbx_L2Amail_status_queue); + + //Test halmbx_copy_to_ring + tcase_add_test(tc_core, test_halmbx_copy_to_ring); + //Test halmbx_copy_from_ring + tcase_add_test(tc_core, test_halmbx_copy_from_ring); + //Test halmbx_A2Lmail_update + tcase_add_test(tc_core, test_halmbx_A2Lmail_update); + //Test halmbx_L2Amail_update + tcase_add_test(tc_core, test_halmbx_L2Amail_update); + + suite_add_tcase(s, tc_core); + return s; +} + +int main(void) +{ + int number_failed = 0; + Suite *s; + + //Run Processing tests + s = processing_suite(); + + SRunner *sr = srunner_create(s); + srunner_set_fork_status (sr, CK_NOFORK); + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + + return (number_failed == 0) ? 0 : -1; +} + -- cgit v1.2.3