<div dir="ltr"><div><div><div><div><div><div>Hi,<br><br></div>Please take a look at following snippet:<br><br>testcase_executer.cpp:<br>1.  #include "___TC_abs_1.h"<br>2. <br>3.  void ___run_tc_abs_1 ()<br>4.  {<br>5.    rtems_id tc_task_id;<br>6.    rtems_name tc_task_name = rtems_build_name( 'T', 'C', ' ', ' ');<br>7.    rtems_task_create(<br>8.    tc_task_name, TC_TASK_PRIORITY, RTEMS_MINIMUM_STACK_SIZE,<br>9.      RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &tc_task_id);<br>10.<br>11.   rtems_task_start (tc_task_id, ___TC_abs_1, 0);<br>12.<br>13.   for (int i=0; i<TC_TIMEOUT_DIVISION_FACTOR; i++) {<br>14.     status = rtems_task_wake_after(RTEMS_MICROSECONDS_TO_TICKS(<br>15.       TC_TIMEOUT/TC_TIMEOUT_DIVISION_FACTOR));<br>16.     if (tc_finished)<br>17.       break;<br>18.   }<br>19. }<br>20.<br>21. rtems_task Init (rtems_task_argument)<br>22. {<br>23.   tc_finished = false;<br>24.   ___run_tc_wait_1 ();<br>25.   if (tc_finished)<br>26.     cout << "___TC_wait_1: " << "PASS" << endl;<br>27.   else<br>28.     cout << "___TC_wait_1: " << "RESTART" << endl;<br>29.   cout << endl;<br>30.<br>31.   cout << "finito!" << endl;<br>32.   exit (0);<br>33. }<br><br></div>It's going to be thousands of test cases, and I want to serially run each test case in a task other than Init.<br></div>In the code above, I've marked symbols that are per each test case, with 3 leading underscores (___).<br></div>This is the basic duplication structure I've come up with. Since RTEMS doesn't support dynamic linking, I'm going to duplicate lines 3 to 19 (___run_tc_abs_1) and 23 to 29 for each test case which leads to having a very big source file for testcase_executer.cpp.<br>Is there any better solution that avoids code redundancy that I'm not aware of? Do you have advices on how to change this structure to minimize code redundancy? Any help is much appreciated.<br></div><div>Note: ___TC_abs_1 is already defined in a separate CPP file.<br></div><div><br></div>Thanks for your time.<br><br></div><div>Kind Regards,<br></div>SAeeD<br></div>