Commit 7f48e0fddc544eb1ed7e4893da8c94555d668c67

Authored by Stéphane Raimbault
1 parent f1eb4bc7

Move malloc before starting unit tests

Showing 1 changed file with 7 additions and 7 deletions
tests/unit-test-client.c
... ... @@ -108,13 +108,6 @@ int main(int argc, char *argv[])
108 108 modbus_free(ctx);
109 109 return -1;
110 110 }
111   - modbus_get_response_timeout(ctx, &new_response_to_sec, &new_response_to_usec);
112   -
113   - printf("** UNIT TESTING **\n");
114   -
115   - printf("1/1 No response timeout modification on connect: ");
116   - ASSERT_TRUE(old_response_to_sec == new_response_to_sec &&
117   - old_response_to_usec == new_response_to_usec, "");
118 111  
119 112 /* Allocate and initialize the memory to store the bits */
120 113 nb_points = (UT_BITS_NB > UT_INPUT_BITS_NB) ? UT_BITS_NB : UT_INPUT_BITS_NB;
... ... @@ -127,6 +120,13 @@ int main(int argc, char *argv[])
127 120 tab_rp_registers = (uint16_t *) malloc(nb_points * sizeof(uint16_t));
128 121 memset(tab_rp_registers, 0, nb_points * sizeof(uint16_t));
129 122  
  123 + printf("** UNIT TESTING **\n");
  124 +
  125 + printf("1/1 No response timeout modification on connect: ");
  126 + modbus_get_response_timeout(ctx, &new_response_to_sec, &new_response_to_usec);
  127 + ASSERT_TRUE(old_response_to_sec == new_response_to_sec &&
  128 + old_response_to_usec == new_response_to_usec, "");
  129 +
130 130 printf("\nTEST WRITE/READ:\n");
131 131  
132 132 /** COIL BITS **/
... ...