]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Refaktoring. Test-suite3 updated. Suite_1 currently broken
authormahi <devnull@localhost>
Tue, 6 Jul 2010 05:32:37 +0000 (07:32 +0200)
committermahi <devnull@localhost>
Tue, 6 Jul 2010 05:32:37 +0000 (07:32 +0200)
28 files changed:
common/printf.c
examples/simple/build_config.mk
system/kernel/event.c
system/kernel/include/sys.h
system/kernel/task.c
system/kernel/testsystem/os_test.h
system/kernel/testsystem/suite_01/test_01_task.c
system/kernel/testsystem/suite_01/test_02_resource.c
system/kernel/testsystem/suite_01/test_03_alarm.c
system/kernel/testsystem/suite_01/test_04_stable.c
system/kernel/testsystem/suite_01/test_master.c
system/kernel/testsystem/suite_02/test_master.c
system/kernel/testsystem/suite_03/Os_Cfg.c
system/kernel/testsystem/suite_03/Os_Cfg.h
system/kernel/testsystem/suite_03/config_03.arxml
system/kernel/testsystem/suite_03/test_master.c
system/kernel/testsystem/test_01_task.c
system/kernel/testsystem/test_02_resource.c
system/kernel/testsystem/test_03_alarm.c
system/kernel/testsystem/test_04_stable.c
system/kernel/testsystem/test_framework.c
system/kernel/testsystem/test_framework.h
system/kernel/testsystem/test_sup_01.c
system/kernel/testsystem/test_sup_02.c
system/kernel/testsystem/test_sup_03.c
system/kernel/testsystem/test_sup_04.c
system/kernel/testsystem/test_sup_05.c
system/kernel/testsystem/test_sup_irq.c

index 547fdfc6698952aafc328d26a93b1f294ff3d7b6..2cd3ee28f2726d4ff52e5c5819a5818110ea52d6 100644 (file)
@@ -112,6 +112,7 @@ int vfprintf(FILE *file, const char *format, va_list ap) {
        return rv;
 }
 
+
 int vsnprintf(char *buffer, size_t n, const char *format, va_list ap) {
        int rv;
 
@@ -120,6 +121,76 @@ int vsnprintf(char *buffer, size_t n, const char *format, va_list ap) {
 }
 
 
+/*
+ * The integer only counterpart
+ */
+int iprintf(const char *format, ...) {
+       va_list ap;
+       int rv;
+
+       va_start(ap, format);
+       rv = vfprintf(_STDOUT, format, ap);
+       va_end(ap);
+       return rv;
+}
+
+int fiprintf(FILE *file, const char *format, ...) {
+       va_list ap;
+       int rv;
+
+       va_start(ap, format);
+       rv = vfprintf(file, format, ap);
+       va_end(ap);
+       return rv;
+}
+
+
+int siprintf(char *buffer, const char *format, ...) {
+       va_list ap;
+       int rv;
+
+       va_start(ap, format);
+       rv = vsnprintf(buffer, ~(size_t)0, format, ap);
+       va_end(ap);
+
+       return rv;
+}
+
+int sniprintf(char *buffer, size_t n, const char *format, ...) {
+       va_list ap;
+       int rv;
+
+       va_start(ap, format);
+       rv = vsnprintf(buffer, n, format, ap);
+       va_end(ap);
+       return rv;
+}
+
+int viprintf(const char *format, va_list ap) {
+       return vfprintf(_STDOUT, format, ap);
+}
+
+int vsiprintf(char *buffer, const char *format, va_list ap) {
+       return vsnprintf(buffer, ~(size_t)0, format, ap);
+}
+
+
+int vfiprintf(FILE *file, const char *format, va_list ap) {
+       int rv;
+       /* Just print to _STDOUT */
+       rv = print(file,NULL,~(size_t)0, format,ap);
+       return rv;
+}
+
+int vsniprintf(char *buffer, size_t n, const char *format, va_list ap) {
+       int rv;
+
+       rv = print(NULL, &buffer, n, format,ap);
+       return rv;
+}
+
+
+
 /**
  *
  * @param file  The file to print to
index e401c2d748ce222ce8ba03497e1ef7d557dffdcd..a1d32b06ef1550bca4d8f75ac8f8fe40310c2693 100644 (file)
@@ -4,4 +4,5 @@
 \r
 MOD_USE+= COMMON DET ECUM MCU NEWLIB KERNEL RAMLOG \r
 \r
+#def-y += NDEBUG\r
 #def-y += HEAPSIZE=1400
\ No newline at end of file
index 44678bfdab9638cd971b7c3fcd761b9a589177df..a8a8ff8228135985fe840b3bf055fb4e4df5a462 100644 (file)
@@ -86,15 +86,14 @@ StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {
        OsPcbType *dest_pcb;
        OsPcbType *currPcbPtr;
        uint32_t flags;\r
-\r
-       dest_pcb = os_get_pcb(TaskID);
 
-\r
        if( TaskID  >= Os_CfgGetTaskCnt() ) {
                rv = E_OS_ID;
                goto err;
        }
 \r
+       dest_pcb = os_get_pcb(TaskID);
+\r
        if( (dest_pcb->state & ST_SUSPENDED ) ) {\r
                rv = E_OS_STATE;\r
                goto err;\r
@@ -128,8 +127,10 @@ StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {
                        currPcbPtr = Os_TaskGetCurrent();
                        /* Checking "4.6.2  Non preemptive scheduling" it does not dispatch if NON  */
                        if( (os_sys.int_nest_cnt == 0) &&
-                               (currPcbPtr->scheduling == FULL) )
+                               (currPcbPtr->scheduling == FULL) &&
+                               (dest_pcb->prio > currPcbPtr->prio) )
                        {
+                               Os_SetOp(OP_SET_EVENT);
                                Os_Dispatch(0);
                        }
 
@@ -160,6 +161,11 @@ StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask) {
 \r
        OsPcbType *dest_pcb;\r
        StatusType rv = E_OK;\r
+
+       if( TaskId  >= Os_CfgGetTaskCnt() ) {
+               rv = E_OS_ID;
+               goto err;
+       }
 \r
        dest_pcb = os_get_pcb(TaskId);\r
 \r
index bb68321df0e6dbc7b9d156291bdf35a00c3704f4..5a257a249611b9c28deca95a556dad812e1902bd 100644 (file)
 #define SYS_H_\r
 \r
 struct os_conf_global_hook_s;\r
+
+#define OP_SET_EVENT           1
+#define OP_ACTIVATE_TASK       2
+
 \r
 typedef struct sys_s {\r
 //     OsApplicationType *curr_application;\r
@@ -25,7 +29,9 @@ typedef struct sys_s {
        /* List of all tasks */\r
        OsPcbType *pcb_list;\r
        /* Interrupt nested count */\r
-       uint32 int_nest_cnt;\r
+       uint32 int_nest_cnt;
+       /* The current operation */
+       uint8_t op;\r
        /* Ptr to the interrupt stack */\r
        void *int_stack;\r
        // The os tick\r
@@ -54,6 +60,14 @@ typedef struct sys_s {
 } sys_t;\r
 \r
 extern sys_t os_sys;\r
+
+static inline void Os_SetOp( uint8_t op) {
+       os_sys.op = op;
+}
+
+static inline uint8_t Os_GetOp( void ) {
+       return os_sys.op;
+}
 \r
 static inline OsPcbType *Os_TaskGetCurrent(  void ) {\r
        return os_sys.curr_pcb;\r
index b746d6f8487c0e2a3735ad600e7d2167736c9e80..c77d2a201546574ac278235d4960aed1b7f105d5 100644 (file)
@@ -335,14 +335,25 @@ void Os_Dispatch( _Bool force ) {
                PRETASKHOOK();
 
        } else {
-               /* We want to run the same task, again. This only happens
-                * when we have multiple activation of a basic task (
-                * extended tasks have an activation limit of 1)
-                */
+               if( Os_GetOp() != OP_SET_EVENT ) {
+
+                       /* We want to run the same task, again. This only happens
+                        * when we have multiple activation of a basic task (
+                        * extended tasks have an activation limit of 1)
+                        */
 
-               /* Setup the stack again, and just call the basic task */
-               Os_StackSetup(pcbPtr);
-               Os_ArchSetSpAndCall(pcbPtr->stack.curr,Os_TaskStartBasic);
+                       /* Setup the stack again, and just call the basic task */
+                       Os_StackSetup(pcbPtr);
+                       Os_ArchSetSpAndCall(pcbPtr->stack.curr,Os_TaskStartBasic);
+               } else {
+                       /* Two cases:
+                        * 1. SetEvent() on itself
+                        * 2. SetEvent()
+                        *
+                        *
+                        * */
+
+               }
        }
 }
 
index b093b5db17731b0f4420562345cc9d7d3f54b248..1585a59f53ead415404968a07bbba199c1e06cd0 100644 (file)
 #ifndef OS_TEST_H_\r
 #define OS_TEST_H_\r
 \r
-#include "test_framework.h"
-#include "debug.h"\r
-\r
-typedef void (*test_func_t)( void );
-\r
-
-#define TEST_INIT()                    printf("Test init\n");\r
-#define TEST_FAIL(_text)               test_fail((_text),  __FILE__,  __LINE__, __FUNCTION__ )\r
-#define TEST_OK()                              test_ok();
-#define TEST_ASSERT(_cond)                     if(!(_cond)) { TEST_FAIL(#_cond); }
-/* Start to run a test */
-#define TEST_RUN()                             printf("Running test %d\n",test_nr);
-/* Indicate that a test is done */
-//#define TEST_DONE()
-#define TEST_START(_str,_nr)           testStart(_str,_nr)
-#define TEST_NEXT(_str,_next_nr)       testEnd(); testStart(_str,_next_nr);
-#define TEST_END()                                     testEnd()
-\r
-\r
-extern int test_suite;\r
-extern int test_nr;
-
-#define TASK_ID_ILL                    99
-#define RES_ID_ILL                             99
-#define ALARM_ID_ILL                   99
-#define SCHTBL_ID_ILL  99
-#define COUNTER_ID_ILL                 99
-\r
-#if 1\r
-#define SECTION_SUP\r
-#define SECTION_USER\r
-#else\r
-#define SECTION_SUP                    __attribute__ ((section(".text_app_sup")))\r
-#define SECTION_USER           __attribute__ ((section(".text_app_user")))\r
-#endif\r
-\r
-#define SECTION_BSS_SUPER      __attribute__ ((aligned (16),section(".bss")))\r
-#define SECTION_BSS_USER       __attribute__ ((aligned (16),section(".bss")))\r
-
-#define OS_STR__(x)            #x
-#define OS_STRSTR__(x)         OS_STR__(x)
-
-#define DECLARE_TEST_BTASK(_nr, _task1, _task2, _task3 ) \
-               __attribute__ ((section (".test_btask"))) const test_func_t btask_sup_matrix_ ## _nr[3] = { _task1, _task2, _task3 }
-
-#define DECLARE_TEST_ETASK(_nr, _task1, _task2, _task3 ) \
-               __attribute__ ((section (".test_etask"))) const test_func_t etask_sup_matrix_ ## _nr[3]  = { _task1, _task2, _task3 }
-\r
-#define DECLARE_TASKS(_nr) \\r
-       void etask_sup_l_##_nr( void ); \\r
-       void etask_sup_m_##_nr( void ); \\r
-       void etask_sup_h_##_nr( void ); \\r
-       void btask_sup_l_##_nr( void ); \\r
-       void btask_sup_m_##_nr( void ); \\r
-       void btask_sup_h_##_nr( void );\r
-\r
-\r
-/*\r
- * Declare tests
- */\r
-\r
-// Test master processes\r
-void OsIdle(void );\r
-void etask_master( void );\r
-void etask_sup_l( void ) SECTION_SUP;\r
-void etask_sup_m( void ) SECTION_SUP;\r
-void etask_sup_h( void ) SECTION_SUP;\r
-\r
-void btask_sup_l( void ) SECTION_SUP;\r
-void btask_sup_m( void ) SECTION_SUP;\r
-void btask_sup_h( void ) SECTION_SUP;\r
-\r
-\r
-// Tests\r
-DECLARE_TASKS(01);\r
-DECLARE_TASKS(02);\r
-DECLARE_TASKS(03);
-DECLARE_TASKS(04);\r
 \r
 #endif /* OS_TEST_H_ */\r
index ce87d76e9c818fd643b93e89c91de9adbb94c8ca..3e8210541dddf26553a0f5d1cdbdaed623fb786e 100644 (file)
@@ -32,7 +32,7 @@
  */\r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 \r
 int btaskRunCnt = 0;\r
index 7f66b146da591b2134fa4b82354d67d07937647d..6369690973c27f66f35e2a3c966aff5669db4519 100644 (file)
@@ -32,7 +32,7 @@
  */\r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 #include "irq.h"\r
 \r
index 288227c404f289ae0ccd55037f55788dfbe508f1..c764095d77f2c040034dd18b638da8ca6e3f2d1d 100644 (file)
@@ -35,7 +35,7 @@
 \r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 \r
 \r
index 9ca3feea23e0e5644e70865c046b2b4bf521c2fa..fe8049300b04f364b5b07dd7549a92963c458e4a 100644 (file)
@@ -34,7 +34,7 @@
  */\r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 \r
 \r
index 8abe33543544ff7bc7467251a550bd9f17bb5015..19bf15a01259dda9ee67539063e9a9aafa4bfcd9 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <stdlib.h>\r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "Mcu.h"\r
 #if defined(USE_GPT)\r
 #include "Gpt.h"\r
@@ -73,7 +73,7 @@ void etask_master( void ) {
        }\r
 
        // Test complete..
-       testExit(0);
+       TestExit(0);
 }\r
 
 extern test_func_t etask_sup_matrix[][3];
index cb74fa5eafbe3dccb5cba759afe1d7f4634e78ce..9a0c35ca5e71507d58798771e6f7de5bed55fa8b 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <stdlib.h>\r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "Mcu.h"\r
 #if defined(USE_GPT)\r
 #include "Gpt.h"\r
@@ -208,7 +208,7 @@ void etask_master( void ) {
        GetEvent(currTask,&evMask);
        TEST_ASSERT( evMask == mask);
 
-       testExit(0);
+       TestExit(0);
 }\r
 
 //--------------------------------------------------------------------\r
index f44e077ae4fa79b5419956aaf6e250494c3027e5..8affd1a727f9efb3dadd94a44427fd193eecd9f1 100644 (file)
@@ -9,7 +9,7 @@
 * 
 * 
 * Generated by Arctic Studio (http://arccore.com)
-*           on Sun Jun 27 21:58:34 CEST 2010
+*           on Sun Jul 04 17:25:57 CEST 2010
 */
 
        \r
@@ -61,17 +61,17 @@ GEN_RESOURCE_HEAD {
 // ##############################    STACKS (TASKS)     ############################\r
 DECLARE_STACK(OsIdle,OS_OSIDLE_STACK_SIZE);\r
 DECLARE_STACK(btask_h_full,2048);\r
-DECLARE_STACK(btask_h_none,2048);\r
+DECLARE_STACK(btask_h_non,2048);\r
 DECLARE_STACK(btask_l_full,2048);\r
-DECLARE_STACK(btask_l_none,2048);\r
+DECLARE_STACK(btask_l_non,2048);\r
 DECLARE_STACK(btask_m_full,2048);\r
-DECLARE_STACK(btask_m_none,2048);\r
+DECLARE_STACK(btask_m_non,2048);\r
 DECLARE_STACK(etask_h_full,2048);\r
-DECLARE_STACK(etask_h_none,2048);\r
+DECLARE_STACK(etask_h_non,2048);\r
 DECLARE_STACK(etask_l_full,2048);\r
-DECLARE_STACK(etask_l_none,2048);\r
+DECLARE_STACK(etask_l_non,2048);\r
 DECLARE_STACK(etask_m_full,2048);\r
-DECLARE_STACK(etask_m_none,2048);\r
+DECLARE_STACK(etask_m_non,2048);\r
 DECLARE_STACK(etask_master,2048);\r
 \r
 // ##################################    TASKS     #################################\r
@@ -94,7 +94,7 @@ GEN_TASK_HEAD {
        ),\r
                                \r
        GEN_BTASK(\r
-               btask_h_none,\r
+               btask_h_non,\r
                4,\r
                NON,\r
                FALSE,\r
@@ -114,7 +114,7 @@ GEN_TASK_HEAD {
        ),\r
                                \r
        GEN_BTASK(\r
-               btask_l_none,\r
+               btask_l_non,\r
                2,\r
                NON,\r
                FALSE,\r
@@ -134,7 +134,7 @@ GEN_TASK_HEAD {
        ),\r
                                \r
        GEN_BTASK(\r
-               btask_m_none,\r
+               btask_m_non,\r
                3,\r
                NON,\r
                FALSE,\r
@@ -154,7 +154,7 @@ GEN_TASK_HEAD {
                \r
                                \r
        GEN_ETASK(\r
-               etask_h_none,\r
+               etask_h_non,\r
                4,\r
                NON,\r
                FALSE,\r
@@ -174,7 +174,7 @@ GEN_TASK_HEAD {
                \r
                                \r
        GEN_ETASK(\r
-               etask_l_none,\r
+               etask_l_non,\r
                2,\r
                NON,\r
                FALSE,\r
@@ -194,7 +194,7 @@ GEN_TASK_HEAD {
                \r
                                \r
        GEN_ETASK(\r
-               etask_m_none,\r
+               etask_m_non,\r
                3,\r
                NON,\r
                FALSE,\r
index 8c4ff2586f0ab5b9e02426426dc74dc6d000cc8e..8c8125dbdc19aa7aaf849d09313095be6ce6df0d 100644 (file)
@@ -9,7 +9,7 @@
 * 
 * 
 * Generated by Arctic Studio (http://arccore.com)
-*           on Sun Jun 27 21:58:34 CEST 2010
+*           on Sun Jul 04 17:25:57 CEST 2010
 */
 
 
@@ -32,7 +32,9 @@
 \r
 \r
 // Event masks\r
+#define EVENT_MASK_kill        8\r
 #define EVENT_MASK_master_notif        1\r
+#define EVENT_MASK_next        16\r
 #define EVENT_MASK_notif       2\r
 #define EVENT_MASK_test        4\r
 \r
 // Task Id's\r
 #define TASK_ID_OsIdle 0\r
 #define TASK_ID_btask_h_full   1\r
-#define TASK_ID_btask_h_none   2\r
+#define TASK_ID_btask_h_non    2\r
 #define TASK_ID_btask_l_full   3\r
-#define TASK_ID_btask_l_none   4\r
+#define TASK_ID_btask_l_non    4\r
 #define TASK_ID_btask_m_full   5\r
-#define TASK_ID_btask_m_none   6\r
+#define TASK_ID_btask_m_non    6\r
 #define TASK_ID_etask_h_full   7\r
-#define TASK_ID_etask_h_none   8\r
+#define TASK_ID_etask_h_non    8\r
 #define TASK_ID_etask_l_full   9\r
-#define TASK_ID_etask_l_none   10\r
+#define TASK_ID_etask_l_non    10\r
 #define TASK_ID_etask_m_full   11\r
-#define TASK_ID_etask_m_none   12\r
+#define TASK_ID_etask_m_non    12\r
 #define TASK_ID_etask_master   13\r
 \r
 // Task entry points\r
 void OsIdle( void );\r
 void btask_h_full( void );\r
-void btask_h_none( void );\r
+void btask_h_non( void );\r
 void btask_l_full( void );\r
-void btask_l_none( void );\r
+void btask_l_non( void );\r
 void btask_m_full( void );\r
-void btask_m_none( void );\r
+void btask_m_non( void );\r
 void etask_h_full( void );\r
-void etask_h_none( void );\r
+void etask_h_non( void );\r
 void etask_l_full( void );\r
-void etask_l_none( void );\r
+void etask_l_non( void );\r
 void etask_m_full( void );\r
-void etask_m_none( void );\r
+void etask_m_non( void );\r
 void etask_master( void );\r
 \r
 // Schedule table id's\r
@@ -86,7 +88,7 @@ void etask_master( void );
 #define OS_TASK_CNT                            14\r
 #define OS_SCHTBL_CNT                  0\r
 #define OS_COUNTER_CNT                 1\r
-#define OS_EVENTS_CNT                  3\r
+#define OS_EVENTS_CNT                  5\r
 #define OS_ISRS_CNT                            0\r
 #define OS_RESOURCE_CNT                        0\r
 #define OS_LINKED_RESOURCE_CNT 0\r
index 000ca0c73916c9321d26e7d996a244a1903c1392..30440cb1ab7e56d056c67ceb1300e57856b746d8 100644 (file)
               </SUB-CONTAINERS>\r
             </CONTAINER>\r
             <CONTAINER UUID="6b1bd06c-aa6c-4a3b-890f-7a6622039010">\r
-              <SHORT-NAME>etask_l_none</SHORT-NAME>\r
+              <SHORT-NAME>etask_l_non</SHORT-NAME>\r
               <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsTask</DEFINITION-REF>\r
               <PARAMETER-VALUES>\r
                 <INTEGER-VALUE>\r
               </PARAMETER-VALUES>\r
             </CONTAINER>\r
             <CONTAINER UUID="21591f45-043e-4d3f-9c91-fbb617d69350">\r
-              <SHORT-NAME>etask_m_none</SHORT-NAME>\r
+              <SHORT-NAME>etask_m_non</SHORT-NAME>\r
               <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsTask</DEFINITION-REF>\r
               <PARAMETER-VALUES>\r
                 <INTEGER-VALUE>\r
               </PARAMETER-VALUES>\r
             </CONTAINER>\r
             <CONTAINER UUID="d8a48b25-b6e2-4c30-9834-9f841effedfc">\r
-              <SHORT-NAME>etask_h_none</SHORT-NAME>\r
+              <SHORT-NAME>etask_h_non</SHORT-NAME>\r
               <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsTask</DEFINITION-REF>\r
               <PARAMETER-VALUES>\r
                 <INTEGER-VALUE>\r
               </PARAMETER-VALUES>\r
             </CONTAINER>\r
             <CONTAINER UUID="e7882a54-1553-411b-89da-b6bdab4a7b15">\r
-              <SHORT-NAME>btask_l_none</SHORT-NAME>\r
+              <SHORT-NAME>btask_l_non</SHORT-NAME>\r
               <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsTask</DEFINITION-REF>\r
               <PARAMETER-VALUES>\r
                 <INTEGER-VALUE>\r
               </PARAMETER-VALUES>\r
             </CONTAINER>\r
             <CONTAINER UUID="fee669e9-e94e-47d2-90bb-2bcf4f95215b">\r
-              <SHORT-NAME>btask_m_none</SHORT-NAME>\r
+              <SHORT-NAME>btask_m_non</SHORT-NAME>\r
               <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsTask</DEFINITION-REF>\r
               <PARAMETER-VALUES>\r
                 <INTEGER-VALUE>\r
               </PARAMETER-VALUES>\r
             </CONTAINER>\r
             <CONTAINER UUID="1427277d-b148-4faa-8b15-a9b732a756d0">\r
-              <SHORT-NAME>btask_h_none</SHORT-NAME>\r
+              <SHORT-NAME>btask_h_non</SHORT-NAME>\r
               <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsTask</DEFINITION-REF>\r
               <PARAMETER-VALUES>\r
                 <INTEGER-VALUE>\r
                 </INTEGER-VALUE>\r
               </PARAMETER-VALUES>\r
             </CONTAINER>\r
+            <CONTAINER UUID="47709c91-4cce-40dc-84d8-9918f984c206">\r
+              <SHORT-NAME>kill</SHORT-NAME>\r
+              <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsEvent</DEFINITION-REF>\r
+              <PARAMETER-VALUES>\r
+                <INTEGER-VALUE>\r
+                  <DEFINITION-REF DEST="INTEGER-PARAM-DEF">/ArcCore/Os/OsEvent/OsEventMask</DEFINITION-REF>\r
+                  <VALUE>8</VALUE>\r
+                </INTEGER-VALUE>\r
+              </PARAMETER-VALUES>\r
+            </CONTAINER>\r
+            <CONTAINER UUID="9e9f81cc-0b31-4c1b-a434-6da73d1980eb">\r
+              <SHORT-NAME>next</SHORT-NAME>\r
+              <DEFINITION-REF DEST="PARAM-CONF-CONTAINER-DEF">/ArcCore/Os/OsEvent</DEFINITION-REF>\r
+              <PARAMETER-VALUES>\r
+                <INTEGER-VALUE>\r
+                  <DEFINITION-REF DEST="INTEGER-PARAM-DEF">/ArcCore/Os/OsEvent/OsEventMask</DEFINITION-REF>\r
+                  <VALUE>16</VALUE>\r
+                </INTEGER-VALUE>\r
+              </PARAMETER-VALUES>\r
+            </CONTAINER>\r
           </CONTAINERS>\r
         </MODULE-CONFIGURATION>\r
       </ELEMENTS>\r
index 868012b3a9e08162aa0137cfe92517f2c53f2ba2..bd34d6015e1f1f51c1e3e849dfd7572a432714ef 100644 (file)
  * for more details.
  * -------------------------------- Arctic Core ------------------------------*/
 
+
+
 /* Tests
  *    Scheduling tests FULL/NONE using SetEvent(), ActivateTask() and ChainTask()
  *    TODO: ChainTask()
  *    TODO: Should we add the GetResource(RES_SCHEDULER) here also?
  *
  *    SetEvent()
- *      etask_m_full: SetEvent() to  etask_l_full, etask_h_full
- *      etask_m_full: SetEvent() to  etask_l_none, etask_h_none
- *      etask_m_none: SetEvent() to  etask_l_full, etask_h_full
- *      etask_m_none: SetEvent() to  etask_l_none, etask_h_none
+ *    1 etask_m_full: SetEvent() to  etask_l_full, etask_h_full
+ *    1 etask_m_full: SetEvent() to  etask_l_non, etask_h_non
+ *    4 etask_m_non: SetEvent() to  etask_l_full, etask_h_full
+ *    4 etask_m_non: SetEvent() to  etask_l_non, etask_h_non
  *
  *      btask_m_full: SetEvent() to  etask_l_full, etask_h_full
- *      btask_m_full: SetEvent() to  etask_l_none, etask_h_none
- *      btask_m_none: SetEvent() to  etask_l_full, etask_h_full
- *      btask_m_none: SetEvent() to  etask_l_none, etask_h_none
+ *      btask_m_full: SetEvent() to  etask_l_non, etask_h_non
+ *      btask_m_non: SetEvent() to  etask_l_full, etask_h_full
+ *      btask_m_non: SetEvent() to  etask_l_non, etask_h_non
  *
  *    ActivateTask()
- *      etask_m_full: ActivateTask() to  etask_l_full, etask_h_full
- *      etask_m_full: ActivateTask() to  etask_l_none, etask_h_none
- *      etask_m_none: ActivateTask() to  etask_l_full, etask_h_full
- *      etask_m_none: ActivateTask() to  etask_l_none, etask_h_none
+ *    2 etask_m_full: ActivateTask() to  etask_l_full, etask_h_full
+ *    2 etask_m_full: ActivateTask() to  etask_l_non, etask_h_non
+ *      etask_m_non: ActivateTask() to  etask_l_full, etask_h_full
+ *      etask_m_non: ActivateTask() to  etask_l_non, etask_h_non
  *
- *      etask_m_full: ActivateTask() to  btask_l_full, btask_h_full
- *      etask_m_full: ActivateTask() to  btask_l_none, btask_h_none
- *      etask_m_none: ActivateTask() to  btask_l_full, btask_h_full
- *      etask_m_none: ActivateTask() to  btask_l_none, btask_h_none
+ *    3 etask_m_full: ActivateTask() to  btask_l_full, btask_h_full
+ *    3 etask_m_full: ActivateTask() to  btask_l_non, btask_h_non
+ *      etask_m_non: ActivateTask() to  btask_l_full, btask_h_full
+ *      etask_m_non: ActivateTask() to  btask_l_non, btask_h_non
  *
  *      btask_m_full: ActivateTask() to  btask_l_full, etask_h_full
- *      btask_m_full: ActivateTask() to  btask_l_none, etask_h_none
- *      btask_m_none: ActivateTask() to  btask_l_full, etask_h_full
- *      btask_m_none: ActivateTask() to  btask_l_none, etask_h_none
+ *      btask_m_full: ActivateTask() to  btask_l_non, etask_h_non
+ *      btask_m_non: ActivateTask() to  btask_l_full, etask_h_full
+ *      btask_m_non: ActivateTask() to  btask_l_non, etask_h_non
  *
  *      btask_m_full: ActivateTask() to  btask_l_full, etask_h_full
- *      btask_m_full: ActivateTask() to  btask_l_none, etask_h_none
- *      btask_m_none: ActivateTask() to  btask_l_full, etask_h_full
- *      btask_m_none: ActivateTask() to  btask_l_none, etask_h_none
+ *      btask_m_full: ActivateTask() to  btask_l_non, etask_h_non
+ *      btask_m_non: ActivateTask() to  btask_l_full, etask_h_full
+ *      btask_m_non: ActivateTask() to  btask_l_non, etask_h_non
  */
 
 #include <stdlib.h>\r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "Mcu.h"\r
 #if defined(USE_GPT)\r
 #include "Gpt.h"\r
 //#define USE_LDEBUG_PRINTF\r
 #include "debug.h"
 #include "arc.h"\r
-#include "test_framework.h"
 \r
 \r
 #define ERROR_LOG_SIZE 1
 
+#define NOT_EXPECTED   0
+#define EXPECTED               1
+#define TASK_BASIC             0
+#define TASK_EXT               1
+
+
+
 typedef struct ErrorEntry {
        StatusType              error;
        OsErrorType     info;
@@ -83,6 +91,75 @@ typedef struct ErrorLog {
 
 ErrorLogType ErrorLog;
 
+#define MAKE_TEST(_x)          TEST_ ## (_x)
+#define TEST_INC()                     test_nr++
+//#define TEST_START2()                printf("%s\n",TestFixure[test_nr-1].description)
+#define TEST_START2()          TestStart(TestFixure[test_nr-1].description, TestFixure[test_nr-1].nr );
+#define TEST_GETCASE()         TestFixure[test_nr-1].nr
+
+
+enum testCase {
+       TEST_1 = 1,
+       TEST_2,
+       TEST_3,
+       TEST_4,
+       TEST_5,
+       TEST_6,
+       TEST_7,
+       TEST_8,
+       TEST_9,
+       TEST_10,
+       TEST_11,
+       TEST_12,
+       TEST_13,
+       TEST_14,
+       TEST_15,
+       TEST_16,
+       TEST_17,
+       TEST_18,
+       TEST_19,
+       TEST_20,
+       TEST_LAST,
+};
+
+
+
+static TestFixtureType TestFixure[] = {
+/* 0 */
+               {"SetEvent()/E/FULL to self",TEST_1},
+               {"ActivateTask()/E/FULL to self",TEST_2},
+
+/* 1 */
+               {"SetEvent()/E/FULL to E/Lo/FULL",TEST_3},
+               {"SetEvent()/E/FULL to E/Hi/FULL",TEST_4},
+               {"SetEvent()/E/FULL to E/Lo/NON",TEST_5},
+               {"SetEvent()/E/FULL to E/Hi/NON",TEST_6},
+
+/* 2 */
+               {"ActivateTask()/E/FULL to E/Lo/FULL",TEST_7},
+               {"ActivateTask()/E/FULL to E/Hi/FULL",TEST_8},
+               {"ActivateTask()/E/FULL to E/Lo/NON",TEST_9},
+               {"ActivateTask()/E/FULL to E/Hi/NON",TEST_10},
+
+/* 3 */
+               {"ActivateTask()/E/FULL to B/Lo/FULL",TEST_11},
+               {"ActivateTask()/E/FULL to B/Hi/FULL",TEST_12},
+               {"ActivateTask()/E/FULL to B/Lo/NON",TEST_13},
+               {"ActivateTask()/E/FULL to B/Hi/NON",TEST_14},
+
+               {"SetEvent()/E/NON to self",TEST_15},
+               {"ActivateTask()/E/NON to self",TEST_16},
+
+/* 4 */
+               {"SetEvent()/E/NON to E/Lo/FULL",TEST_17},
+               {"SetEvent()/E/NON to E/Hi/FULL",TEST_18},
+               {"SetEvent()/E/NON to E/Lo/NON",TEST_19},
+               {"SetEvent()/E/NON to E/Hi/NON",TEST_20},
+
+               {"",TEST_LAST},
+};
+
+
 ErrorEntryType *errorLogGetEntry( int backlog ) {
 
 
@@ -95,6 +172,7 @@ ErrorEntryType *errorLogGetEntry( int backlog ) {
 }
 
 
+
 void validateErrorHook(int backlog, int error, int serviceId,
                                                        uint32_t param1, uint32_t param2, uint32_t param3,
                                                        int apiId, int modId ) {
@@ -126,6 +204,9 @@ do {                                                                                                                                        \
                TEST_ASSERT(_param3 == entry->info.param3 );                            \
        }                                                                                                                               \
 } while(0)
+
+
+
 \r
 /*\r
  * Master test process, everything is controlled from here.\r
@@ -134,10 +215,24 @@ void etask_master( void ) {
        TEST_INIT();
        test_nr = 1;
 
+       /* Activate ext. task "slaves" */
+       ActivateTask(TASK_ID_etask_l_full);
+       ActivateTask(TASK_ID_etask_h_full);
+       ActivateTask(TASK_ID_etask_l_non);
+       ActivateTask(TASK_ID_etask_h_non);
+
+       /* Do the m_full -> XX tests first */
        ActivateTask(TASK_ID_etask_m_full);
-       ActivateTask(TASK_ID_etask_m_none);
 
-       testExit(0);
+       /* Do the next test */
+       WaitEvent(EVENT_MASK_next);
+       ClearEvent(EVENT_MASK_next);
+
+       /* Do the m_non -> XX  */
+       ActivateTask(TASK_ID_etask_m_non);
+
+
+       TestExit(0);
 }\r
 
 //--------------------------------------------------------------------\r
@@ -148,7 +243,7 @@ void btask_h_full( void ) {
        TerminateTask();
 }
 
-void btask_h_none( void ) {
+void btask_h_non( void ) {
 
        TerminateTask();
 }
@@ -158,7 +253,7 @@ void btask_l_full( void ) {
        TerminateTask();
 }
 
-void btask_l_none( void ) {
+void btask_l_non( void ) {
 
        TerminateTask();
 }
@@ -168,21 +263,33 @@ void btask_m_full( void ) {
        TerminateTask();
 }
 
-void btask_m_none( void ) {
+void btask_m_non( void ) {
 
        TerminateTask();
 }
 
+
+static void waitKillAndTest( void ) {
+       TaskType currTask;
+       EventMaskType mask;
+       GetTaskID(&currTask);
+
+       WaitEvent( EVENT_MASK_test | EVENT_MASK_kill);
+       GetEvent(currTask,&mask);
+       if( EVENT_MASK_kill & mask ) {
+               TerminateTask();
+       }
+       ClearEvent(EVENT_MASK_test);
+}
+
 void etask_h_full( void ) {
        for(;;) {
-               WaitEvent(EVENT_MASK_test);
-               ClearEvent(EVENT_MASK_test);
+               waitKillAndTest();
                switch(test_nr) {
-               case 2:
+               case TEST_4:
+               case TEST_8:
                        SetEvent(TASK_ID_etask_m_full,EVENT_MASK_test);
                        break;
-               case 100:
-                       TerminateTask();
                default:
                        TEST_ASSERT(0);
                        break;
@@ -191,22 +298,45 @@ void etask_h_full( void ) {
        }
 }
 
-void etask_h_none( void ) {
-
-
+void etask_h_non( void ) {
+       for(;;) {
+               waitKillAndTest();
+               switch(test_nr) {
+               case TEST_6:
+               case TEST_9:
+                       SetEvent(TASK_ID_etask_m_full,EVENT_MASK_test);
+                       break;
+               default:
+                       TEST_ASSERT(0);
+                       break;
+               }
+       }
 }
 
 void etask_l_full( void ) {
        for(;;) {
-               WaitEvent(EVENT_MASK_test);
-               ClearEvent(EVENT_MASK_test);
+               waitKillAndTest();
+               switch(test_nr) {
+               case TEST_3:
+               case TEST_7:
+                       SetEvent(TASK_ID_etask_m_full,EVENT_MASK_test);
+                       break;
+               default:
+                       TEST_ASSERT(0);
+                       break;
+               }
+
+       }
+}
 
+void etask_l_non( void ) {
+       for(;;) {
+               waitKillAndTest();
                switch(test_nr) {
-               case 1:
+               case TEST_5:
+               case TEST_9:
                        SetEvent(TASK_ID_etask_m_full,EVENT_MASK_test);
                        break;
-               case 100:
-                       TerminateTask();
                default:
                        TEST_ASSERT(0);
                        break;
@@ -215,61 +345,160 @@ void etask_l_full( void ) {
        }
 }
 
-void etask_l_none( void ) {
 
+static void taskDispatchCheck( TaskType task,_Bool expected, _Bool etask ) {
+       EventMaskType mask;
+       StatusType rv;
+       TaskType currTask;
+       TaskStateType taskState;
+
+       GetTaskID(&currTask);
+
+       /* 1. Kill the task */
+       TEST_ASSERT(taskState == TASK_STATE_WAITING);
+       rv = SetEvent(task,EVENT_MASK_kill);
+       TEST_ASSERT( rv == E_OK );
+
+       /* 2. Grab task state */
+       GetTaskState(task, &taskState);
+       TEST_ASSERT(taskState == TASK_STATE_SUSPENDED);
+
+       /* 3. Activate */
+       ActivateTask(task);
+
+       GetEvent(currTask,&mask);
+       if( expected ) {
+               TEST_ASSERT( mask & EVENT_MASK_test );
+       } else {
+               TEST_ASSERT( (mask & EVENT_MASK_test) == 0 );
+       }
+
+       /* Let task task run */
+       WaitEvent(EVENT_MASK_test);
+       ClearEvent(EVENT_MASK_test);
+}
+
+
+static void eventExpectNoDispatch( TaskType task ) {
+       EventMaskType mask;
+       StatusType rv;
+       /** req OS?? */
+       rv = GetEvent(task,&mask);
+       TEST_ASSERT(rv == E_OK);
+       TEST_ASSERT( !(mask & EVENT_MASK_test) );
+       /* After SetEvent(), NO dispatch */
+       SetEvent(task, EVENT_MASK_test);
+       GetEvent(task,&mask);
+       TEST_ASSERT( mask & EVENT_MASK_test );
+
+       /* Let the Low prio task run */
+       WaitEvent(EVENT_MASK_test);
+       ClearEvent(EVENT_MASK_test);
+}
 
+static void eventExpectDispatch( TaskType task ) {
+       EventMaskType mask;
+       StatusType rv;
+       /** req OS?? */
+       rv = GetEvent(task,&mask);
+       TEST_ASSERT(rv == E_OK);
+       TEST_ASSERT( !(mask & EVENT_MASK_test) );
+       /* After SetEvent(), dispatch */
+       SetEvent(task, EVENT_MASK_test);
+       GetEvent(task,&mask);
+       TEST_ASSERT( !(mask & EVENT_MASK_test) );
 }
 
+
+
 void etask_m_full( void ) {
+       StatusType      rv;
+       TaskType task;
        EventMaskType mask;
+       static int m_full_starts = 0;
+       _Bool kill = 0;
 
-       ActivateTask(TASK_ID_etask_l_full);
-       ActivateTask(TASK_ID_etask_h_full);
+       (void)rv;
+       m_full_starts++;
+       GetTaskID(&task);
 
        for(;;) {
-               switch(test_nr) {
-               case 1:
-                       TEST_START("SetEvent() to low",test_nr);
-                       /** req OS?? */
-                       GetEvent(TASK_ID_etask_l_full,&mask);
-                       TEST_ASSERT( !(mask & EVENT_MASK_test) );
-                       /* After SetEvent(), NO dispatch */
-                       SetEvent(TASK_ID_etask_l_full, EVENT_MASK_test);
-                       GetEvent(TASK_ID_etask_l_full,&mask);
-                       TEST_ASSERT( mask & EVENT_MASK_test )
-
-                       /* Let the Low prio task run */
-                       WaitEvent(EVENT_MASK_test);
+               if( kill == 1) {
+                       /* Kill tasks */
+#if 0
+                       SetEvent(TASK_ID_etask_l_full, EVENT_MASK_kill);
+                       SetEvent(TASK_ID_etask_h_full, EVENT_MASK_kill);
+                       SetEvent(TASK_ID_etask_l_non, EVENT_MASK_kill);
+                       SetEvent(TASK_ID_etask_h_non, EVENT_MASK_kill);
+#endif
+                       SetEvent(TASK_ID_etask_master, EVENT_MASK_next);
+                       TerminateTask();
+               }
+
+               TEST_START2();
+               switch(TEST_GETCASE()) {
+               case TEST_1:
+                       GetTaskID(&task);
+                       GetEvent(task,&mask);
+                       TEST_ASSERT( (mask & EVENT_MASK_test) == 0 );
+                       TEST_ASSERT( m_full_starts == 1 );
+                       SetEvent(task,EVENT_MASK_test);
+                       GetEvent(task,&mask);
+                       TEST_ASSERT( (mask & EVENT_MASK_test) );
+                       TEST_ASSERT( m_full_starts == 1 );
                        ClearEvent(EVENT_MASK_test);
-                       TEST_END();
-                       test_nr++;
                        break;
-               case 2:
-                       TEST_START("SetEvent() to high",test_nr);
-                       /** req OS?? */
-                       GetEvent(TASK_ID_etask_h_full,&mask);
-                       TEST_ASSERT( !(mask & EVENT_MASK_test) );
-                       /* After SetEvent(), dispatch */
-                       SetEvent(TASK_ID_etask_h_full, EVENT_MASK_test);
-                       GetEvent(TASK_ID_etask_h_full,&mask);
-                       TEST_ASSERT( !(mask & EVENT_MASK_test) );
-                       TEST_END();
-                       test_nr = 100;
+               case TEST_2:
+                       rv = ActivateTask(task);
+                       TEST_ASSERT( rv == E_OS_LIMIT);
+                       break;
+               case TEST_3:
+                       eventExpectNoDispatch(TASK_ID_etask_l_full);
+                       break;
+               case TEST_4:
+                       eventExpectDispatch(TASK_ID_etask_h_full);
+                       break;
+               case TEST_5:
+                       eventExpectNoDispatch(TASK_ID_etask_l_non);
+                       break;
+               case TEST_6:
+                       eventExpectDispatch(TASK_ID_etask_h_non);
+                       break;
+               case TEST_7:
+                       taskDispatchCheck(TASK_ID_etask_l_full, EXPECTED, TASK_EXT );
+                       break;
+               case TEST_8:
+                       taskDispatchCheck(TASK_ID_etask_h_full, NOT_EXPECTED, TASK_EXT );
+                       break;
+               case TEST_9:
+                       taskDispatchCheck(TASK_ID_etask_l_non, EXPECTED, TASK_EXT );
+                       break;
+               case TEST_10:
+                       taskDispatchCheck(TASK_ID_etask_h_full, NOT_EXPECTED, TASK_EXT );
+                       break;
+               case TEST_11:
+                       taskDispatchCheck(TASK_ID_btask_l_full, EXPECTED, TASK_BASIC );
+                       break;
+               case TEST_12:
+                       taskDispatchCheck(TASK_ID_btask_h_full, NOT_EXPECTED, TASK_BASIC );
+                       break;
+               case TEST_13:
+                       taskDispatchCheck(TASK_ID_btask_l_non, EXPECTED, TASK_BASIC );
+                       break;
+               case TEST_14:
+                       taskDispatchCheck(TASK_ID_btask_h_full, NOT_EXPECTED, TASK_BASIC );
+                       kill = 1;
                        break;
-               case 100:
-                       /* Kill tasks */
-                       SetEvent(TASK_ID_etask_l_full, EVENT_MASK_test);
-                       SetEvent(TASK_ID_etask_h_full, EVENT_MASK_test);
-                       TerminateTask();
                default:
                        TEST_ASSERT(0);
                        break;
                }
-
+               TEST_END();
+               TEST_INC();
        }
 }
 
-void etask_m_none( void ) {
+void etask_m_non( void ) {
 
 
 }
index ce87d76e9c818fd643b93e89c91de9adbb94c8ca..3e8210541dddf26553a0f5d1cdbdaed623fb786e 100644 (file)
@@ -32,7 +32,7 @@
  */\r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 \r
 int btaskRunCnt = 0;\r
index 5d7988ec9d414e777a6a9b79e6933480c7a190a1..d4aa38f5e9aa0e804a7c69177866f2aabe8e4192 100644 (file)
@@ -32,7 +32,7 @@
  */\r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 #include "irq.h"\r
 \r
index b7c0dce8d865f1826171da74dc867095c568bb87..2267684e91a50e7fd859c1c9b955d9eb6ae390ee 100644 (file)
@@ -35,7 +35,7 @@
 \r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 \r
 \r
index 5a3a59e8f6051d660959f0b26701a46eb9df5460..f5001420cb613c132964ec266a4dca3cf49b83be 100644 (file)
@@ -35,7 +35,7 @@
  */\r
 \r
 #include "Os.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "arc.h"\r
 \r
 \r
index 008f4c64e16563163d5a3b31429cfbf109ddb7a7..b3dbd23035cbcfa430f8c23a11d37e1210a4f493 100644 (file)
  *   but it should go away (suite_01)
  * - Hooks and error handling should be unitfied into one file.
  * - That test-cases is dependent on the former testcase to increase "test_nr"
+ * - Should be able to see what tests are not run?!
+ *
+ *
+ * Total tests:   150
+ * Not run:       5    (not touched by assert)
+ * Failures:      10
+ * Success:       135
+ * Not Implented: 0
+ *
+ * Next:
+ * 1. Fix statistics
+ * 2. Cleanup of testCnt and other "indexes"
+ * 3. Fix statistics over severaral test_suites. (move to NOLOAD section)
  *
  */
 
@@ -57,6 +70,12 @@ int _test_failed = 0;
 int testCnt = 0;
 
 
+struct testStats {
+       int ok;
+       int fail;
+       int notRun;
+       int notImplemented;
+};
 
 struct test {
        uint8_t testSuite;
@@ -69,11 +88,11 @@ struct test {
 struct test testTable[50] = { {0} };
 
 
-void testInit( void ) {
+void TestInit( void ) {
 
 }
 \r
-void test_done( void ) {\r
+void TestDone( void ) {\r
        printf( "\nTest summary\n"\r
                                "Total: %d\n"\r
                                "OK   : %d\n"\r
@@ -88,11 +107,11 @@ void test_done( void ) {
  * @param line
  * @param function
  */\r
-void test_fail( const char *text,char *file,  int line, const char *function ) {\r
+void TestFail( const char *text,char *file,  int line, const char *function ) {\r
        printf("%02d %02d FAILED, %s , %d, %s\n",test_suite, test_nr, file, line, function);\r
        testTable[testCnt].testSuite = test_suite;
        testTable[testCnt].testNr = test_nr;
-       testTable[testCnt].status = TEST_FLG_ASSERT;
+       testTable[testCnt].status |= TEST_FLG_ASSERT;
 //     testCnt++;
 //     _test_failed++;\r
 }\r
@@ -110,33 +129,39 @@ void testSetErrorMask( uint32_t errMask ) {
 void testValidateHook( void ) {
 
 }
+
 /**
  * Start a test
  */
-void testStart( const char *str, int testNr ) {
+void TestStart( const char *str, int testNr ) {
        testTable[testCnt].status = TEST_FLG_RUNNING;
        testTable[testCnt].testNr = testNr;
        testTable[testCnt].description = str;
        printf("%3d %3d %s\n",testCnt,testNr,str);
 }
 
-void testInc( void ) {
+void TestInc( void ) {
        testCnt++;
 }
 
 /**
  * End a testcase.
  */
-void testEnd( void ) {
+void TestEnd( void ) {
        uint16_t status = testTable[testCnt].status;
 
-       if( status & TEST_FLG_RUNNING ) {
+       if( status & TEST_FLG_NOT_IMPLEMENTED ) {
+               printf("Not Implemented\n");
+       } else  if( (status & TEST_FLG_TOUCHED) == 0 ) {
+               printf("NOT touched\n");
+       } else  if( status & TEST_FLG_RUNNING ) {
                if( status & TEST_FLG_ASSERT ) {
 
                } else {
                        /* All is OK */
                        testTable[testCnt].status &= TEST_FLG_RUNNING;
                        testTable[testCnt].status |= TEST_FLG_OK;
+                       printf("OK\n");
                }
        } else {
                printf("testEnd() on a test that is not running\n");
@@ -144,13 +169,21 @@ void testEnd( void ) {
        testCnt++;
 }
 
-void testExit( int rv ) {
+void TestExit( int rv ) {
        Irq_Disable();
        exit(rv);
 }
 
+void TestTouch( void ) {
+       testTable[testCnt].status |= TEST_FLG_TOUCHED;
+}
+
+void TestNotImplemented( void ) {
+       testTable[testCnt].status |= TEST_FLG_NOT_IMPLEMENTED;
+}
+
 \r
-void test_ok( void ) {\r
+void TestOk( void ) {\r
        printf("%02d %02d OK\n",test_suite, test_nr);
        testTable[testCnt].testSuite = test_suite;
        testTable[testCnt].testNr = test_nr;
index c0a5050f2815b68c96672a82700ae3a07cacdb0d..94f2913b3a9d76f248e515b1012dbe1447af8ee6 100644 (file)
 #define TEST_FRAMEWORK_H_\r
 
 /* Test flags */
-#define TEST_FLG_RUNNING               1
-#define TEST_FLG_ASSERT                (1<<1)
-#define TEST_FLG_DONE                  (1<<2)
-#define TEST_FLG_OK                    (1<<3)
+#define TEST_FLG_RUNNING                       1
+#define TEST_FLG_ASSERT                        (1<<1)
+#define TEST_FLG_DONE                          (1<<2)
+#define TEST_FLG_OK                            (1<<3)
+#define TEST_FLG_NOT_IMPLEMENTED       (1<<4)
+#define TEST_FLG_TOUCHED                       (1<<5)
 
-#define TEST_VALUE_NC                  (-1)\r
-void test_done( void );\r
+#define TEST_VALUE_NC                  (-1)
+
+#define TASK_ID_ILL                    99
+#define RES_ID_ILL                             99
+#define ALARM_ID_ILL                   99
+#define SCHTBL_ID_ILL  99
+#define COUNTER_ID_ILL                 99
+
+
+
+#define TEST_INIT()                    printf("Test init\n");
+#define TEST_FAIL(_text)               TestFail((_text),  __FILE__,  __LINE__, __FUNCTION__ )
+#define TEST_OK()                              TestOk();
+#define TEST_ASSERT(_cond)     TestTouch(); \
+                                                               if(!(_cond)) { \
+                                                                       TEST_FAIL(#_cond); \
+                                                               }
+
+/* Start to run a test */
+#define TEST_RUN()                             printf("Running test %d\n",test_nr);
+/* Indicate that a test is done */
+//#define TEST_DONE()
+#define TEST_START(_str,_nr)           TestStart(_str,_nr)
+#define TEST_NEXT(_str,_next_nr)       TestEnd(); TestStart(_str,_next_nr);
+#define TEST_END()                                     TestEnd()
+#define TEST_NOT_IMPLEMENTED()         TestNotImplemented();
+
+typedef struct TestFixture {
+       const char *description;
+       int nr;
+} TestFixtureType;
 \r
-void test_fail( const char *text,char *file,  int line, const char *function );\r
-void test_ok( void );\r
+void TestDone( void );\r
+\r
+void TestFail( const char *text,char *file,  int line, const char *function );\r
+void TestOk( void );
+void TestTouch( void );\r
+
+void TestStart( const char *str, int testNr );
+void TestInc( void );
+void TestEnd( void );
+void TestExit( int rv );
+
+
+typedef void (*test_func_t)( void );
+
+extern int test_suite;
+extern int test_nr;
+
+
+
+#if 1
+#define SECTION_SUP
+#define SECTION_USER
+#else
+#define SECTION_SUP                    __attribute__ ((section(".text_app_sup")))
+#define SECTION_USER           __attribute__ ((section(".text_app_user")))
+#endif
+
+#define SECTION_BSS_SUPER      __attribute__ ((aligned (16),section(".bss")))
+#define SECTION_BSS_USER       __attribute__ ((aligned (16),section(".bss")))
+
+#define OS_STR__(x)            #x
+#define OS_STRSTR__(x)         OS_STR__(x)
+
+#define DECLARE_TEST_BTASK(_nr, _task1, _task2, _task3 ) \
+               __attribute__ ((section (".test_btask"))) const test_func_t btask_sup_matrix_ ## _nr[3] = { _task1, _task2, _task3 }
+
+#define DECLARE_TEST_ETASK(_nr, _task1, _task2, _task3 ) \
+               __attribute__ ((section (".test_etask"))) const test_func_t etask_sup_matrix_ ## _nr[3]  = { _task1, _task2, _task3 }
+
+#define DECLARE_TASKS(_nr) \
+       void etask_sup_l_##_nr( void ); \
+       void etask_sup_m_##_nr( void ); \
+       void etask_sup_h_##_nr( void ); \
+       void btask_sup_l_##_nr( void ); \
+       void btask_sup_m_##_nr( void ); \
+       void btask_sup_h_##_nr( void );
+
+
+/*
+ * Declare tests
+ */
+
+// Test master processes
+void OsIdle(void );
+void etask_master( void );
+void etask_sup_l( void ) SECTION_SUP;
+void etask_sup_m( void ) SECTION_SUP;
+void etask_sup_h( void ) SECTION_SUP;
+
+void btask_sup_l( void ) SECTION_SUP;
+void btask_sup_m( void ) SECTION_SUP;
+void btask_sup_h( void ) SECTION_SUP;
+
 
-void testStart( const char *str, int testNr );
-void testInc( void );
-void testEnd( void );
-void testExit( int rv );
+// Tests
+DECLARE_TASKS(01);
+DECLARE_TASKS(02);
+DECLARE_TASKS(03);
+DECLARE_TASKS(04);
 \r
 #endif /* TEST_FRAMEWORK_H_ */\r
index f88f8298627d98e44ae936e16a5822071a4a7eaf..4e39bb605bf408986ecfcb70468961ef5d2477a4 100644 (file)
@@ -20,7 +20,7 @@
 //#include "Platform_Types.h"\r
 #include "Os.h"\r
 #include "debug.h"\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 //#include "test_cfg.h"\r
 \r
 #define EVENT_NR       1\r
index e8d6c9fd1f26ac3ed366f78a642cd83fba2cdc6a..db56cfbfc91df69e831c6e128ea11b05065399f2 100644 (file)
@@ -24,7 +24,7 @@
 #include "Os.h"\r
 #include "debug.h"\r
 #include <assert.h>\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 \r
 \r
 void etask_sup_l_02( void ) {\r
index 40c5b9c515bbfe1b853e08148f132f5d73bffbc3..87666473c76d7c279ac025b405828136f6b3b005 100644 (file)
@@ -28,7 +28,7 @@
 #include "debug.h"
 //#include <stdio.h>
 #include <assert.h>
-#include "os_test.h"
+#include "test_framework.h"
 
 
 //static int test = 1;
index c6978cbcd59af65538b5652c4c612b575e657751..cbaee212e718d1dad74e4272ad6c8ee8de844fbf 100644 (file)
@@ -26,7 +26,7 @@
 #include "debug.h"\r
 //#include <stdio.h>\r
 #include <assert.h>\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "irq.h"\r
 \r
 #if 0\r
index be5c4c023899d29730c58fa4a1cdaf7bdc91ad74..44552200c60d19c74f7dd106306731d275140ed3 100644 (file)
@@ -26,7 +26,7 @@
 #include "debug.h"\r
 //#include <stdio.h>\r
 #include <assert.h>\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "irq.h"\r
 \r
 #if 0\r
index 63506eb85d71ae7720e5082914723968cf61dd28..4353e675349b15c24935c81fb3f0c7adbe37eae8 100644 (file)
@@ -21,7 +21,7 @@
 #include "debug.h"\r
 //#include <stdio.h>\r
 #include <assert.h>\r
-#include "os_test.h"\r
+#include "test_framework.h"\r
 #include "irq.h"\r
 \r
 void isr_l(void ) {\r