test_stringfields.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2009, Mark Michelson
  5. *
  6. * Mark Michelson <mmmichelson@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*! \file
  19. *
  20. * \brief String fields test
  21. *
  22. * \author\verbatim Mark Michelson <mmichelson@digium.com> \endverbatim
  23. *
  24. * Test module for string fields API
  25. * \ingroup tests
  26. */
  27. /*** MODULEINFO
  28. <depend>TEST_FRAMEWORK</depend>
  29. <support_level>core</support_level>
  30. ***/
  31. #include "asterisk.h"
  32. #include "asterisk/module.h"
  33. #include "asterisk/stringfields.h"
  34. #include "asterisk/cli.h"
  35. #include "asterisk/utils.h"
  36. #include "asterisk/test.h"
  37. AST_TEST_DEFINE(string_field_test)
  38. {
  39. const char *address_holder;
  40. struct ast_string_field_pool *field_pool1;
  41. struct ast_string_field_pool *field_pool2;
  42. struct ast_string_field_pool *field_pool3;
  43. static const char LONG_STRING[] = "A professional panoramic photograph of the majestic elephant bathing itself and its young by the shores of the raging Mississippi River";
  44. struct {
  45. AST_DECLARE_STRING_FIELDS (
  46. AST_STRING_FIELD(string1);
  47. );
  48. AST_STRING_FIELD_EXTENDED(string2);
  49. } test_struct;
  50. struct {
  51. AST_DECLARE_STRING_FIELDS (
  52. AST_STRING_FIELD(string1);
  53. AST_STRING_FIELD(string2);
  54. );
  55. AST_STRING_FIELD_EXTENDED(string3);
  56. } test_struct2;
  57. switch (cmd) {
  58. case TEST_INIT:
  59. info->name = "string_field_test";
  60. info->category = "/main/utils/";
  61. info->summary = "Test stringfield operations";
  62. info->description =
  63. "This tests the stringfield API";
  64. return AST_TEST_NOT_RUN;
  65. case TEST_EXECUTE:
  66. break;
  67. }
  68. memset(&test_struct, 0, sizeof(test_struct));
  69. memset(&test_struct2, 0, sizeof(test_struct));
  70. ast_test_status_update(test, "First things first. Let's see if we can actually allocate string fields\n");
  71. if (ast_string_field_init(&test_struct, 32)) {
  72. ast_test_status_update(test, "Failure to initialize string fields. They are totally messed up\n");
  73. return AST_TEST_FAIL;
  74. } else {
  75. ast_test_status_update(test, "All right! Successfully allocated! Now let's get down to business\n");
  76. }
  77. ast_string_field_init_extended(&test_struct, string2);
  78. ast_test_status_update(test,"We're going to set some string fields and perform some checks\n");
  79. ast_string_field_set(&test_struct, string1, "elephant");
  80. ast_string_field_set(&test_struct, string2, "hippopotamus");
  81. ast_test_status_update(test, "First we're going to make sure that the strings are actually set to what we expect\n");
  82. if (strcmp(test_struct.string1, "elephant")) {
  83. ast_test_status_update(test, "We were expecting test_struct.string1 to have 'elephant' but it has %s\n", test_struct.string1);
  84. goto error;
  85. } else {
  86. ast_test_status_update(test, "test_struct.string1 appears to be all clear. It has '%s' and that's what we expect\n", test_struct.string1);
  87. }
  88. if (strcmp(test_struct.string2, "hippopotamus")) {
  89. ast_test_status_update(test, "We were expecting test_struct.string2 to have 'hippopotamus' but it has %s\n", test_struct.string2);
  90. goto error;
  91. } else {
  92. ast_test_status_update(test, "test_struct.string2 appears to be all clear. It has '%s' and that's what we expect\n", test_struct.string2);
  93. }
  94. ast_test_status_update(test, "Now let's make sure that our recorded capacities for these strings is what we expect\n");
  95. if (AST_STRING_FIELD_ALLOCATION(test_struct.string1) != strlen("elephant") + 1) {
  96. ast_test_status_update(test, "string1 has allocation area of %hu but we expect %lu\n",
  97. AST_STRING_FIELD_ALLOCATION(test_struct.string1), (unsigned long) strlen("elephant") + 1);
  98. goto error;
  99. } else {
  100. ast_test_status_update(test, "string1 has the allocation area we expect: %hu\n", AST_STRING_FIELD_ALLOCATION(test_struct.string1));
  101. }
  102. if (AST_STRING_FIELD_ALLOCATION(test_struct.string2) != strlen("hippopotamus") + 1) {
  103. ast_test_status_update(test, "string2 has allocation area of %hu but we expect %lu\n",
  104. AST_STRING_FIELD_ALLOCATION(test_struct.string2), (unsigned long) strlen("hippopotamus") + 1);
  105. goto error;
  106. } else {
  107. ast_test_status_update(test, "string2 has the allocation area we expect: %hu\n", AST_STRING_FIELD_ALLOCATION(test_struct.string2));
  108. }
  109. ast_test_status_update(test, "Now we're going to shrink string1 and see if it's in the same place in memory\n");
  110. address_holder = test_struct.string1;
  111. ast_string_field_set(&test_struct, string1, "rhino");
  112. if (strcmp(test_struct.string1, "rhino")) {
  113. ast_test_status_update(test, "string1 has the wrong value in it. We want 'rhino' but it has '%s'\n", test_struct.string1);
  114. goto error;
  115. } else {
  116. ast_test_status_update(test, "string1 successfully was changed to '%s'\n", test_struct.string1);
  117. }
  118. if (address_holder != test_struct.string1) {
  119. ast_test_status_update(test, "We shrunk string1, but it moved?!\n");
  120. goto error;
  121. } else {
  122. ast_test_status_update(test, "Shrinking string1 allowed it to stay in the same place in memory\n");
  123. }
  124. if (AST_STRING_FIELD_ALLOCATION(test_struct.string1) != strlen("elephant") + 1) {
  125. ast_test_status_update(test, "The allocation amount changed when we shrunk the string...\n");
  126. goto error;
  127. } else {
  128. ast_test_status_update(test, "Shrinking string1 did not change its allocation area (This is a good thing)\n");
  129. }
  130. ast_test_status_update(test, "Next, let's increase it a little but not all the way to its original size\n");
  131. address_holder = test_struct.string1;
  132. ast_string_field_set(&test_struct, string1, "mammoth");
  133. if (strcmp(test_struct.string1, "mammoth")) {
  134. ast_test_status_update(test, "string1 has the wrong value in it. We want 'mammoth' but it has '%s'\n", test_struct.string1);
  135. goto error;
  136. } else {
  137. ast_test_status_update(test, "string1 successfully was changed to '%s'\n", test_struct.string1);
  138. }
  139. if (address_holder != test_struct.string1) {
  140. ast_test_status_update(test, "We expanded string1, but it moved?!\n");
  141. goto error;
  142. } else {
  143. ast_test_status_update(test, "Expanding string1 allowed it to stay in the same place in memory\n");
  144. }
  145. if (AST_STRING_FIELD_ALLOCATION(test_struct.string1) != strlen("elephant") + 1) {
  146. ast_test_status_update(test, "The allocation amount changed when we expanded the string...\n");
  147. goto error;
  148. } else {
  149. ast_test_status_update(test, "Expanding string1 did not change its allocation area (This is a good thing)\n");
  150. }
  151. ast_test_status_update(test, "Cool, now let's bring it back to its original size and see what happens\n");
  152. ast_string_field_set(&test_struct, string1, "elephant");
  153. if (strcmp(test_struct.string1, "elephant")) {
  154. ast_test_status_update(test, "string1 has the wrong value in it. We want 'elephant' but it has '%s'\n", test_struct.string1);
  155. goto error;
  156. } else {
  157. ast_test_status_update(test, "string1 successfully changed to '%s'\n", test_struct.string1);
  158. }
  159. if (address_holder != test_struct.string1) {
  160. ast_test_status_update(test, "We restored string1 to its original size, but it moved?!\n");
  161. goto error;
  162. } else {
  163. ast_test_status_update(test, "Restoring string1 did not cause it to move (This is a good thing)\n");
  164. }
  165. if (AST_STRING_FIELD_ALLOCATION(test_struct.string1) != strlen("elephant") + 1) {
  166. ast_test_status_update(test, "The allocation amount changed when we re-expanded the string...\n");
  167. goto error;
  168. } else {
  169. ast_test_status_update(test, "The allocation amount for string1 is still holding steady\n");
  170. }
  171. ast_test_status_update(test, "All right, now we're going to expand string 2. It should stay in place since it was the last string allocated in this pool\n");
  172. address_holder = test_struct.string2;
  173. ast_string_field_set(&test_struct, string2, "hippopotamus face");
  174. if (strcmp(test_struct.string2, "hippopotamus face")) {
  175. ast_test_status_update(test, "string2 has the wrong value. We want 'hippopotamus face' but it has '%s'\n", test_struct.string2);
  176. goto error;
  177. } else {
  178. ast_test_status_update(test, "string2 successfully changed to '%s'\n", test_struct.string2);
  179. }
  180. if (AST_STRING_FIELD_ALLOCATION(test_struct.string2) != strlen("hippopotamus face") + 1) {
  181. ast_test_status_update(test, "The allocation amount is incorrect for string2. We expect %lu but it has %d\n",
  182. (unsigned long) strlen("hippopotamus face"), AST_STRING_FIELD_ALLOCATION(test_struct.string2) + 1);
  183. goto error;
  184. } else {
  185. ast_test_status_update(test, "The allocation amount successfully increased for string2 when it grew\n");
  186. }
  187. if (test_struct.string2 != address_holder) {
  188. ast_test_status_update(test, "string2 has moved, but it should not have since it had room to grow\n");
  189. goto error;
  190. } else {
  191. ast_test_status_update(test, "string2 stayed in place when it grew. Good job!\n");
  192. }
  193. ast_test_status_update(test, "Now we're going to set string1 to a very long string so that a new string field pool must be allocated\n");
  194. address_holder = test_struct.string1;
  195. ast_string_field_set(&test_struct, string1, LONG_STRING);
  196. if (strcmp(test_struct.string1, LONG_STRING)) {
  197. ast_test_status_update(test, "We were expecting string1 to be '%s'\nbut it was actually '%s'\n", LONG_STRING, test_struct.string1);
  198. goto error;
  199. } else {
  200. ast_test_status_update(test, "string1 successfully changed to '%s'\n", test_struct.string1);
  201. }
  202. if (address_holder == test_struct.string1) {
  203. ast_test_status_update(test, "Uh oh, string1 didn't move when we set it to a long value\n");
  204. goto error;
  205. } else {
  206. ast_test_status_update(test, "Good. Setting string1 to a long value caused it to change addresses\n");
  207. }
  208. if (AST_STRING_FIELD_ALLOCATION(test_struct.string1) != strlen(LONG_STRING) + 1) {
  209. ast_test_status_update(test, "The string field allocation for string1 indicates a length of %hu instead of the expected %lu\n",
  210. AST_STRING_FIELD_ALLOCATION(test_struct.string1), (unsigned long) strlen(LONG_STRING) + 1);
  211. goto error;
  212. } else {
  213. ast_test_status_update(test, "The stored allocation size of string1 is what we expect\n");
  214. }
  215. ast_string_field_init(&test_struct2, 32);
  216. ast_test_status_update(test, "Now using a totally separate area of memory we're going to test a basic pool freeing scenario\n");
  217. ast_string_field_init_extended(&test_struct2, string3);
  218. ast_string_field_set(&test_struct2, string1, "first");
  219. ast_string_field_set(&test_struct2, string2, "second");
  220. ast_string_field_set(&test_struct2, string3, "third");
  221. /* This string is 208 characters long, which will surely exceed the initial pool size */
  222. ast_string_field_set(&test_struct2, string1, "Expanded first string to create new pool-----------------------------------------------------------------------------------------------------------------------------------------------------------------------");
  223. /* Pool size at this point is 976, so 1000 chars should do it */
  224. ast_string_field_set(&test_struct2, string2, "Expanded second string to create new pool----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
  225. field_pool3 = test_struct2.__field_mgr_pool;
  226. field_pool2 = test_struct2.__field_mgr_pool->prev;
  227. field_pool1 = test_struct2.__field_mgr_pool->prev->prev;
  228. if(field_pool3->prev != field_pool2 || field_pool2->prev != field_pool1) {
  229. ast_test_status_update(test, "Pools are not linked properly!\n");
  230. goto error;
  231. } else {
  232. ast_test_status_update(test, "Three different pools are linked as expected.\n");
  233. }
  234. ast_string_field_set(&test_struct2, string1, NULL);
  235. if (test_struct2.string1 != __ast_string_field_empty || field_pool3->prev != field_pool1) {
  236. ast_test_status_update(test, "Things did not work out when removing the middle pool!\n");
  237. goto error;
  238. } else {
  239. ast_test_status_update(test, "After removing a pool the remaining two are linked as expected.\n");
  240. }
  241. ast_string_field_free_memory(&test_struct2);
  242. ast_string_field_free_memory(&test_struct);
  243. return AST_TEST_PASS;
  244. error:
  245. ast_string_field_free_memory(&test_struct);
  246. ast_string_field_free_memory(&test_struct2);
  247. return AST_TEST_FAIL;
  248. }
  249. struct test_struct {
  250. int foo;
  251. AST_DECLARE_STRING_FIELDS (
  252. AST_STRING_FIELD(string1);
  253. );
  254. int foo2;
  255. AST_STRING_FIELD_EXTENDED(string2);
  256. };
  257. AST_TEST_DEFINE(string_field_aggregate_test)
  258. {
  259. enum ast_test_result_state res = AST_TEST_PASS;
  260. struct test_struct *inst1 = NULL;
  261. struct test_struct *inst2 = NULL;
  262. struct test_struct *inst3 = NULL;
  263. struct test_struct *inst4 = NULL;
  264. switch (cmd) {
  265. case TEST_INIT:
  266. info->name = "string_field_aggregate_test";
  267. info->category = "/main/utils/";
  268. info->summary = "Test stringfield aggregate operations";
  269. info->description =
  270. "This tests the structure comparison and copy macros of the stringfield API";
  271. return AST_TEST_NOT_RUN;
  272. case TEST_EXECUTE:
  273. break;
  274. }
  275. inst1 = ast_calloc_with_stringfields(1, struct test_struct, 32);
  276. if (!inst1) {
  277. ast_test_status_update(test, "Unable to allocate structure 1!\n");
  278. res = AST_TEST_FAIL;
  279. goto error;
  280. }
  281. ast_string_field_init_extended(inst1, string2);
  282. inst2 = ast_calloc_with_stringfields(1, struct test_struct, 32);
  283. if (!inst2) {
  284. ast_test_status_update(test, "Unable to allocate structure 2!\n");
  285. res = AST_TEST_FAIL;
  286. goto error;
  287. }
  288. ast_string_field_init_extended(inst2, string2);
  289. inst3 = ast_calloc_with_stringfields(1, struct test_struct, 32);
  290. if (!inst3) {
  291. ast_test_status_update(test, "Unable to allocate structure 3!\n");
  292. res = AST_TEST_FAIL;
  293. goto error;
  294. }
  295. ast_string_field_init_extended(inst3, string2);
  296. inst4 = ast_calloc_with_stringfields(1, struct test_struct, 32);
  297. if (!inst4) {
  298. ast_test_status_update(test, "Unable to allocate structure 4!\n");
  299. res = AST_TEST_FAIL;
  300. goto error;
  301. }
  302. ast_string_field_init_extended(inst4, string2);
  303. ast_string_field_set(inst1, string1, "foo");
  304. ast_string_field_set(inst1, string2, "bar");
  305. inst1->foo = 1;
  306. ast_string_field_ptr_set_by_fields(inst2->__field_mgr_pool, inst2->__field_mgr, &inst2->string2, "bar");
  307. ast_string_field_ptr_set_by_fields(inst2->__field_mgr_pool, inst2->__field_mgr, &inst2->string1, "foo");
  308. inst2->foo = 2;
  309. if (inst3->__field_mgr.header->embedded_pool->prev) {
  310. ast_test_status_update(test, "Structure 3 embedded pool should not have a previous pool!\n");
  311. res = AST_TEST_FAIL;
  312. goto error;
  313. }
  314. ast_string_field_set(inst3, string1, "foo");
  315. if (inst3->__field_mgr.header->embedded_pool != inst3->__field_mgr_pool) {
  316. ast_test_status_update(test, "Structure 3 embedded pool should have been the current pool!\n");
  317. res = AST_TEST_FAIL;
  318. goto error;
  319. }
  320. if (inst3->__field_mgr.header->embedded_pool->prev) {
  321. ast_test_status_update(test, "Structure 3 embedded pool should not have a previous pool!\n");
  322. res = AST_TEST_FAIL;
  323. goto error;
  324. }
  325. ast_test_status_update(test, "Structures 3 embedded pool initialized successfully.\n");
  326. /* Exhaust the embedded pool */
  327. ast_string_field_set(inst3, string2, "baz 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890");
  328. inst3->foo = 3;
  329. if (inst3->__field_mgr_pool == inst3->__field_mgr.header->embedded_pool) {
  330. ast_test_status_update(test, "Structure 3 embedded pool should not have been the current pool!\n");
  331. res = AST_TEST_FAIL;
  332. goto error;
  333. }
  334. if (inst3->__field_mgr.header->embedded_pool != inst3->__field_mgr_pool->prev) {
  335. ast_test_status_update(test, "Structure 3 embedded pool should be the current pool's previous!\n");
  336. res = AST_TEST_FAIL;
  337. goto error;
  338. }
  339. ast_test_status_update(test, "Structures 3 additional pool initialized successfully.\n");
  340. ast_string_field_set(inst4, string1, "faz");
  341. /* Exhaust the embedded pool */
  342. ast_string_field_set(inst4, string2, "baz 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890");
  343. inst4->foo = 4;
  344. if (ast_string_fields_cmp(inst1, inst2)) {
  345. ast_test_status_update(test, "Structures 1/2 should be equal!\n");
  346. res = AST_TEST_FAIL;
  347. goto error;
  348. } else {
  349. ast_test_status_update(test, "Structures 1/2 are equal as expected.\n");
  350. }
  351. if (!ast_string_fields_cmp(inst1, inst3)) {
  352. ast_test_status_update(test, "Structures 1/3 should be different!\n");
  353. res = AST_TEST_FAIL;
  354. goto error;
  355. } else {
  356. ast_test_status_update(test, "Structures 1/3 are different as expected.\n");
  357. }
  358. if (!ast_string_fields_cmp(inst2, inst3)) {
  359. ast_test_status_update(test, "Structures 2/3 should be different!\n");
  360. res = AST_TEST_FAIL;
  361. goto error;
  362. } else {
  363. ast_test_status_update(test, "Structures 2/3 are different as expected.\n");
  364. }
  365. if (!ast_string_fields_cmp(inst3, inst4)) {
  366. ast_test_status_update(test, "Structures 3/4 should be different!\n");
  367. res = AST_TEST_FAIL;
  368. goto error;
  369. } else {
  370. ast_test_status_update(test, "Structures 3/4 are different as expected.\n");
  371. }
  372. if (ast_string_fields_copy(inst1, inst3)) {
  373. ast_test_status_update(test, "Copying from structure 3 to structure 1 failed!\n");
  374. res = AST_TEST_FAIL;
  375. goto error;
  376. } else {
  377. ast_test_status_update(test, "Copying from structure 3 to structure 1 succeeded!\n");
  378. }
  379. /* inst1 and inst3 should now be equal and inst1 should no longer be equal to inst2 */
  380. if (ast_string_fields_cmp(inst1, inst3)) {
  381. ast_test_status_update(test, "Structures 1/3 should be equal!\n");
  382. res = AST_TEST_FAIL;
  383. goto error;
  384. } else {
  385. ast_test_status_update(test, "Structures 1/3 are equal as expected.\n");
  386. }
  387. if (!ast_string_fields_cmp(inst1, inst2)) {
  388. ast_test_status_update(test, "Structures 1/2 should be different!\n");
  389. res = AST_TEST_FAIL;
  390. } else {
  391. ast_test_status_update(test, "Structures 1/2 are different as expected.\n");
  392. }
  393. ast_test_status_update(test, "Reset but don't free.\n");
  394. ast_string_field_init(inst1, AST_STRINGFIELD_RESET);
  395. ast_string_field_init(inst2, AST_STRINGFIELD_RESET);
  396. ast_string_field_init(inst3, AST_STRINGFIELD_RESET);
  397. ast_string_field_init(inst4, AST_STRINGFIELD_RESET);
  398. if (ast_string_fields_cmp(inst1, inst2)) {
  399. ast_test_status_update(test, "Structures 1/2 should be the same (empty)!\n");
  400. res = AST_TEST_FAIL;
  401. } else {
  402. ast_test_status_update(test, "Structures 1/2 are the same (empty) as expected.\n");
  403. }
  404. if (inst4->__field_mgr.header->embedded_pool != inst4->__field_mgr_pool) {
  405. ast_test_status_update(test, "Structure 4 embedded pool should have been the current pool!\n");
  406. res = AST_TEST_FAIL;
  407. goto error;
  408. } else {
  409. ast_test_status_update(test, "Structure 4 embedded pool is the current pool as expected.\n");
  410. }
  411. if (inst4->__field_mgr.header->embedded_pool->prev) {
  412. ast_test_status_update(test, "Structure 4 embedded pool should not have a previous pool!\n");
  413. res = AST_TEST_FAIL;
  414. goto error;
  415. } else {
  416. ast_test_status_update(test, "Structure 4 embedded pool does not have a previous as expected.\n");
  417. }
  418. error:
  419. ast_string_field_free_memory(inst1);
  420. ast_free(inst1);
  421. ast_string_field_free_memory(inst2);
  422. ast_free(inst2);
  423. ast_string_field_free_memory(inst3);
  424. ast_free(inst3);
  425. ast_string_field_free_memory(inst4);
  426. ast_free(inst4);
  427. return res;
  428. }
  429. static int unload_module(void)
  430. {
  431. AST_TEST_UNREGISTER(string_field_aggregate_test);
  432. AST_TEST_UNREGISTER(string_field_test);
  433. return 0;
  434. }
  435. static int load_module(void)
  436. {
  437. AST_TEST_REGISTER(string_field_test);
  438. AST_TEST_REGISTER(string_field_aggregate_test);
  439. return AST_MODULE_LOAD_SUCCESS;
  440. }
  441. AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "String Fields Test");