Changes between Version 1 and Version 2 of GSoC/2013/Testing


Ignore:
Timestamp:
06/07/14 14:25:09 (10 years ago)
Author:
Marcinbujar
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • GSoC/2013/Testing

    v1 v2  
    11= RTEMSTestingSOCIS2013 =
    22
    3 
    4 Project description and results from ESA Summer of Code in Space 2013 coming soon.
     3=  Project Outline  =
     4
     5
     6This document outlines the process of integrating a unit testing tool called [https://github.com/ThrowTheSwitch/Unity Unity] with a new RTEMS test suite currently under development. This project was carried out during the [http://sophia.estec.esa.int/socis2013 ESA Summer of Code 2013].
     7=  Unity  =
     8
     9 *  unity.c: implementation
     10 *  unity.h: function and macro definitions
     11 *  unity internals.h: internal definitions
     12=  Integration  =
     13
     14Unity has been modified to work with the new RTEMS testsuite. All developed code can be found [https://github.com/marcinbujar/Unity here]. It will soon be merged to Unity.
     15=  JSON Test Output  =
     16
     17
     18An option has been added to output the test results in JSON format.
     19
     20Test with normal output:
     21
     22 main.c:39:test_rtems_tick_announce:IGNORE: TODO
     23 main.c:44:test_rtems_clock_set:PASS
     24 main.c:57:test_rtems_clock_get:PASS
     25 main.c:113:test_rtems_clock_maintain:IGNORE: TODO
     26 -----------------------
     27 4 Tests 0 Failures 2 Ignored
     28 OK
     29
     30Test result with JSON output
     31
     32 {
     33 "tests": [
     34  {
     35   "test_rtems_tick_announce": {
     36    "linenumber": 39,
     37    "file": "main.c",
     38    "result": "IGNORE",
     39    "message": "TODO"
     40   }
     41  },
     42  {
     43   "test_rtems_clock_set": {
     44    "linenumber": 44,
     45    "file": "main.c",
     46    "result": "PASS"
     47   }
     48  },
     49  {
     50   "test_rtems_clock_get": {
     51    "linenumber": 57,
     52    "file": "main.c",
     53    "result": "PASS"
     54   }
     55  },
     56  {
     57   "test_rtems_clock_maintain": {
     58    "linenumber": 113,
     59    "file": "main.c",
     60    "result": "IGNORE",
     61    "message": "TODO"
     62   }
     63  },
     64  {}
     65 ],
     66 "summary": {
     67  "tests": 4,
     68  "failed": 0,
     69  "ignored": 2
     70  }
     71 }
     72
     73=  Source  =
     74
     75
     76 *  unity.c: testsuite/librtemstest/unity.c
     77 *  unity.h: testsuite/include/unity.h
     78 *  unity_internals.h: testsuite/include/unity_internals.h
     79
     80=  Testsuite Organisation  =
     81
     82=  Unity  =
     83
     84
     85 *  include - Headers
     86 *  librtemstest - Unity and utilities
     87=  Test Directories  =
     88
     89
     90 *  general - General Areas
     91 *  deviceio - Device IO
     92 *  filesystems - File Systems
     93 *  memory - Memory Management
     94 *  network - Network
     95 *  tasks - Tasks Management
     96 *  timing - Timing Tests
     97
     98
     99=  Example Test  =
     100
     101
     102 /*
     103 *  COPYRIGHT (c) 1989-2011.
     104 *  On-Line Applications Research Corporation (OAR).
     105 *
     106 *  The license and distribution terms for this file may be
     107 *  found in the file LICENSE in this distribution or at
     108 *  http://www.rtems.com/license/LICENSE.
     109 */
     110 
     111 /* RTEMS Clock Tests
     112 * based on sp1, spclockget
     113 */
     114 
     115 #ifdef HAVE_CONFIG_H
     116 #include "config.h"
     117 #endif
     118 
     119 #include <rtems/testsuite.h>
     120 #include <rtems/tmacros.h>
     121 #include <rtems/pritime.h>
     122 
     123 void setUp(void)
     124 {
     125 }
     126 
     127 void tearDown(void)
     128 {
     129 }
     130 
     131 /* Announce a tick */
     132 void test_rtems_tick_announce(void)
     133 {
     134   TEST_IGNORE_MESSAGE( "TODO" );
     135 }
     136 
     137 /* Set clock */
     138 void test_rtems_clock_set(){
     139   rtems_status_code status;
     140   rtems_time_of_day time;
     141   rtems_id          id;
     142 
     143   build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
     144   status = rtems_clock_set( &time );
     145   TEST_ASSERT_EQUAL( status, RTEMS_SUCCESSFUL );
     146 }
     147 
     148 /* Get clock */
     149 void test_rtems_clock_get()
     150 {
     151   rtems_status_code status;
     152   rtems_time_of_day time;
     153   rtems_interval    interval;
     154   struct timeval    timev;
     155 
     156   /* NULL parameter */
     157   status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, NULL );
     158   TEST_ASSERT_EQUAL_MESSAGE( status, RTEMS_INVALID_ADDRESS, "null pointer" );
     159 
     160   /* ... */
     161 }
     162 
     163 /* Maintain clock */
     164 void test_rtems_clock_maintain(void)
     165 {
     166   TEST_IGNORE_MESSAGE( "TODO" );
     167 }
     168 
     169 /* Main test runner */
     170 rtems_task Init(rtems_task_argument argument)
     171 {
     172   /* The lines below should be generated automatically instead */
     173   Unity.TestFile = "main.c";
     174   UnityBegin();
     175   RUN_TEST( test_rtems_tick_announce, 36 );
     176   RUN_TEST( test_rtems_clock_set, 44 );
     177   RUN_TEST( test_rtems_clock_get, 57 );
     178   RUN_TEST( test_rtems_clock_maintain, 110 );
     179   UnityEnd();
     180 
     181   exit( 0 );
     182 }
     183 
     184 /* Configuration */
     185 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     186 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     187 
     188 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     189 #define CONFIGURE_MAXIMUM_TASKS             1
     190 
     191 #define CONFIGURE_INIT
     192 #include <rtems/confdefs.h>
     193
     194=  Automated Test Runner  =
     195
     196
     197An option was added to automatically generate code for the Init task which executes all the tests. An existing Ruby script in Unity for this task (generate_test_runner.rb) has been modified to work with RTEMS.
     198
     199An example runner.c generated by the script:
     200
     201
     202 /* AUTOGENERATED FILE. DO NOT EDIT. */
     203 
     204 //=======External Functions This Runner Calls=====
     205
     206 extern void setUp(void);
     207 extern void tearDown(void);
     208 extern void test_rtems_tick_announce(void);
     209 extern void test_rtems_clock_set();
     210 extern void test_rtems_clock_get();
     211 extern void test_rtems_clock_maintain(void);
     212 
     213 //=======Test Reset Option=====
     214
     215 void resetTest()
     216 {
     217   tearDown();
     218   setUp();
     219 }
     220 
     221 //=======MAIN=====
     222
     223 rtems_task Init(rtems_task_argument argument)
     224 {
     225   Unity.TestFile = "general/clock/main.c";
     226   UnityBegin();
     227   RUN_TEST(test_rtems_tick_announce, 37);
     228   RUN_TEST(test_rtems_clock_set, 45);
     229   RUN_TEST(test_rtems_clock_get, 58);
     230   RUN_TEST(test_rtems_clock_maintain, 111);
     231 
     232   UnityEnd();
     233 }
     234
     235
     236Once compiled, it is linked with the test binary and can be executed.