client_test.cc 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521
  1. /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  2. *
  3. * Gearmand client and server library.
  4. *
  5. * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
  6. * Copyright (C) 2008 Brian Aker, Eric Day
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are
  11. * met:
  12. *
  13. * * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * * Redistributions in binary form must reproduce the above
  17. * copyright notice, this list of conditions and the following disclaimer
  18. * in the documentation and/or other materials provided with the
  19. * distribution.
  20. *
  21. * * The names of its contributors may not be used to endorse or
  22. * promote products derived from this software without specific prior
  23. * written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. */
  38. #include "gear_config.h"
  39. #include <libtest/test.hpp>
  40. using namespace libtest;
  41. #include <cassert>
  42. #include <cstdio>
  43. #include <cstdlib>
  44. #include <cstring>
  45. #include <ctime>
  46. #include <iostream>
  47. #include <vector>
  48. #define GEARMAN_CORE
  49. #include <libgearman-1.0/gearman.h>
  50. #include "tests/start_worker.h"
  51. #include "tests/workers/v1/echo_or_react.h"
  52. #include "tests/workers/v1/echo_or_react_chunk.h"
  53. #include "tests/workers/v2/echo_or_react.h"
  54. #include "tests/workers/v2/echo_or_react_chunk.h"
  55. #define NAMESPACE_KEY "foo123"
  56. #define WORKER_FUNCTION_NAME "client_test"
  57. #define WORKER_CHUNKED_FUNCTION_NAME "reverse_test"
  58. #include "libgearman/client.hpp"
  59. #include "libgearman/worker.hpp"
  60. using namespace org::gearmand;
  61. #include "tests/limits.h"
  62. #include "tests/do.h"
  63. #include "tests/server_options.h"
  64. #include "tests/do_background.h"
  65. #include "tests/execute.h"
  66. #include "tests/gearman_client_do_job_handle.h"
  67. #include "tests/gearman_execute_partition.h"
  68. #include "tests/libgearman-1.0/fork.h"
  69. #include "tests/protocol.h"
  70. #include "tests/regression.h"
  71. #include "tests/task.h"
  72. #include "tests/unique.h"
  73. #ifndef __INTEL_COMPILER
  74. #pragma GCC diagnostic ignored "-Wold-style-cast"
  75. #endif
  76. #include "tests/runner.h"
  77. #ifndef __INTEL_COMPILER
  78. #pragma GCC diagnostic ignored "-Wold-style-cast"
  79. #endif
  80. #include "tests/libgearman-1.0/client_test.h"
  81. #include "libgearman/interface/client.hpp"
  82. #include "libgearman/is.hpp"
  83. /**
  84. @note Just here until I fix libhashkit.
  85. */
  86. static uint32_t internal_generate_hash(const char *key, size_t key_length)
  87. {
  88. const char *ptr= key;
  89. uint32_t value= 0;
  90. while (key_length--)
  91. {
  92. uint32_t val= (uint32_t) *ptr++;
  93. value += val;
  94. value += (value << 10);
  95. value ^= (value >> 6);
  96. }
  97. value += (value << 3);
  98. value ^= (value >> 11);
  99. value += (value << 15);
  100. return value == 0 ? 1 : (uint32_t) value;
  101. }
  102. /* Prototypes */
  103. static void *client_test_temp_worker(gearman_job_st *, void *,
  104. size_t *result_size, gearman_return_t *ret_ptr)
  105. {
  106. *result_size= 0;
  107. *ret_ptr= GEARMAN_SUCCESS;
  108. return NULL;
  109. }
  110. extern "C"
  111. {
  112. static __attribute__((noreturn)) void *client_thread(void *object)
  113. {
  114. volatile gearman_return_t *ret= (volatile gearman_return_t *)object;
  115. {
  116. libgearman::Client client(libtest::default_port());
  117. gearman_client_set_timeout(&client, 400);
  118. for (size_t x= 0; x < 5; x++)
  119. {
  120. gearman_return_t rc;
  121. size_t result_size;
  122. (void)gearman_client_do(&client, "client_test_temp", NULL, NULL, 0, &result_size, &rc);
  123. if (gearman_failed(rc))
  124. {
  125. *ret= rc;
  126. break;
  127. }
  128. }
  129. }
  130. pthread_exit(0);
  131. }
  132. }
  133. static test_return_t init_test(void *)
  134. {
  135. gearman_client_st client;
  136. ASSERT_TRUE(gearman_client_create(&client));
  137. gearman_client_free(&client);
  138. return TEST_SUCCESS;
  139. }
  140. static test_return_t allocation_test(void *)
  141. {
  142. gearman_client_st *client;
  143. ASSERT_TRUE(client= gearman_client_create(NULL));
  144. gearman_client_free(client);
  145. return TEST_SUCCESS;
  146. }
  147. static test_return_t clone_test(void *)
  148. {
  149. {
  150. gearman_client_st *client= gearman_client_clone(NULL, NULL);
  151. ASSERT_TRUE(client);
  152. ASSERT_TRUE(gearman_is_allocated(client));
  153. gearman_client_free(client);
  154. }
  155. {
  156. gearman_client_st *from= gearman_client_create(NULL);
  157. ASSERT_TRUE(from);
  158. gearman_client_st* client= gearman_client_clone(NULL, from);
  159. ASSERT_TRUE(client);
  160. gearman_client_free(client);
  161. gearman_client_free(from);
  162. }
  163. {
  164. gearman_client_st *from_with_host= gearman_client_create(NULL);
  165. ASSERT_TRUE(from_with_host);
  166. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_add_server(from_with_host, "localhost", 12345));
  167. ASSERT_TRUE(from_with_host->impl()->universal.con_list);
  168. gearman_client_st* client= gearman_client_clone(NULL, from_with_host);
  169. ASSERT_TRUE(client);
  170. ASSERT_TRUE(client->impl()->universal.con_list);
  171. ASSERT_TRUE(gearman_client_compare(client, from_with_host));
  172. gearman_client_free(client);
  173. gearman_client_free(from_with_host);
  174. }
  175. return TEST_SUCCESS;
  176. }
  177. static test_return_t option_test(void *)
  178. {
  179. gearman_client_st *gear;
  180. gearman_client_options_t default_options;
  181. gear= gearman_client_create(NULL);
  182. ASSERT_TRUE(gear);
  183. { // Initial Allocated, no changes
  184. ASSERT_TRUE(gearman_is_allocated(gear));
  185. test_false(gear->impl()->options.non_blocking);
  186. test_false(gear->impl()->options.unbuffered_result);
  187. test_false(gear->impl()->options.no_new);
  188. test_false(gear->impl()->options.free_tasks);
  189. ASSERT_FALSE(gear->impl()->options.generate_unique);
  190. }
  191. /* Set up for default options */
  192. default_options= gearman_client_options(gear);
  193. /*
  194. We take the basic options, and push
  195. them back in. See if we change anything.
  196. */
  197. gearman_client_set_options(gear, default_options);
  198. { // Initial Allocated, no changes
  199. ASSERT_TRUE(gearman_is_allocated(gear));
  200. test_false(gear->impl()->options.non_blocking);
  201. test_false(gear->impl()->options.unbuffered_result);
  202. test_false(gear->impl()->options.no_new);
  203. test_false(gear->impl()->options.free_tasks);
  204. ASSERT_FALSE(gear->impl()->options.generate_unique);
  205. }
  206. /*
  207. We will trying to modify non-mutable options (which should not be allowed)
  208. */
  209. {
  210. gearman_client_remove_options(gear, GEARMAN_CLIENT_ALLOCATED);
  211. { // Initial Allocated, no changes
  212. ASSERT_TRUE(gearman_is_allocated(gear));
  213. test_false(gear->impl()->options.non_blocking);
  214. test_false(gear->impl()->options.unbuffered_result);
  215. test_false(gear->impl()->options.no_new);
  216. test_false(gear->impl()->options.free_tasks);
  217. ASSERT_FALSE(gear->impl()->options.generate_unique);
  218. }
  219. gearman_client_remove_options(gear, GEARMAN_CLIENT_NO_NEW);
  220. { // Initial Allocated, no changes
  221. ASSERT_TRUE(gearman_is_allocated(gear));
  222. test_false(gear->impl()->options.non_blocking);
  223. test_false(gear->impl()->options.unbuffered_result);
  224. test_false(gear->impl()->options.no_new);
  225. test_false(gear->impl()->options.free_tasks);
  226. ASSERT_FALSE(gear->impl()->options.generate_unique);
  227. }
  228. }
  229. /*
  230. We will test modifying GEARMAN_CLIENT_NON_BLOCKING in several manners.
  231. */
  232. {
  233. gearman_client_remove_options(gear, GEARMAN_CLIENT_NON_BLOCKING);
  234. { // GEARMAN_CLIENT_NON_BLOCKING set to default, by default.
  235. ASSERT_TRUE(gearman_is_allocated(gear));
  236. test_false(gear->impl()->options.non_blocking);
  237. test_false(gear->impl()->options.unbuffered_result);
  238. test_false(gear->impl()->options.no_new);
  239. test_false(gear->impl()->options.free_tasks);
  240. }
  241. gearman_client_add_options(gear, GEARMAN_CLIENT_NON_BLOCKING);
  242. { // GEARMAN_CLIENT_NON_BLOCKING set to default, by default.
  243. ASSERT_TRUE(gearman_is_allocated(gear));
  244. ASSERT_TRUE(gear->impl()->options.non_blocking);
  245. test_false(gear->impl()->options.unbuffered_result);
  246. test_false(gear->impl()->options.no_new);
  247. test_false(gear->impl()->options.free_tasks);
  248. }
  249. gearman_client_set_options(gear, GEARMAN_CLIENT_NON_BLOCKING);
  250. { // GEARMAN_CLIENT_NON_BLOCKING set to default, by default.
  251. ASSERT_TRUE(gearman_is_allocated(gear));
  252. ASSERT_TRUE(gear->impl()->options.non_blocking);
  253. test_false(gear->impl()->options.unbuffered_result);
  254. test_false(gear->impl()->options.no_new);
  255. test_false(gear->impl()->options.free_tasks);
  256. }
  257. gearman_client_set_options(gear, GEARMAN_CLIENT_UNBUFFERED_RESULT);
  258. { // Everything is now set to false except GEARMAN_CLIENT_UNBUFFERED_RESULT, and non-mutable options
  259. ASSERT_TRUE(gearman_is_allocated(gear));
  260. test_false(gear->impl()->options.non_blocking);
  261. ASSERT_TRUE(gear->impl()->options.unbuffered_result);
  262. test_false(gear->impl()->options.no_new);
  263. test_false(gear->impl()->options.free_tasks);
  264. }
  265. // Test setting GEARMAN_CLIENT_GENERATE_UNIQUE
  266. {
  267. gearman_client_set_options(gear, default_options);
  268. { // See if we return to defaults
  269. test_false(gear->impl()->options.non_blocking);
  270. test_false(gear->impl()->options.unbuffered_result);
  271. test_false(gear->impl()->options.no_new);
  272. test_false(gear->impl()->options.free_tasks);
  273. ASSERT_FALSE(gear->impl()->options.generate_unique);
  274. }
  275. gearman_client_remove_options(gear, GEARMAN_CLIENT_GENERATE_UNIQUE);
  276. { // Initial Allocated, no changes
  277. test_false(gear->impl()->options.non_blocking);
  278. test_false(gear->impl()->options.unbuffered_result);
  279. test_false(gear->impl()->options.no_new);
  280. test_false(gear->impl()->options.free_tasks);
  281. ASSERT_FALSE(gear->impl()->options.generate_unique);
  282. }
  283. gearman_client_set_options(gear, GEARMAN_CLIENT_GENERATE_UNIQUE);
  284. { // See if we return to defaults
  285. test_false(gear->impl()->options.non_blocking);
  286. test_false(gear->impl()->options.unbuffered_result);
  287. test_false(gear->impl()->options.no_new);
  288. test_false(gear->impl()->options.free_tasks);
  289. ASSERT_TRUE(gear->impl()->options.generate_unique);
  290. }
  291. }
  292. /*
  293. Reset options to default. Then add an option, and then add more options. Make sure
  294. the options are all additive.
  295. */
  296. {
  297. gearman_client_set_options(gear, default_options);
  298. { // See if we return to defaults
  299. ASSERT_TRUE(gearman_is_allocated(gear));
  300. test_false(gear->impl()->options.non_blocking);
  301. test_false(gear->impl()->options.unbuffered_result);
  302. test_false(gear->impl()->options.no_new);
  303. test_false(gear->impl()->options.free_tasks);
  304. ASSERT_FALSE(gear->impl()->options.generate_unique);
  305. }
  306. gearman_client_add_options(gear, GEARMAN_CLIENT_FREE_TASKS);
  307. { // All defaults, except timeout_return
  308. ASSERT_TRUE(gearman_is_allocated(gear));
  309. test_false(gear->impl()->options.non_blocking);
  310. test_false(gear->impl()->options.unbuffered_result);
  311. test_false(gear->impl()->options.no_new);
  312. ASSERT_TRUE(gear->impl()->options.free_tasks);
  313. ASSERT_FALSE(gear->impl()->options.generate_unique);
  314. }
  315. gearman_client_add_options(gear, (gearman_client_options_t)(GEARMAN_CLIENT_NON_BLOCKING|GEARMAN_CLIENT_UNBUFFERED_RESULT));
  316. { // GEARMAN_CLIENT_NON_BLOCKING set to default, by default.
  317. ASSERT_TRUE(gearman_is_allocated(gear));
  318. ASSERT_TRUE(gear->impl()->options.non_blocking);
  319. ASSERT_TRUE(gear->impl()->options.unbuffered_result);
  320. test_false(gear->impl()->options.no_new);
  321. ASSERT_TRUE(gear->impl()->options.free_tasks);
  322. ASSERT_FALSE(gear->impl()->options.generate_unique);
  323. }
  324. }
  325. /*
  326. Add an option, and then replace with that option plus a new option.
  327. */
  328. {
  329. gearman_client_set_options(gear, default_options);
  330. { // See if we return to defaults
  331. ASSERT_TRUE(gearman_is_allocated(gear));
  332. test_false(gear->impl()->options.non_blocking);
  333. test_false(gear->impl()->options.unbuffered_result);
  334. test_false(gear->impl()->options.no_new);
  335. test_false(gear->impl()->options.free_tasks);
  336. ASSERT_FALSE(gear->impl()->options.generate_unique);
  337. }
  338. gearman_client_add_options(gear, GEARMAN_CLIENT_FREE_TASKS);
  339. { // All defaults, except timeout_return
  340. ASSERT_TRUE(gearman_is_allocated(gear));
  341. test_false(gear->impl()->options.non_blocking);
  342. test_false(gear->impl()->options.unbuffered_result);
  343. test_false(gear->impl()->options.no_new);
  344. ASSERT_TRUE(gear->impl()->options.free_tasks);
  345. ASSERT_FALSE(gear->impl()->options.generate_unique);
  346. }
  347. gearman_client_add_options(gear, (gearman_client_options_t)(GEARMAN_CLIENT_FREE_TASKS|GEARMAN_CLIENT_UNBUFFERED_RESULT));
  348. { // GEARMAN_CLIENT_NON_BLOCKING set to default, by default.
  349. ASSERT_TRUE(gearman_is_allocated(gear));
  350. test_false(gear->impl()->options.non_blocking);
  351. ASSERT_TRUE(gear->impl()->options.unbuffered_result);
  352. test_false(gear->impl()->options.no_new);
  353. ASSERT_TRUE(gear->impl()->options.free_tasks);
  354. ASSERT_FALSE(gear->impl()->options.generate_unique);
  355. }
  356. }
  357. }
  358. gearman_client_free(gear);
  359. return TEST_SUCCESS;
  360. }
  361. static test_return_t echo_test(void *object)
  362. {
  363. gearman_client_st *client= (gearman_client_st *)object;
  364. ASSERT_TRUE(client);
  365. gearman_string_t value= { test_literal_param("This is my echo test") };
  366. if (GEARMAN_SUCCESS != gearman_client_echo(client, gearman_string_param(value)))
  367. {
  368. Error << gearman_client_error(client);
  369. }
  370. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_echo(client, gearman_string_param(value)));
  371. return TEST_SUCCESS;
  372. }
  373. static void log_printer(const char *line, gearman_verbose_t verbose, void*)
  374. {
  375. Out << gearman_verbose_name(verbose) << " : " << line;
  376. }
  377. static test_return_t gearman_client_set_log_fn_TEST(void *object)
  378. {
  379. gearman_client_st *client= (gearman_client_st *)object;
  380. ASSERT_TRUE(client);
  381. gearman_log_fn *func= log_printer;
  382. gearman_client_set_log_fn(client, func, NULL, GEARMAN_VERBOSE_MAX);
  383. gearman_string_t value= { test_literal_param("This is my echo test") };
  384. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_echo(client, gearman_string_param(value)));
  385. return TEST_SUCCESS;
  386. }
  387. static test_return_t submit_job_test(void *object)
  388. {
  389. gearman_client_st *client= (gearman_client_st *)object;
  390. ASSERT_TRUE(client);
  391. const char *worker_function= (const char *)gearman_client_context(client);
  392. ASSERT_TRUE(worker_function);
  393. gearman_string_t value= { test_literal_param("submit_job_test") };
  394. size_t result_length;
  395. gearman_return_t rc;
  396. void *job_result= gearman_client_do(client, worker_function, NULL, gearman_string_param(value), &result_length, &rc);
  397. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  398. ASSERT_TRUE(job_result);
  399. ASSERT_EQ(gearman_size(value), result_length);
  400. test_memcmp(gearman_c_str(value), job_result, gearman_size(value));
  401. free(job_result);
  402. return TEST_SUCCESS;
  403. }
  404. static test_return_t submit_echo_job_test(void *object)
  405. {
  406. gearman_client_st *client= (gearman_client_st *)object;
  407. ASSERT_TRUE(client);
  408. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_echo(client, test_literal_param("foo")));
  409. return submit_job_test(object);
  410. }
  411. static test_return_t submit_null_job_test(void *object)
  412. {
  413. gearman_client_st *client= (gearman_client_st *)object;
  414. ASSERT_TRUE(client);
  415. const char *worker_function= (const char *)gearman_client_context(client);
  416. ASSERT_NOT_NULL(worker_function);
  417. size_t result_length;
  418. gearman_return_t rc;
  419. void *job_result= gearman_client_do(client, worker_function, NULL, NULL, 0,
  420. &result_length, &rc);
  421. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  422. test_zero(result_length);
  423. test_false(job_result);
  424. return TEST_SUCCESS;
  425. }
  426. static test_return_t submit_exception_job_test(void *object)
  427. {
  428. gearman_client_st *client= (gearman_client_st *)object;
  429. ASSERT_TRUE(client);
  430. const char *worker_function= (const char *)gearman_client_context(client);
  431. ASSERT_TRUE(worker_function);
  432. size_t result_length;
  433. gearman_return_t rc;
  434. void *job_result= gearman_client_do(client, worker_function, NULL,
  435. test_literal_param("exception"),
  436. &result_length, &rc);
  437. if (gearman_client_has_option(client, GEARMAN_CLIENT_EXCEPTION))
  438. {
  439. ASSERT_NOT_NULL(job_result);
  440. ASSERT_EQ(GEARMAN_WORK_EXCEPTION, rc);
  441. test_memcmp(EXCEPTION_MESSAGE, job_result, result_length);
  442. free(job_result);
  443. }
  444. else
  445. {
  446. ASSERT_NULL(job_result);
  447. ASSERT_EQ(GEARMAN_WORK_EXCEPTION, rc);
  448. }
  449. return TEST_SUCCESS;
  450. }
  451. static test_return_t submit_warning_job_test(void *object)
  452. {
  453. gearman_client_st *client= (gearman_client_st *)object;
  454. ASSERT_TRUE(client);
  455. const char *worker_function= (const char *)gearman_client_context(client);
  456. ASSERT_TRUE(worker_function);
  457. size_t result_length;
  458. gearman_return_t rc;
  459. void *job_result= gearman_client_do(client, worker_function, NULL,
  460. test_literal_param("warning"),
  461. &result_length, &rc);
  462. ASSERT_NOT_NULL(job_result);
  463. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  464. test_memcmp("warning", job_result, result_length);
  465. free(job_result);
  466. return TEST_SUCCESS;
  467. }
  468. static test_return_t submit_fail_job_test(void *object)
  469. {
  470. gearman_client_st *client= (gearman_client_st *)object;
  471. ASSERT_TRUE(client);
  472. const char *worker_function= (const char *)gearman_client_context(client);
  473. ASSERT_TRUE(worker_function);
  474. size_t result_length;
  475. gearman_return_t rc;
  476. void *job_result= gearman_client_do(client, worker_function, NULL, "fail", 4,
  477. &result_length, &rc);
  478. ASSERT_EQ(GEARMAN_WORK_FAIL, rc);
  479. test_false(job_result);
  480. test_false(result_length);
  481. return TEST_SUCCESS;
  482. }
  483. static test_return_t submit_multiple_do(void *object)
  484. {
  485. for (uint32_t x= 0; x < 100 /* arbitrary */; x++)
  486. {
  487. libgearman::Client client((gearman_client_st *)object);
  488. gearman_client_set_context(&client, gearman_client_context((gearman_client_st *)object));
  489. uint32_t option= uint32_t(random() %3);
  490. switch (option)
  491. {
  492. case 0:
  493. ASSERT_EQ(TEST_SUCCESS, submit_null_job_test(&client));
  494. break;
  495. case 1:
  496. ASSERT_EQ(TEST_SUCCESS, submit_job_test(&client));
  497. break;
  498. default:
  499. case 2:
  500. ASSERT_EQ(TEST_SUCCESS, submit_exception_job_test(&client));
  501. break;
  502. }
  503. }
  504. return TEST_SUCCESS;
  505. }
  506. static test_return_t gearman_client_job_status_test(void *object)
  507. {
  508. gearman_client_st *client= (gearman_client_st *)object;
  509. ASSERT_TRUE(client);
  510. gearman_string_t value= { test_literal_param("background_test") };
  511. const char *worker_function= (const char *)gearman_client_context(client);
  512. ASSERT_TRUE(worker_function);
  513. gearman_job_handle_t job_handle;
  514. ASSERT_EQ(GEARMAN_SUCCESS,
  515. gearman_client_do_background(client, worker_function, NULL, gearman_string_param(value), job_handle));
  516. gearman_return_t ret;
  517. bool is_known;
  518. do
  519. {
  520. bool is_running;
  521. uint32_t numerator;
  522. uint32_t denominator;
  523. ASSERT_EQ(GEARMAN_SUCCESS,
  524. (ret= gearman_client_job_status(client, job_handle, &is_known, &is_running, &numerator, &denominator)));
  525. } while (gearman_continue(ret) and is_known);
  526. return TEST_SUCCESS;
  527. }
  528. static void* test_malloc_fn(size_t size, void *context)
  529. {
  530. bool *malloc_check= (bool *)context;
  531. *malloc_check= true;
  532. return malloc(size);
  533. }
  534. static void test_free_fn(void *ptr, void *context)
  535. {
  536. bool *free_check= (bool *)context;
  537. *free_check= true;
  538. free(ptr);
  539. }
  540. static test_return_t gearman_client_set_workload_malloc_fn_test(void *object)
  541. {
  542. gearman_client_st *client= (gearman_client_st *)object;
  543. ASSERT_TRUE(client);
  544. bool malloc_check= false;
  545. gearman_client_set_workload_malloc_fn(client, test_malloc_fn, &malloc_check);
  546. ASSERT_EQ(TEST_SUCCESS, submit_job_test(object));
  547. ASSERT_EQ(true, malloc_check);
  548. return TEST_SUCCESS;
  549. }
  550. static test_return_t gearman_client_set_workload_free_fn_test(void *object)
  551. {
  552. gearman_client_st *client= (gearman_client_st *)object;
  553. ASSERT_TRUE(client);
  554. bool free_check= false;
  555. gearman_client_set_workload_free_fn(client, test_free_fn, &free_check);
  556. ASSERT_EQ(TEST_SUCCESS, submit_job_test(object));
  557. ASSERT_EQ(true, free_check);
  558. return TEST_SUCCESS;
  559. }
  560. struct _alloc_test_st {
  561. int64_t count;
  562. int64_t total;
  563. _alloc_test_st():
  564. count(0),
  565. total(0)
  566. { }
  567. void add()
  568. {
  569. count++;
  570. total++;
  571. }
  572. void subtract()
  573. {
  574. count--;
  575. }
  576. bool success() // count is valid as 1 only with the current test
  577. {
  578. if (total and count == 1)
  579. {
  580. return true;
  581. }
  582. std::cerr << __func__ << ":" << __LINE__ << " Total:" << total << " Count:" << count << std::endl;
  583. return false;
  584. }
  585. };
  586. static void* test_malloc_count_fn(size_t size, void *context)
  587. {
  588. _alloc_test_st *_foo= (_alloc_test_st *)context;
  589. _foo->add();
  590. return malloc(size);
  591. }
  592. static void test_free_count_fn(void *ptr, void *context)
  593. {
  594. _alloc_test_st *_foo= (_alloc_test_st *)context;
  595. _foo->subtract();
  596. return free(ptr);
  597. }
  598. static test_return_t gearman_client_set_workload_allocators_test(void *object)
  599. {
  600. gearman_client_st *client= (gearman_client_st *)object;
  601. ASSERT_TRUE(client);
  602. _alloc_test_st _foo;
  603. gearman_client_set_workload_malloc_fn(client, test_malloc_count_fn, &_foo);
  604. gearman_client_set_workload_free_fn(client, test_free_count_fn, &_foo);
  605. ASSERT_EQ(TEST_SUCCESS, submit_job_test(object));
  606. ASSERT_TRUE(_foo.success());
  607. return TEST_SUCCESS;
  608. }
  609. static test_return_t gearman_client_job_status_with_return(void *object)
  610. {
  611. gearman_client_st *client= (gearman_client_st *)object;
  612. ASSERT_TRUE(client);
  613. gearman_string_t value= { test_literal_param("background_test") };
  614. const char *worker_function= (const char *)gearman_client_context(client);
  615. ASSERT_TRUE(worker_function);
  616. gearman_job_handle_t job_handle;
  617. ASSERT_EQ(GEARMAN_SUCCESS,
  618. gearman_client_do_background(client, worker_function, NULL, gearman_string_param(value), job_handle));
  619. gearman_return_t ret;
  620. do
  621. {
  622. uint32_t numerator;
  623. uint32_t denominator;
  624. ret= gearman_client_job_status(client, job_handle, NULL, NULL, &numerator, &denominator);
  625. } while (gearman_continue(ret));
  626. ASSERT_EQ(GEARMAN_SUCCESS, ret);
  627. return TEST_SUCCESS;
  628. }
  629. static test_return_t background_failure_test(void *object)
  630. {
  631. gearman_client_st *client= (gearman_client_st *)object;
  632. gearman_job_handle_t job_handle;
  633. bool is_known;
  634. bool is_running;
  635. uint32_t numerator;
  636. uint32_t denominator;
  637. gearman_return_t rc= gearman_client_do_background(client, "does_not_exist", NULL,
  638. test_literal_param("background_failure_test"),
  639. job_handle);
  640. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  641. do {
  642. rc= gearman_client_job_status(client, job_handle, &is_known, &is_running,
  643. &numerator, &denominator);
  644. ASSERT_TRUE(is_known == true and is_running == false and numerator == 0 and denominator == 0);
  645. } while (gearman_continue(rc)); // We do not test for is_known since the server will keep the job around until a worker comes along
  646. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  647. return TEST_SUCCESS;
  648. }
  649. static test_return_t add_servers_test(void *)
  650. {
  651. libgearman::Client client;
  652. ASSERT_EQ(GEARMAN_SUCCESS,
  653. gearman_client_add_servers(&client, "localhost:4730,localhost"));
  654. if (libtest::check_dns())
  655. {
  656. ASSERT_EQ(GEARMAN_GETADDRINFO,
  657. gearman_client_add_servers(&client, "www.google.com:7003,does_not_exist.google.com:12345"));
  658. }
  659. return TEST_SUCCESS;
  660. }
  661. static test_return_t hostname_resolution(void *)
  662. {
  663. test_skip_valgrind();
  664. libgearman::Client client;
  665. test_skip(GEARMAN_SUCCESS, gearman_client_add_servers(&client, "exist.gearman.info:12345"));
  666. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_error_code(&client));
  667. #if defined(__FreeBSD__) && __FreeBSD__
  668. ASSERT_EQ(GEARMAN_TIMEOUT,
  669. gearman_client_echo(&client, test_literal_param("foo")));
  670. #else
  671. ASSERT_EQ(GEARMAN_COULD_NOT_CONNECT,
  672. gearman_client_echo(&client, test_literal_param("foo")));
  673. #endif
  674. return TEST_SUCCESS;
  675. }
  676. static test_return_t gearman_client_st_id_t_TEST(gearman_client_st*)
  677. {
  678. return TEST_SKIPPED;
  679. // @todo, test the internal value of client, no API is available for this
  680. // right now.
  681. #if 0
  682. gearman_client_st *client= gearman_client_create(NULL);
  683. ASSERT_TRUE(client);
  684. ASSERT_EQ(false, gearman_id_valid(client));
  685. gearman_client_free(client);
  686. return TEST_SUCCESS;
  687. #endif
  688. }
  689. static test_return_t gearman_worker_st_id_t_TEST(gearman_client_st*)
  690. {
  691. gearman_worker_st *worker= gearman_worker_create(NULL);
  692. ASSERT_TRUE(worker);
  693. gearman_id_t id= gearman_worker_id(worker);
  694. ASSERT_EQ(true, gearman_id_valid(id));
  695. gearman_worker_free(worker);
  696. return TEST_SUCCESS;
  697. }
  698. static test_return_t bug_518512_test(void *)
  699. {
  700. size_t result_size;
  701. libgearman::Client client(libtest::default_port());
  702. gearman_client_set_timeout(&client, 0);
  703. gearman_return_t rc;
  704. void *result= gearman_client_do(&client, "client_test_temp", NULL, NULL, 0,
  705. &result_size, &rc);
  706. ASSERT_EQ(GEARMAN_TIMEOUT, rc);
  707. test_false(result);
  708. test_zero(result_size);
  709. gearman_function_t func_arg= gearman_function_create_v1(client_test_temp_worker);
  710. std::unique_ptr<worker_handle_st> completion_worker(test_worker_start(libtest::default_port(), NULL, "client_test_temp",
  711. func_arg, NULL, gearman_worker_options_t()));
  712. libgearman::Client client2(libtest::default_port());
  713. gearman_client_set_timeout(&client2, -1);
  714. result= gearman_client_do(&client2, "client_test_temp", NULL, NULL, 0,
  715. &result_size, &rc);
  716. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  717. test_false(result);
  718. test_zero(result_size);
  719. return TEST_SUCCESS;
  720. }
  721. #define NUMBER_OF_WORKERS 2
  722. static test_return_t loop_test(void *)
  723. {
  724. pthread_t one;
  725. pthread_t two;
  726. struct worker_handle_st *handles[NUMBER_OF_WORKERS];
  727. gearman_function_t func_arg= gearman_function_create_v1(client_test_temp_worker);
  728. for (size_t x= 0; x < NUMBER_OF_WORKERS; x++)
  729. {
  730. handles[x]= test_worker_start(libtest::default_port(), NULL, "client_test_temp",
  731. func_arg, NULL, gearman_worker_options_t());
  732. }
  733. gearman_return_t one_rc= GEARMAN_SUCCESS;
  734. pthread_create(&one, NULL, client_thread, &one_rc);
  735. gearman_return_t two_rc= GEARMAN_SUCCESS;
  736. pthread_create(&two, NULL, client_thread, &two_rc);
  737. void *unused;
  738. pthread_join(one, &unused);
  739. pthread_join(two, &unused);
  740. for (size_t x= 0; x < NUMBER_OF_WORKERS; x++)
  741. {
  742. delete handles[x];
  743. }
  744. ASSERT_EQ(GEARMAN_SUCCESS, one_rc);
  745. ASSERT_EQ(GEARMAN_SUCCESS, two_rc);
  746. return TEST_SUCCESS;
  747. }
  748. static test_return_t regression_785203_do_test(void *)
  749. {
  750. libgearman::Client client(libtest::default_port());
  751. gearman_client_add_options(&client, GEARMAN_CLIENT_FREE_TASKS);
  752. { // All defaults, except timeout_return
  753. ASSERT_TRUE(gearman_is_allocated(&client));
  754. test_false((&client)->impl()->options.non_blocking);
  755. test_false((&client)->impl()->options.unbuffered_result);
  756. test_false((&client)->impl()->options.no_new);
  757. ASSERT_TRUE((&client)->impl()->options.free_tasks);
  758. }
  759. gearman_function_t func= gearman_function_create_v2(echo_or_react_worker_v2);
  760. std::unique_ptr<worker_handle_st> handle(test_worker_start(libtest::default_port(), NULL,
  761. __func__,
  762. func, NULL, gearman_worker_options_t()));
  763. gearman_return_t rc;
  764. size_t result_length;
  765. void *result= gearman_client_do(&client, __func__, NULL,
  766. test_literal_param("keep it rocking and sing"),
  767. &result_length, &rc);
  768. ASSERT_TRUE(result);
  769. free(result);
  770. return TEST_SUCCESS;
  771. }
  772. static test_return_t regression_785203_do_background_test(void *object)
  773. {
  774. gearman_client_st *original_client= (gearman_client_st *)object;
  775. ASSERT_TRUE(original_client);
  776. gearman_function_t echo_react_chunk_fn_v2= gearman_function_create_v2(echo_or_react_worker_v2);
  777. std::unique_ptr<worker_handle_st> handle(test_worker_start(libtest::default_port(), NULL,
  778. __func__,
  779. echo_react_chunk_fn_v2, NULL, gearman_worker_options_t()));
  780. libgearman::Client client(libtest::default_port());
  781. gearman_client_add_options(&client, GEARMAN_CLIENT_FREE_TASKS);
  782. { // All defaults, except timeout_return
  783. ASSERT_TRUE(gearman_is_allocated((&client)));
  784. test_false((&client)->impl()->options.non_blocking);
  785. test_false((&client)->impl()->options.unbuffered_result);
  786. test_false((&client)->impl()->options.no_new);
  787. ASSERT_TRUE((&client)->impl()->options.free_tasks);
  788. }
  789. gearman_job_handle_t job_handle;
  790. ASSERT_EQ(GEARMAN_SUCCESS,
  791. gearman_client_do_background(&client, __func__,
  792. NULL, // No unique requested
  793. test_literal_param("keep it rocking and sing"),
  794. job_handle));
  795. gearman_return_t ret;
  796. do
  797. {
  798. uint32_t numerator;
  799. uint32_t denominator;
  800. ret= gearman_client_job_status(&client, job_handle, NULL, NULL, &numerator, &denominator);
  801. } while (gearman_continue(ret));
  802. ASSERT_EQ(GEARMAN_SUCCESS, ret);
  803. return TEST_SUCCESS;
  804. }
  805. static test_return_t regression2_TEST(void *)
  806. {
  807. libgearman::Client client;
  808. size_t result_length;
  809. gearman_return_t rc;
  810. void *job_result= gearman_client_do(&client,
  811. __func__, // Worker does not exist.
  812. NULL, // no unique
  813. test_literal_param("submit_log_failure"),
  814. &result_length, &rc);
  815. ASSERT_EQ(GEARMAN_NO_SERVERS, rc);
  816. test_false(job_result);
  817. test_zero(result_length);
  818. return TEST_SUCCESS;
  819. }
  820. static test_return_t gearman_worker_timeout_TEST(void *object)
  821. {
  822. gearman_client_st *client= (gearman_client_st *)object;
  823. ASSERT_TRUE(client);
  824. gearman_function_t dreaming_fn= gearman_function_create(echo_or_react_worker_v2);
  825. std::unique_ptr<worker_handle_st> worker_handle(test_worker_start(libtest::default_port(), NULL,
  826. __func__,
  827. dreaming_fn, NULL,
  828. gearman_worker_options_t(),
  829. 0));
  830. /*
  831. The client should get a timeout since the "sleeper" will sleep longer then the timeout.
  832. */
  833. size_t result_length;
  834. gearman_return_t rc;
  835. void *job_result= gearman_client_do(client,
  836. __func__, // Our sleeper function
  837. NULL, // No unique
  838. gearman_literal_param("sleep"), // We send "sleep" to tell the sleeper to sleep
  839. &result_length, &rc);
  840. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  841. ASSERT_TRUE(job_result);
  842. ASSERT_EQ(sizeof("slept") -1, result_length);
  843. test_memcmp("slept", job_result, 5);
  844. free(job_result);
  845. return TEST_SUCCESS;
  846. }
  847. static test_return_t gearman_worker_timeout_TIMEOUT_TEST(void *object)
  848. {
  849. // This test currently takes to long.
  850. test_skip_valgrind();
  851. gearman_client_st *client= (gearman_client_st *)object;
  852. ASSERT_TRUE(client);
  853. ASSERT_TRUE(ECHO_OR_REACT_DREAM);
  854. int timeout= ECHO_OR_REACT_DREAM/4;
  855. gearman_function_t dreaming_fn= gearman_function_create(echo_or_react_worker_v2);
  856. std::unique_ptr<worker_handle_st> worker_handle(test_worker_start(libtest::default_port(), NULL,
  857. __func__,
  858. dreaming_fn, NULL,
  859. gearman_worker_options_t(),
  860. timeout));
  861. /*
  862. The client should get a timeout since the "sleeper" will sleep longer then the timeout.
  863. */
  864. size_t result_length;
  865. gearman_return_t rc;
  866. void *job_result= gearman_client_do(client,
  867. __func__, // Our sleeper function
  868. NULL, // No unique
  869. gearman_literal_param("sleep"), // We send "sleep" to tell the sleeper to sleep
  870. &result_length, &rc);
  871. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  872. ASSERT_TRUE(job_result);
  873. ASSERT_EQ(sizeof("slept") -1, result_length);
  874. test_memcmp("slept", job_result, 5);
  875. free(job_result);
  876. return TEST_SUCCESS;
  877. }
  878. static test_return_t regression_975591_TEST(void *object)
  879. {
  880. gearman_client_st *client= (gearman_client_st *)object;
  881. ASSERT_TRUE(client);
  882. gearman_function_t dreaming_fn= gearman_function_create(echo_or_react_worker_v2);
  883. std::unique_ptr<worker_handle_st> worker_handle(test_worker_start(libtest::default_port(), NULL,
  884. __func__,
  885. dreaming_fn, NULL,
  886. gearman_worker_options_t(),
  887. 0));
  888. size_t payload_size[] = { 100, 1000, 10000, 1000000, 1000000, 0 };
  889. libtest::vchar_t payload;
  890. for (size_t *ptr= payload_size; *ptr; ptr++)
  891. {
  892. payload.reserve(*ptr);
  893. for (size_t x= payload.size(); x < *ptr; x++)
  894. {
  895. payload.push_back(rand());
  896. }
  897. size_t result_length;
  898. gearman_return_t rc;
  899. char *job_result= (char*)gearman_client_do(client, __func__,
  900. NULL,
  901. &payload[0], payload.size(),
  902. &result_length, &rc);
  903. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  904. ASSERT_EQ(payload.size(), result_length);
  905. test_memcmp(&payload[0], job_result, result_length);
  906. free(job_result);
  907. }
  908. return TEST_SUCCESS;
  909. }
  910. static void log_counter(const char *line, gearman_verbose_t verbose,
  911. void *context)
  912. {
  913. uint32_t *counter= (uint32_t *)context;
  914. (void)verbose;
  915. (void)line;
  916. *counter= *counter + 1;
  917. }
  918. static test_return_t submit_log_failure_TEST(void *object)
  919. {
  920. gearman_client_st *client= (gearman_client_st *)object;
  921. ASSERT_TRUE(client);
  922. gearman_string_t value= { test_literal_param("submit_log_failure") };
  923. gearman_log_fn *func= log_counter;
  924. uint32_t global_counter= 0;
  925. gearman_client_set_log_fn(client, func, &global_counter, GEARMAN_VERBOSE_MAX);
  926. test_null(client->impl()->universal.con_list);
  927. const char *worker_function= (const char *)gearman_client_context(client);
  928. ASSERT_TRUE(worker_function);
  929. size_t result_length;
  930. gearman_return_t rc;
  931. test_null(client->impl()->task);
  932. void *job_result= gearman_client_do(client, worker_function, NULL,
  933. gearman_string_param(value),
  934. &result_length, &rc);
  935. ASSERT_EQ(GEARMAN_NO_SERVERS, rc);
  936. test_false(job_result);
  937. test_zero(result_length);
  938. test_null(client->impl()->task);
  939. ASSERT_TRUE(global_counter);
  940. return TEST_SUCCESS;
  941. }
  942. static test_return_t strerror_count(void *)
  943. {
  944. ASSERT_EQ((int)GEARMAN_MAX_RETURN, 53);
  945. return TEST_SUCCESS;
  946. }
  947. #undef MAKE_NEW_STRERROR
  948. static test_return_t strerror_strings(void *)
  949. {
  950. uint32_t values[]= {
  951. 2723107532U, 1294272985U, 949848612U, 646434617U,
  952. 2273096667U, 3411376012U, 978198404U, 2644287234U,
  953. 1762137345U, 1727436301U, 1103093142U, 2958899803U,
  954. 3844590487U, 3520316764U, 3288532333U, 697573278U,
  955. 2328987341U, 1321921098U, 1475770122U, 4011631587U,
  956. 2468981698U, 2935753385U, 884320816U, 3006705975U,
  957. 2840498210U, 2953034368U, 501858685U, 1635925784U,
  958. 880765771U, 15612712U, 1489284002U, 2968621609U,
  959. 79936336U, 3059874010U, 3562217099U, 13337402U,
  960. 132823274U, 3950859856U, 237150774U, 290535510U,
  961. 2101976744U, 2262698284U, 3182950564U, 2391595326U,
  962. 1764731897U, 3485422815U, 99607280U, 2348849961U,
  963. 607991020U, 1597605008U, 1377573125U, 723914800U, 3144965656U };
  964. for (int rc= GEARMAN_SUCCESS; rc < GEARMAN_MAX_RETURN; rc++)
  965. {
  966. uint32_t hash_val;
  967. const char *msg= gearman_strerror((gearman_return_t)rc);
  968. hash_val= internal_generate_hash(msg, strlen(msg));
  969. ASSERT_EQ_(values[rc], hash_val, "New Value for %s at %d: %uU\n", msg, rc, hash_val);
  970. }
  971. return TEST_SUCCESS;
  972. }
  973. #define REGRESSION_FUNCTION_833394_54 "54_char_function_name________________________________"
  974. #define REGRESSION_FUNCTION_833394_55 "55_char_function_name_________________________________"
  975. #define REGRESSION_FUNCTION_833394_65 "65_char_function_name___________________________________________"
  976. static test_return_t regression_833394_test(void *object)
  977. {
  978. gearman_client_st *client= (gearman_client_st *)object;
  979. gearman_function_t echo_react_chunk_fn_v2= gearman_function_create_v2(echo_or_react_worker_v2);
  980. std::unique_ptr<worker_handle_st> handle(test_worker_start(libtest::default_port(), NULL, REGRESSION_FUNCTION_833394_54, echo_react_chunk_fn_v2, NULL, gearman_worker_options_t()));
  981. std::unique_ptr<worker_handle_st> handle1(test_worker_start(libtest::default_port(), NULL, REGRESSION_FUNCTION_833394_55, echo_react_chunk_fn_v2, NULL, gearman_worker_options_t()));
  982. std::unique_ptr<worker_handle_st> handle2(test_worker_start(libtest::default_port(), NULL, REGRESSION_FUNCTION_833394_65, echo_react_chunk_fn_v2, NULL, gearman_worker_options_t()));
  983. for (size_t x= 0; x < 100; x++)
  984. {
  985. ASSERT_TRUE(client);
  986. size_t result_length;
  987. gearman_return_t rc;
  988. char *job_result= (char*)gearman_client_do(client, REGRESSION_FUNCTION_833394_54,
  989. NULL,
  990. test_literal_param("this should be echo'ed"),
  991. &result_length, &rc);
  992. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  993. ASSERT_TRUE(job_result);
  994. ASSERT_EQ(test_literal_param_size("this should be echo'ed"), result_length);
  995. free(job_result);
  996. }
  997. for (size_t x= 0; x < 100; x++)
  998. {
  999. ASSERT_TRUE(client);
  1000. size_t result_length;
  1001. gearman_return_t rc;
  1002. char *job_result= (char*)gearman_client_do(client, REGRESSION_FUNCTION_833394_55,
  1003. NULL,
  1004. test_literal_param("this should be echo'ed"),
  1005. &result_length, &rc);
  1006. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  1007. ASSERT_TRUE(job_result);
  1008. ASSERT_EQ(test_literal_param_size("this should be echo'ed"), result_length);
  1009. free(job_result);
  1010. }
  1011. for (size_t x= 0; x < 100; x++)
  1012. {
  1013. ASSERT_TRUE(client);
  1014. size_t result_length;
  1015. gearman_return_t rc;
  1016. char *job_result= (char*)gearman_client_do(client, REGRESSION_FUNCTION_833394_65,
  1017. NULL,
  1018. test_literal_param("this should be echo'ed"),
  1019. &result_length, &rc);
  1020. ASSERT_EQ(GEARMAN_SUCCESS, rc);
  1021. ASSERT_TRUE(job_result);
  1022. ASSERT_EQ(test_literal_param_size("this should be echo'ed"), result_length);
  1023. free(job_result);
  1024. }
  1025. return TEST_SUCCESS;
  1026. }
  1027. static test_return_t GEARMAN_SUCCESS_TEST(void*)
  1028. {
  1029. ASSERT_EQ(0, int(GEARMAN_SUCCESS));
  1030. return TEST_SUCCESS;
  1031. }
  1032. static test_return_t GEARMAN_FAIL_COMPAT_TEST(void*)
  1033. {
  1034. ASSERT_EQ(GEARMAN_FAIL, GEARMAN_FATAL);
  1035. ASSERT_EQ(GEARMAN_FAIL, GEARMAN_WORK_FAIL);
  1036. return TEST_SUCCESS;
  1037. }
  1038. static test_return_t GEARMAN_ERROR_COMPAT_TEST(void*)
  1039. {
  1040. ASSERT_EQ(GEARMAN_ERROR, GEARMAN_WORK_ERROR);
  1041. return TEST_SUCCESS;
  1042. }
  1043. static test_return_t gearman_client_set_identifier_TEST(void* object)
  1044. {
  1045. gearman_client_st *client= (gearman_client_st *)object;
  1046. ASSERT_EQ(GEARMAN_SUCCESS,
  1047. gearman_client_set_identifier(client, test_literal_param(__func__)));
  1048. return TEST_SUCCESS;
  1049. }
  1050. static test_return_t gearman_client_set_identifier_plus_work_TEST(void* object)
  1051. {
  1052. ASSERT_EQ(TEST_SUCCESS, gearman_client_set_identifier_TEST(object));
  1053. ASSERT_EQ(TEST_SUCCESS, regression_833394_test(object));
  1054. return TEST_SUCCESS;
  1055. }
  1056. static test_return_t gearman_client_set_identifier_plus_random_TEST(void* object)
  1057. {
  1058. for (size_t x= 0; x < 10; x++)
  1059. {
  1060. switch (random() %3)
  1061. {
  1062. case 0:
  1063. ASSERT_EQ(TEST_SUCCESS, gearman_client_set_identifier_TEST(object));
  1064. break;
  1065. case 1:
  1066. ASSERT_EQ(TEST_SUCCESS, regression_833394_test(object));
  1067. break;
  1068. default:
  1069. ASSERT_EQ(TEST_SUCCESS, regression_975591_TEST(object));
  1070. }
  1071. }
  1072. return TEST_SUCCESS;
  1073. }
  1074. static test_return_t gearman_client_cancel_job_TEST(void* object)
  1075. {
  1076. gearman_client_st *client= (gearman_client_st *)object;
  1077. gearman_job_handle_t job_handle;
  1078. strcpy(job_handle, __func__);
  1079. // For the moment we won't test the return value since this will change once
  1080. // we formalize the behavior.
  1081. test_compare(GEARMAN_JOB_NOT_FOUND, gearman_client_cancel_job(client, job_handle));
  1082. return TEST_SUCCESS;
  1083. }
  1084. static test_return_t gearman_client_free_TEST(void *)
  1085. {
  1086. gearman_client_free(NULL);
  1087. return TEST_SUCCESS;
  1088. }
  1089. static test_return_t gearman_client_error_TEST(void *)
  1090. {
  1091. test_null(gearman_client_error(NULL));
  1092. return TEST_SUCCESS;
  1093. }
  1094. static test_return_t gearman_client_error_no_error_TEST(void *)
  1095. {
  1096. libgearman::Client client;
  1097. test_null(gearman_client_error(&client));
  1098. return TEST_SUCCESS;
  1099. }
  1100. static test_return_t gearman_client_errno_TEST(void *)
  1101. {
  1102. ASSERT_EQ(EINVAL, gearman_client_errno(NULL));
  1103. return TEST_SUCCESS;
  1104. }
  1105. static test_return_t gearman_client_errno_no_error_TEST(void *)
  1106. {
  1107. libgearman::Client client;
  1108. ASSERT_EQ(0, gearman_client_errno(&client));
  1109. return TEST_SUCCESS;
  1110. }
  1111. static test_return_t gearman_client_options_SSL_TEST(void *)
  1112. {
  1113. libgearman::Client client;
  1114. ASSERT_FALSE(gearman_client_has_option(&client, GEARMAN_CLIENT_SSL));
  1115. gearman_client_add_options(&client, GEARMAN_CLIENT_SSL);
  1116. ASSERT_TRUE(gearman_client_has_option(&client, GEARMAN_CLIENT_SSL));
  1117. return TEST_SUCCESS;
  1118. }
  1119. static test_return_t gearman_client_options_TEST(void *)
  1120. {
  1121. ASSERT_EQ(gearman_client_options_t(), gearman_client_options(NULL));
  1122. return TEST_SUCCESS;
  1123. }
  1124. static test_return_t __SETUP(client_test_st* test, const gearman_function_t& echo_react_fn)
  1125. {
  1126. ASSERT_TRUE(test);
  1127. test->set_worker_name(WORKER_FUNCTION_NAME);
  1128. test->push(test_worker_start(libtest::default_port(),
  1129. test->session_namespace(),
  1130. test->worker_name(),
  1131. echo_react_fn, NULL, gearman_worker_options_t()));
  1132. return TEST_SUCCESS;
  1133. }
  1134. static test_return_t chunk_v1_SETUP(void *object)
  1135. {
  1136. gearman_function_t echo_react_chunk_fn= gearman_function_create_v1(echo_or_react_chunk_worker);
  1137. ASSERT_EQ(TEST_SUCCESS, __SETUP((client_test_st *)object, echo_react_chunk_fn));
  1138. return TEST_SUCCESS;
  1139. }
  1140. static test_return_t chunk_v2_SETUP(void *object)
  1141. {
  1142. gearman_function_t echo_react_chunk_fn= gearman_function_create_v2(echo_or_react_chunk_worker_v2);
  1143. ASSERT_EQ(TEST_SUCCESS, __SETUP((client_test_st *)object, echo_react_chunk_fn));
  1144. return TEST_SUCCESS;
  1145. }
  1146. static test_return_t reset_SETUP(void *object)
  1147. {
  1148. client_test_st* test= (client_test_st *)object;
  1149. test->reset_clone();
  1150. return TEST_SUCCESS;
  1151. }
  1152. static test_return_t default_v2_SETUP(void *object)
  1153. {
  1154. gearman_function_t echo_react_fn= gearman_function_create_v2(echo_or_react_worker_v2);
  1155. ASSERT_EQ(TEST_SUCCESS, __SETUP((client_test_st *)object, echo_react_fn));
  1156. return TEST_SUCCESS;
  1157. }
  1158. static test_return_t GEARMAN_CLIENT_GENERATE_UNIQUE_SETUP(void *object)
  1159. {
  1160. client_test_st* test= (client_test_st *)object;
  1161. ASSERT_TRUE(test);
  1162. ASSERT_EQ(TEST_SUCCESS, default_v2_SETUP(object));
  1163. gearman_client_remove_options(test->client(), GEARMAN_CLIENT_GENERATE_UNIQUE);
  1164. test_false(gearman_client_has_option(test->client(), GEARMAN_CLIENT_GENERATE_UNIQUE));
  1165. return TEST_SUCCESS;
  1166. }
  1167. static test_return_t gearman_client_add_server_localhost_TEST(void*)
  1168. {
  1169. libgearman::Client client;
  1170. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_add_server(&client, "localhost", libtest::default_port()));
  1171. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_echo(&client, test_literal_param(__func__)));
  1172. return TEST_SUCCESS;
  1173. }
  1174. static test_return_t gearman_client_add_server_empty_quote_TEST(void*)
  1175. {
  1176. libgearman::Client client;
  1177. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_add_server(&client, "", libtest::default_port()));
  1178. ASSERT_EQ(GEARMAN_SUCCESS, gearman_client_echo(&client, test_literal_param(__func__)));
  1179. return TEST_SUCCESS;
  1180. }
  1181. static test_return_t gearman_client_create_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1182. {
  1183. gearman_client_st* clone;
  1184. ASSERT_TRUE((clone= gearman_client_create(NULL)));
  1185. gearman_client_free(clone);
  1186. return TEST_SUCCESS;
  1187. }
  1188. static test_return_t gearman_client_clone_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1189. {
  1190. gearman_client_st* clone;
  1191. ASSERT_TRUE((clone= gearman_client_clone(NULL, NULL)));
  1192. gearman_client_free(clone);
  1193. return TEST_SUCCESS;
  1194. }
  1195. static test_return_t gearman_client_free_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1196. {
  1197. gearman_client_free(NULL);
  1198. return TEST_SUCCESS;
  1199. }
  1200. static test_return_t gearman_client_error_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1201. {
  1202. ASSERT_EQ(NULL, gearman_client_error(NULL));
  1203. return TEST_SUCCESS;
  1204. }
  1205. static test_return_t gearman_client_error_code_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1206. {
  1207. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_error_code(NULL));
  1208. return TEST_SUCCESS;
  1209. }
  1210. static test_return_t gearman_client_options_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1211. {
  1212. ASSERT_EQ(gearman_client_options_t(GEARMAN_WORKER_MAX), gearman_client_options(NULL));
  1213. return TEST_SUCCESS;
  1214. }
  1215. static test_return_t gearman_client_has_option_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1216. {
  1217. ASSERT_EQ(false, gearman_client_has_option(NULL, GEARMAN_CLIENT_GENERATE_UNIQUE));
  1218. return TEST_SUCCESS;
  1219. }
  1220. static test_return_t gearman_client_set_options_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1221. {
  1222. // Hopefile valgrind will catch any issues that might crop up here
  1223. gearman_client_set_options(NULL, GEARMAN_CLIENT_GENERATE_UNIQUE);
  1224. return TEST_SUCCESS;
  1225. }
  1226. static test_return_t gearman_client_add_options_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1227. {
  1228. // Hopefile valgrind will catch any issues that might crop up here
  1229. gearman_client_add_options(NULL, GEARMAN_CLIENT_GENERATE_UNIQUE);
  1230. return TEST_SUCCESS;
  1231. }
  1232. static test_return_t gearman_client_remove_options_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1233. {
  1234. // Hopefile valgrind will catch any issues that might crop up here
  1235. gearman_client_remove_options(NULL, GEARMAN_CLIENT_GENERATE_UNIQUE);
  1236. return TEST_SUCCESS;
  1237. }
  1238. static test_return_t gearman_client_timeout_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1239. {
  1240. ASSERT_EQ(-1, gearman_client_timeout(NULL));
  1241. return TEST_SUCCESS;
  1242. }
  1243. static test_return_t gearman_client_set_timeout_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1244. {
  1245. gearman_client_set_timeout(NULL, 23);
  1246. return TEST_SUCCESS;
  1247. }
  1248. static test_return_t gearman_client_context_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1249. {
  1250. ASSERT_EQ(NULL, gearman_client_context(NULL));
  1251. return TEST_SUCCESS;
  1252. }
  1253. static test_return_t gearman_client_set_context_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1254. {
  1255. gearman_client_set_context(NULL, NULL);
  1256. return TEST_SUCCESS;
  1257. }
  1258. static test_return_t gearman_client_set_log_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1259. {
  1260. gearman_client_set_log_fn(NULL, NULL, NULL, GEARMAN_VERBOSE_FATAL);
  1261. return TEST_SUCCESS;
  1262. }
  1263. static test_return_t gearman_client_set_workload_malloc_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1264. {
  1265. gearman_client_set_workload_malloc_fn(NULL, NULL, NULL);
  1266. return TEST_SUCCESS;
  1267. }
  1268. static test_return_t gearman_client_set_workload_free_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1269. {
  1270. gearman_client_set_workload_free_fn(NULL, NULL, NULL);
  1271. return TEST_SUCCESS;
  1272. }
  1273. static test_return_t gearman_client_set_memory_allocators_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1274. {
  1275. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_set_memory_allocators(NULL, NULL, NULL, NULL, NULL, NULL));
  1276. return TEST_SUCCESS;
  1277. }
  1278. static test_return_t gearman_client_add_server_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1279. {
  1280. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_add_server(NULL, NULL, 0));
  1281. return TEST_SUCCESS;
  1282. }
  1283. static test_return_t gearman_client_remove_servers_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1284. {
  1285. gearman_client_remove_servers(NULL);
  1286. return TEST_SUCCESS;
  1287. }
  1288. static test_return_t gearman_client_wait_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1289. {
  1290. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_wait(NULL));
  1291. return TEST_SUCCESS;
  1292. }
  1293. static test_return_t gearman_client_do_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1294. {
  1295. gearman_return_t ret;
  1296. ASSERT_EQ(NULL, gearman_client_do(NULL, NULL, NULL, NULL, 0, NULL, &ret));
  1297. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1298. return TEST_SUCCESS;
  1299. }
  1300. static test_return_t gearman_client_do_low_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1301. {
  1302. gearman_return_t ret;
  1303. ASSERT_EQ(NULL, gearman_client_do_low(NULL, NULL, NULL, NULL, 0, NULL, &ret));
  1304. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1305. return TEST_SUCCESS;
  1306. }
  1307. static test_return_t gearman_client_do_high_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1308. {
  1309. gearman_return_t ret;
  1310. ASSERT_EQ(NULL, gearman_client_do_high(NULL, NULL, NULL, NULL, 0, NULL, &ret));
  1311. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1312. return TEST_SUCCESS;
  1313. }
  1314. static test_return_t gearman_client_do_job_handle_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1315. {
  1316. ASSERT_EQ(NULL, gearman_client_do_job_handle(NULL));
  1317. return TEST_SUCCESS;
  1318. }
  1319. static test_return_t gearman_client_do_background_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1320. {
  1321. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_do_background(NULL, NULL, NULL, NULL, 0, NULL));
  1322. return TEST_SUCCESS;
  1323. }
  1324. static test_return_t gearman_client_do_low_background_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1325. {
  1326. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_do_low_background(NULL, NULL, NULL, NULL, 0, NULL));
  1327. return TEST_SUCCESS;
  1328. }
  1329. static test_return_t gearman_client_job_status_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1330. {
  1331. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_job_status(NULL, NULL, NULL, NULL, NULL, NULL));
  1332. return TEST_SUCCESS;
  1333. }
  1334. static test_return_t gearman_client_unique_status_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1335. {
  1336. gearman_status_t status= gearman_client_unique_status(NULL, NULL, 0);
  1337. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_status_return(status));
  1338. return TEST_SUCCESS;
  1339. }
  1340. static test_return_t gearman_client_do_high_background_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1341. {
  1342. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_do_high_background(NULL, NULL, NULL, NULL, 0, NULL));
  1343. return TEST_SUCCESS;
  1344. }
  1345. static test_return_t gearman_client_add_task_status_by_unique_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1346. {
  1347. gearman_return_t ret;
  1348. ASSERT_EQ(NULL, gearman_client_add_task_status_by_unique(NULL, NULL, NULL, &ret));
  1349. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1350. return TEST_SUCCESS;
  1351. }
  1352. static test_return_t gearman_client_echo_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1353. {
  1354. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_echo(NULL, NULL, 0));
  1355. return TEST_SUCCESS;
  1356. }
  1357. static test_return_t gearman_client_task_free_all_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1358. {
  1359. gearman_client_task_free_all(NULL);
  1360. return TEST_SUCCESS;
  1361. }
  1362. static test_return_t gearman_client_set_task_context_free_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1363. {
  1364. gearman_client_set_task_context_free_fn(NULL, NULL);
  1365. return TEST_SUCCESS;
  1366. }
  1367. static test_return_t gearman_client_add_task_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1368. {
  1369. gearman_return_t ret;
  1370. ASSERT_EQ(NULL, gearman_client_add_task(NULL, NULL, NULL, NULL, NULL, NULL, 0, &ret));
  1371. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1372. return TEST_SUCCESS;
  1373. }
  1374. static test_return_t gearman_client_add_task_high_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1375. {
  1376. gearman_return_t ret;
  1377. ASSERT_EQ(NULL, gearman_client_add_task_high(NULL, NULL, NULL, NULL, NULL, NULL, 0, &ret));
  1378. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1379. return TEST_SUCCESS;
  1380. }
  1381. static test_return_t gearman_client_add_task_low_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1382. {
  1383. gearman_return_t ret;
  1384. ASSERT_EQ(NULL, gearman_client_add_task_low(NULL, NULL, NULL, NULL, NULL, NULL, 0, &ret));
  1385. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1386. return TEST_SUCCESS;
  1387. }
  1388. static test_return_t gearman_client_add_task_background_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1389. {
  1390. gearman_return_t ret;
  1391. ASSERT_EQ(NULL, gearman_client_add_task_background(NULL, NULL, NULL, NULL, NULL, NULL, 0, &ret));
  1392. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1393. return TEST_SUCCESS;
  1394. }
  1395. static test_return_t gearman_client_add_task_high_background_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1396. {
  1397. gearman_return_t ret;
  1398. ASSERT_EQ(NULL, gearman_client_add_task_high_background(NULL, NULL, NULL, NULL, NULL, NULL, 0, &ret));
  1399. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1400. return TEST_SUCCESS;
  1401. }
  1402. static test_return_t gearman_client_add_task_low_background_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1403. {
  1404. gearman_return_t ret;
  1405. ASSERT_EQ(NULL, gearman_client_add_task_low_background(NULL, NULL, NULL, NULL, NULL, NULL, 0, &ret));
  1406. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1407. return TEST_SUCCESS;
  1408. }
  1409. static test_return_t gearman_client_add_task_status_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1410. {
  1411. gearman_return_t ret;
  1412. ASSERT_EQ(NULL, gearman_client_add_task_status(NULL, NULL, NULL, NULL, &ret));
  1413. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1414. return TEST_SUCCESS;
  1415. }
  1416. static test_return_t gearman_client_set_workload_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1417. {
  1418. gearman_client_set_workload_fn(NULL, NULL);
  1419. return TEST_SUCCESS;
  1420. }
  1421. static test_return_t gearman_client_set_created_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1422. {
  1423. gearman_client_set_created_fn(NULL, NULL);
  1424. return TEST_SUCCESS;
  1425. }
  1426. static test_return_t gearman_client_set_status_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1427. {
  1428. gearman_client_set_status_fn(NULL, NULL);
  1429. return TEST_SUCCESS;
  1430. }
  1431. static test_return_t gearman_client_clear_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1432. {
  1433. gearman_client_clear_fn(NULL);
  1434. return TEST_SUCCESS;
  1435. }
  1436. static test_return_t gearman_client_set_fail_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1437. {
  1438. gearman_client_set_fail_fn(NULL, NULL);
  1439. return TEST_SUCCESS;
  1440. }
  1441. static test_return_t gearman_client_set_complete_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1442. {
  1443. gearman_client_set_complete_fn(NULL, NULL);
  1444. return TEST_SUCCESS;
  1445. }
  1446. static test_return_t gearman_client_set_exception_fn_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1447. {
  1448. gearman_client_set_exception_fn(NULL, NULL);
  1449. return TEST_SUCCESS;
  1450. }
  1451. static test_return_t gearman_client_run_tasks_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1452. {
  1453. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_run_tasks(NULL));
  1454. return TEST_SUCCESS;
  1455. }
  1456. static test_return_t gearman_client_compare_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1457. {
  1458. ASSERT_EQ(false, gearman_client_compare(NULL, NULL));
  1459. return TEST_SUCCESS;
  1460. }
  1461. static test_return_t gearman_client_set_identifier_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1462. {
  1463. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_client_set_identifier(NULL, NULL, 0));
  1464. return TEST_SUCCESS;
  1465. }
  1466. static test_return_t gearman_client_set_namespace_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1467. {
  1468. gearman_client_set_namespace(NULL, NULL, 0);
  1469. return TEST_SUCCESS;
  1470. }
  1471. static test_return_t gearman_client_set_server_option_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1472. {
  1473. gearman_client_set_namespace(NULL, NULL, 0);
  1474. return TEST_SUCCESS;
  1475. }
  1476. static test_return_t gearman_task_free_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1477. {
  1478. gearman_task_free(NULL);
  1479. return TEST_SUCCESS;
  1480. }
  1481. static test_return_t gearman_task_context_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1482. {
  1483. gearman_task_context(NULL);
  1484. return TEST_SUCCESS;
  1485. }
  1486. static test_return_t gearman_task_set_context_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1487. {
  1488. gearman_task_set_context(NULL, NULL);
  1489. return TEST_SUCCESS;
  1490. }
  1491. static test_return_t gearman_task_function_name_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1492. {
  1493. ASSERT_EQ(NULL, gearman_task_function_name(NULL));
  1494. return TEST_SUCCESS;
  1495. }
  1496. static test_return_t gearman_task_unique_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1497. {
  1498. ASSERT_EQ(NULL, gearman_task_unique(NULL));
  1499. return TEST_SUCCESS;
  1500. }
  1501. static test_return_t gearman_task_job_handle_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1502. {
  1503. ASSERT_EQ(NULL, gearman_task_job_handle(NULL));
  1504. return TEST_SUCCESS;
  1505. }
  1506. static test_return_t gearman_task_is_known_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1507. {
  1508. ASSERT_EQ(false, gearman_task_is_known(NULL));
  1509. return TEST_SUCCESS;
  1510. }
  1511. static test_return_t gearman_task_is_running_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1512. {
  1513. ASSERT_EQ(false, gearman_task_is_running(NULL));
  1514. return TEST_SUCCESS;
  1515. }
  1516. static test_return_t gearman_task_numerator_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1517. {
  1518. ASSERT_EQ(0, gearman_task_numerator(NULL));
  1519. return TEST_SUCCESS;
  1520. }
  1521. static test_return_t gearman_task_denominator_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1522. {
  1523. ASSERT_EQ(0, gearman_task_denominator(NULL));
  1524. return TEST_SUCCESS;
  1525. }
  1526. static test_return_t gearman_task_give_workload_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1527. {
  1528. gearman_task_give_workload(NULL, NULL, 0);
  1529. return TEST_SUCCESS;
  1530. }
  1531. static test_return_t gearman_task_send_workload_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1532. {
  1533. gearman_return_t ret;
  1534. ASSERT_EQ(0, gearman_task_send_workload(NULL, NULL, 0, &ret));
  1535. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1536. return TEST_SUCCESS;
  1537. }
  1538. static test_return_t gearman_task_data_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1539. {
  1540. ASSERT_EQ(NULL, gearman_task_data(NULL));
  1541. return TEST_SUCCESS;
  1542. }
  1543. static test_return_t gearman_task_data_size_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1544. {
  1545. ASSERT_EQ(0, gearman_task_data_size(NULL));
  1546. return TEST_SUCCESS;
  1547. }
  1548. static test_return_t gearman_task_take_data_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1549. {
  1550. size_t taken_space;
  1551. ASSERT_EQ(NULL, gearman_task_take_data(NULL, &taken_space));
  1552. return TEST_SUCCESS;
  1553. }
  1554. static test_return_t gearman_task_recv_data_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1555. {
  1556. gearman_return_t ret;
  1557. ASSERT_EQ(0, gearman_task_recv_data(NULL, NULL, 0, &ret));
  1558. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, ret);
  1559. return TEST_SUCCESS;
  1560. }
  1561. static test_return_t gearman_task_error_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1562. {
  1563. ASSERT_EQ(NULL, gearman_task_error(NULL));
  1564. return TEST_SUCCESS;
  1565. }
  1566. static test_return_t gearman_task_result_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1567. {
  1568. ASSERT_EQ(NULL, gearman_task_result(NULL));
  1569. return TEST_SUCCESS;
  1570. }
  1571. static test_return_t gearman_task_return_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1572. {
  1573. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_task_return(NULL));
  1574. return TEST_SUCCESS;
  1575. }
  1576. static test_return_t gearman_task_strstate_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1577. {
  1578. ASSERT_EQ(NULL, gearman_task_strstate(NULL));
  1579. return TEST_SUCCESS;
  1580. }
  1581. static test_return_t gearman_job_free_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1582. {
  1583. gearman_job_free(NULL);
  1584. return TEST_SUCCESS;
  1585. }
  1586. static test_return_t gearman_job_send_data_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1587. {
  1588. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_job_send_data(NULL, NULL, 0));
  1589. return TEST_SUCCESS;
  1590. }
  1591. static test_return_t gearman_job_send_warning_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1592. {
  1593. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_job_send_warning(NULL, NULL, 0));
  1594. return TEST_SUCCESS;
  1595. }
  1596. static test_return_t gearman_job_send_status_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1597. {
  1598. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_job_send_status(NULL, 0, 0));
  1599. return TEST_SUCCESS;
  1600. }
  1601. static test_return_t gearman_job_send_complete_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1602. {
  1603. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_job_send_complete(NULL, 0, 0));
  1604. return TEST_SUCCESS;
  1605. }
  1606. static test_return_t gearman_job_send_exception_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1607. {
  1608. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_job_send_exception(NULL, 0, 0));
  1609. return TEST_SUCCESS;
  1610. }
  1611. static test_return_t gearman_job_send_fail_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1612. {
  1613. ASSERT_EQ(GEARMAN_INVALID_ARGUMENT, gearman_job_send_fail(NULL));
  1614. return TEST_SUCCESS;
  1615. }
  1616. static test_return_t gearman_job_handle_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1617. {
  1618. ASSERT_EQ(NULL, gearman_job_handle(NULL));
  1619. return TEST_SUCCESS;
  1620. }
  1621. static test_return_t gearman_job_function_name_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1622. {
  1623. ASSERT_EQ(NULL, gearman_job_function_name(NULL));
  1624. return TEST_SUCCESS;
  1625. }
  1626. static test_return_t gearman_job_unique_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1627. {
  1628. ASSERT_EQ(NULL, gearman_job_unique(NULL));
  1629. return TEST_SUCCESS;
  1630. }
  1631. static test_return_t gearman_job_workload_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1632. {
  1633. ASSERT_EQ(NULL, gearman_job_unique(NULL));
  1634. return TEST_SUCCESS;
  1635. }
  1636. static test_return_t gearman_job_workload_size_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1637. {
  1638. ASSERT_EQ(0, gearman_job_workload_size(NULL));
  1639. return TEST_SUCCESS;
  1640. }
  1641. static test_return_t gearman_job_take_workload_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1642. {
  1643. ASSERT_EQ(NULL, gearman_job_take_workload(NULL, NULL));
  1644. return TEST_SUCCESS;
  1645. }
  1646. static test_return_t gearman_job_clone_worker_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1647. {
  1648. ASSERT_EQ(NULL, gearman_job_clone_worker(NULL));
  1649. return TEST_SUCCESS;
  1650. }
  1651. static test_return_t gearman_job_error_GEARMAN_INVALID_ARGUMENT_TEST(void*)
  1652. {
  1653. ASSERT_EQ(NULL, gearman_job_error(NULL));
  1654. return TEST_SUCCESS;
  1655. }
  1656. static test_return_t default_v1_SETUP(void *object)
  1657. {
  1658. gearman_function_t echo_react_fn= gearman_function_create_v1(echo_or_react_worker);
  1659. ASSERT_EQ(TEST_SUCCESS, __SETUP((client_test_st *)object, echo_react_fn));
  1660. return TEST_SUCCESS;
  1661. }
  1662. static test_return_t pre_free_tasks(void *object)
  1663. {
  1664. client_test_st *test= (client_test_st *)object;
  1665. ASSERT_TRUE(test);
  1666. ASSERT_EQ(TEST_SUCCESS, default_v2_SETUP(object));
  1667. gearman_client_add_options(test->client(), GEARMAN_CLIENT_FREE_TASKS);
  1668. ASSERT_TRUE(gearman_client_has_option(test->client(), GEARMAN_CLIENT_FREE_TASKS));
  1669. return TEST_SUCCESS;
  1670. }
  1671. static test_return_t namespace_v1_SETUP(void *object)
  1672. {
  1673. client_test_st *test= (client_test_st *)object;
  1674. ASSERT_TRUE(test);
  1675. test->session_namespace(NAMESPACE_KEY);
  1676. ASSERT_EQ(TEST_SUCCESS, default_v1_SETUP(object));
  1677. return TEST_SUCCESS;
  1678. }
  1679. static test_return_t namespace_v2_SETUP(void *object)
  1680. {
  1681. client_test_st *test= (client_test_st *)object;
  1682. ASSERT_TRUE(test);
  1683. test->session_namespace(NAMESPACE_KEY);
  1684. ASSERT_EQ(TEST_SUCCESS, default_v2_SETUP(object));
  1685. return TEST_SUCCESS;
  1686. }
  1687. static test_return_t pre_logging(void *object)
  1688. {
  1689. client_test_st *test= (client_test_st *)object;
  1690. ASSERT_TRUE(test);
  1691. test->clear_clone();
  1692. test_null(test->client()->impl()->universal.con_list);
  1693. test->set_worker_name(WORKER_FUNCTION_NAME);
  1694. return TEST_SUCCESS;
  1695. }
  1696. static void *world_create(server_startup_st& servers, test_return_t& error)
  1697. {
  1698. const char *argv[]= { "--exceptions", 0 };
  1699. in_port_t first_port= libtest::default_port();
  1700. ASSERT_TRUE(server_startup(servers, "gearmand", first_port, argv));
  1701. #if 0
  1702. if (0)
  1703. {
  1704. const char *null_args[]= { 0 };
  1705. in_port_t second_port= libtest::get_free_port();
  1706. ASSERT_TRUE(server_startup(servers, "gearmand", second_port, null_args));
  1707. }
  1708. #endif
  1709. client_test_st *test= new client_test_st();
  1710. ASSERT_TRUE(test);
  1711. test->add_server(NULL, first_port);
  1712. error= TEST_SUCCESS;
  1713. return (void *)test;
  1714. }
  1715. static bool world_destroy(void *object)
  1716. {
  1717. client_test_st *test= (client_test_st *)object;
  1718. delete test;
  1719. return TEST_SUCCESS;
  1720. }
  1721. test_st client_fork_TESTS[] ={
  1722. {"fork()", 0, check_client_fork_TEST },
  1723. {0, 0, 0}
  1724. };
  1725. test_st gearman_client_add_server_TESTS[] ={
  1726. {"gearman_client_add_server(localhost)", 0, gearman_client_add_server_localhost_TEST },
  1727. {"gearman_client_add_server(empty quote)", 0, gearman_client_add_server_empty_quote_TEST },
  1728. {0, 0, 0}
  1729. };
  1730. test_st gearman_client_st_GEARMAN_INVALID_ARGUMENT_TESTS[] ={
  1731. {"gearman_client_create()", 0, gearman_client_create_GEARMAN_INVALID_ARGUMENT_TEST },
  1732. {"gearman_client_clone()", 0, gearman_client_clone_GEARMAN_INVALID_ARGUMENT_TEST },
  1733. {"gearman_client_free()", 0, gearman_client_free_GEARMAN_INVALID_ARGUMENT_TEST },
  1734. {"gearman_client_error()", 0, gearman_client_error_GEARMAN_INVALID_ARGUMENT_TEST },
  1735. {"gearman_client_error_code()", 0, gearman_client_error_code_GEARMAN_INVALID_ARGUMENT_TEST },
  1736. {"gearman_client_options()", 0, gearman_client_options_GEARMAN_INVALID_ARGUMENT_TEST },
  1737. {"gearman_client_has_option()", 0, gearman_client_has_option_GEARMAN_INVALID_ARGUMENT_TEST },
  1738. {"gearman_client_set_options()", 0, gearman_client_set_options_GEARMAN_INVALID_ARGUMENT_TEST },
  1739. {"gearman_client_add_option()", 0, gearman_client_add_options_GEARMAN_INVALID_ARGUMENT_TEST },
  1740. {"gearman_client_remove_options()", 0, gearman_client_remove_options_GEARMAN_INVALID_ARGUMENT_TEST },
  1741. {"gearman_client_timeout()", 0, gearman_client_timeout_GEARMAN_INVALID_ARGUMENT_TEST },
  1742. {"gearman_client_set_timeout()", 0, gearman_client_set_timeout_GEARMAN_INVALID_ARGUMENT_TEST },
  1743. {"gearman_client_context()", 0, gearman_client_context_GEARMAN_INVALID_ARGUMENT_TEST },
  1744. {"gearman_client_set_context()", 0, gearman_client_set_context_GEARMAN_INVALID_ARGUMENT_TEST },
  1745. {"gearman_client_set_log_fn()", 0, gearman_client_set_log_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1746. {"gearman_client_set_workload_malloc_fn()", 0, gearman_client_set_workload_malloc_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1747. {"gearman_client_set_workload_free_fn()", 0, gearman_client_set_workload_free_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1748. {"gearman_client_set_memory_allocators()", 0, gearman_client_set_memory_allocators_GEARMAN_INVALID_ARGUMENT_TEST },
  1749. {"gearman_client_add_server()", 0, gearman_client_add_server_GEARMAN_INVALID_ARGUMENT_TEST },
  1750. {"gearman_client_remove_servers()", 0, gearman_client_remove_servers_GEARMAN_INVALID_ARGUMENT_TEST },
  1751. {"gearman_client_wait()", 0, gearman_client_wait_GEARMAN_INVALID_ARGUMENT_TEST },
  1752. {"gearman_client_do()", 0, gearman_client_do_GEARMAN_INVALID_ARGUMENT_TEST },
  1753. {"gearman_client_do_high()", 0, gearman_client_do_high_GEARMAN_INVALID_ARGUMENT_TEST },
  1754. {"gearman_client_do_low()", 0, gearman_client_do_low_GEARMAN_INVALID_ARGUMENT_TEST },
  1755. {"gearman_client_do_job_handle()", 0, gearman_client_do_job_handle_GEARMAN_INVALID_ARGUMENT_TEST },
  1756. {"gearman_client_do_background()", 0, gearman_client_do_background_GEARMAN_INVALID_ARGUMENT_TEST },
  1757. {"gearman_client_do_high_background()", 0, gearman_client_do_high_background_GEARMAN_INVALID_ARGUMENT_TEST },
  1758. {"gearman_client_do_low_background()", 0, gearman_client_do_low_background_GEARMAN_INVALID_ARGUMENT_TEST },
  1759. {"gearman_client_job_status()", 0, gearman_client_job_status_GEARMAN_INVALID_ARGUMENT_TEST },
  1760. {"gearman_client_unique_status()", 0, gearman_client_unique_status_GEARMAN_INVALID_ARGUMENT_TEST },
  1761. {"gearman_client_add_task_status_by_unique()", 0, gearman_client_add_task_status_by_unique_GEARMAN_INVALID_ARGUMENT_TEST },
  1762. {"gearman_client_echo()", 0, gearman_client_echo_GEARMAN_INVALID_ARGUMENT_TEST },
  1763. {"gearman_client_set_task_context_free_fn()", 0, gearman_client_set_task_context_free_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1764. {"gearman_client_task_free_all()", 0, gearman_client_task_free_all_GEARMAN_INVALID_ARGUMENT_TEST },
  1765. {"gearman_client_add_task()", 0, gearman_client_add_task_GEARMAN_INVALID_ARGUMENT_TEST },
  1766. {"gearman_client_add_task_high()", 0, gearman_client_add_task_high_GEARMAN_INVALID_ARGUMENT_TEST },
  1767. {"gearman_client_add_task_low()", 0, gearman_client_add_task_low_GEARMAN_INVALID_ARGUMENT_TEST },
  1768. {"gearman_client_add_task_background()", 0, gearman_client_add_task_background_GEARMAN_INVALID_ARGUMENT_TEST },
  1769. {"gearman_client_add_task_high_background()", 0, gearman_client_add_task_high_background_GEARMAN_INVALID_ARGUMENT_TEST },
  1770. {"gearman_client_add_task_low_background()", 0, gearman_client_add_task_low_background_GEARMAN_INVALID_ARGUMENT_TEST },
  1771. {"gearman_client_add_task_status()", 0, gearman_client_add_task_status_GEARMAN_INVALID_ARGUMENT_TEST },
  1772. {"gearman_client_set_workload_fn()", 0, gearman_client_set_workload_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1773. {"gearman_client_set_created_fn()", 0, gearman_client_set_created_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1774. {"gearman_client_set_status_fn()", 0, gearman_client_set_status_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1775. {"gearman_client_set_complete_fn()", 0, gearman_client_set_complete_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1776. {"gearman_client_set_exception_fn()", 0, gearman_client_set_exception_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1777. {"gearman_client_set_fail_fn()", 0, gearman_client_set_fail_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1778. {"gearman_client_clear_fn()", 0, gearman_client_clear_fn_GEARMAN_INVALID_ARGUMENT_TEST },
  1779. {"gearman_client_run_tasks()", 0, gearman_client_run_tasks_GEARMAN_INVALID_ARGUMENT_TEST },
  1780. {"gearman_client_compare()", 0, gearman_client_compare_GEARMAN_INVALID_ARGUMENT_TEST },
  1781. {"gearman_client_set_server_option()", 0, gearman_client_set_server_option_GEARMAN_INVALID_ARGUMENT_TEST },
  1782. {"gearman_client_set_namespace()", 0, gearman_client_set_namespace_GEARMAN_INVALID_ARGUMENT_TEST },
  1783. {"gearman_client_set_identifier()", 0, gearman_client_set_identifier_GEARMAN_INVALID_ARGUMENT_TEST },
  1784. {0, 0, 0}
  1785. };
  1786. test_st gearman_task_st_GEARMAN_INVALID_ARGUMENT_TESTS[] ={
  1787. {"gearman_task_free()", 0, gearman_task_free_GEARMAN_INVALID_ARGUMENT_TEST },
  1788. {"gearman_task_context()", 0, gearman_task_context_GEARMAN_INVALID_ARGUMENT_TEST },
  1789. {"gearman_task_set_context()", 0, gearman_task_set_context_GEARMAN_INVALID_ARGUMENT_TEST },
  1790. {"gearman_task_function_name()", 0, gearman_task_function_name_GEARMAN_INVALID_ARGUMENT_TEST },
  1791. {"gearman_task_unique()", 0, gearman_task_unique_GEARMAN_INVALID_ARGUMENT_TEST },
  1792. {"gearman_task_job_handle()", 0, gearman_task_job_handle_GEARMAN_INVALID_ARGUMENT_TEST },
  1793. {"gearman_task_is_known()", 0, gearman_task_is_known_GEARMAN_INVALID_ARGUMENT_TEST },
  1794. {"gearman_task_is_running()", 0, gearman_task_is_running_GEARMAN_INVALID_ARGUMENT_TEST },
  1795. {"gearman_task_numerator()", 0, gearman_task_numerator_GEARMAN_INVALID_ARGUMENT_TEST },
  1796. {"gearman_task_denominator()", 0, gearman_task_denominator_GEARMAN_INVALID_ARGUMENT_TEST },
  1797. {"gearman_task_give_workload()", 0, gearman_task_give_workload_GEARMAN_INVALID_ARGUMENT_TEST },
  1798. {"gearman_task_send_workload()", 0, gearman_task_send_workload_GEARMAN_INVALID_ARGUMENT_TEST },
  1799. {"gearman_task_data()", 0, gearman_task_data_GEARMAN_INVALID_ARGUMENT_TEST },
  1800. {"gearman_task_data_size()", 0, gearman_task_data_size_GEARMAN_INVALID_ARGUMENT_TEST },
  1801. {"gearman_task_take_data()", 0, gearman_task_take_data_GEARMAN_INVALID_ARGUMENT_TEST },
  1802. {"gearman_task_recv_data()", 0, gearman_task_recv_data_GEARMAN_INVALID_ARGUMENT_TEST },
  1803. {"gearman_task_error()", 0, gearman_task_error_GEARMAN_INVALID_ARGUMENT_TEST },
  1804. {"gearman_task_result()", 0, gearman_task_result_GEARMAN_INVALID_ARGUMENT_TEST },
  1805. {"gearman_task_return()", 0, gearman_task_return_GEARMAN_INVALID_ARGUMENT_TEST },
  1806. {"gearman_task_strstate()", 0, gearman_task_strstate_GEARMAN_INVALID_ARGUMENT_TEST },
  1807. {0, 0, 0}
  1808. };
  1809. test_st gearman_job_st_GEARMAN_INVALID_ARGUMENT_TESTS[] ={
  1810. {"gearman_job_free()", 0, gearman_job_free_GEARMAN_INVALID_ARGUMENT_TEST },
  1811. {"gearman_job_send_data()", 0, gearman_job_send_data_GEARMAN_INVALID_ARGUMENT_TEST },
  1812. {"gearman_job_send_warning()", 0, gearman_job_send_warning_GEARMAN_INVALID_ARGUMENT_TEST },
  1813. {"gearman_job_send_statu()", 0, gearman_job_send_status_GEARMAN_INVALID_ARGUMENT_TEST },
  1814. {"gearman_job_send_complete()", 0, gearman_job_send_complete_GEARMAN_INVALID_ARGUMENT_TEST },
  1815. {"gearman_job_send_exception()", 0, gearman_job_send_exception_GEARMAN_INVALID_ARGUMENT_TEST },
  1816. {"gearman_job_send()", 0, gearman_job_send_fail_GEARMAN_INVALID_ARGUMENT_TEST },
  1817. {"gearman_job_handle()", 0, gearman_job_handle_GEARMAN_INVALID_ARGUMENT_TEST },
  1818. {"gearman_job_function_name()", 0, gearman_job_function_name_GEARMAN_INVALID_ARGUMENT_TEST },
  1819. {"gearman_job_unique()", 0, gearman_job_unique_GEARMAN_INVALID_ARGUMENT_TEST },
  1820. {"gearman_job_workload()", 0, gearman_job_workload_GEARMAN_INVALID_ARGUMENT_TEST },
  1821. {"gearman_job_workload_size()", 0, gearman_job_workload_size_GEARMAN_INVALID_ARGUMENT_TEST },
  1822. {"gearman_job_take_workload()", 0, gearman_job_take_workload_GEARMAN_INVALID_ARGUMENT_TEST },
  1823. {"gearman_job_clone_worker()", 0, gearman_job_clone_worker_GEARMAN_INVALID_ARGUMENT_TEST },
  1824. {"gearman_job_error()", 0, gearman_job_error_GEARMAN_INVALID_ARGUMENT_TEST },
  1825. {0, 0, 0}
  1826. };
  1827. test_st gearman_client_set_identifier_TESTS[] ={
  1828. {"gearman_client_set_identifier()", 0, gearman_client_set_identifier_TEST },
  1829. {"gearman_client_set_identifier(with_work)", 0, gearman_client_set_identifier_plus_work_TEST },
  1830. {"gearman_client_set_identifier(RANDOM)", 0, gearman_client_set_identifier_plus_random_TEST },
  1831. {0, 0, 0}
  1832. };
  1833. test_st gearman_client_cancel_job_TESTS[] ={
  1834. {"gearman_client_cancel_job()", 0, gearman_client_cancel_job_TEST },
  1835. {0, 0, 0}
  1836. };
  1837. test_st gearman_return_t_TESTS[] ={
  1838. {"GEARMAN_SUCCESS", 0, (test_callback_fn*)GEARMAN_SUCCESS_TEST },
  1839. {"GEARMAN_FAIL == GEARMAN_FATAL == GEARMAN_WORK_FAIL", 0, (test_callback_fn*)GEARMAN_FAIL_COMPAT_TEST },
  1840. {"GEARMAN_ERROR == GEARMAN_WORK_ERROR", 0, (test_callback_fn*)GEARMAN_ERROR_COMPAT_TEST },
  1841. {0, 0, 0}
  1842. };
  1843. test_st gearman_id_t_TESTS[] ={
  1844. {"gearman_client_st", 0, (test_callback_fn*)gearman_client_st_id_t_TEST },
  1845. {"gearman_worker_st", 0, (test_callback_fn*)gearman_worker_st_id_t_TEST },
  1846. {0, 0, 0}
  1847. };
  1848. test_st gearman_client_st_init_TESTS[] ={
  1849. {"init", 0, init_test },
  1850. {"allocation", 0, allocation_test },
  1851. {"clone_test", 0, clone_test },
  1852. {"echo", 0, echo_test },
  1853. {"gearman_client_set_log_fn", 0, gearman_client_set_log_fn_TEST },
  1854. {"options", 0, option_test },
  1855. {0, 0, 0}
  1856. };
  1857. test_st gearman_client_st_TESTS[] ={
  1858. {"submit_job", 0, submit_job_test },
  1859. {"submit_echo_job", 0, submit_echo_job_test },
  1860. {"submit_null_job", 0, submit_null_job_test },
  1861. {"exception", 0, submit_exception_job_test },
  1862. {"warning", 0, submit_warning_job_test },
  1863. {"submit_multiple_do", 0, submit_multiple_do },
  1864. {"gearman_client_job_status()", 0, gearman_client_job_status_test },
  1865. {"gearman_client_job_status() with gearman_return_t", 0, gearman_client_job_status_with_return },
  1866. {"background_failure", 0, background_failure_test },
  1867. {"add_servers", 0, add_servers_test },
  1868. {"gearman_client_add_servers(GEARMAN_GETADDRINFO)", 0, hostname_resolution },
  1869. {"submit_fail_job", 0, submit_fail_job_test }, // Since this drops the worker, it must be last
  1870. {0, 0, 0}
  1871. };
  1872. test_st loop_TESTS[] ={
  1873. {"loop_test", 0, loop_test },
  1874. {0, 0, 0}
  1875. };
  1876. test_st coalescence_TESTS[] ={
  1877. {"basic coalescence", 0, coalescence_TEST },
  1878. {"coalescence by hash", 0, coalescence_by_data_hash_TEST },
  1879. {"coalescence by data", 0, coalescence_by_data_TEST },
  1880. {"coalescence by data fail", 0, coalescence_by_data_FAIL_TEST },
  1881. {0, 0, 0}
  1882. };
  1883. test_st gearman_command_t_tests[] ={
  1884. {"gearman_command_t", 0, check_gearman_command_t },
  1885. {0, 0, 0}
  1886. };
  1887. test_st gearman_worker_timeout_TESTS[] ={
  1888. {"gearman_worker_timeout(0)", 0, gearman_worker_timeout_TEST },
  1889. {"gearman_worker_timeout(DEFAULT_TIMEOUT)", 0, gearman_worker_timeout_TIMEOUT_TEST },
  1890. {0, 0, 0}
  1891. };
  1892. test_st tests_log_TESTS[] ={
  1893. {"submit_log_failure", 0, submit_log_failure_TEST },
  1894. {0, 0, 0}
  1895. };
  1896. test_st regression2_TESTS[] ={
  1897. {"stale client", 0, regression2_TEST },
  1898. {0, 0, 0}
  1899. };
  1900. test_st gearman_strerror_tests[] ={
  1901. {"count", 0, strerror_count },
  1902. {"strings", 0, strerror_strings },
  1903. {0, 0, 0}
  1904. };
  1905. test_st unique_tests[] ={
  1906. {"compare sent unique", 0, unique_compare_test },
  1907. {"gearman_client_unique_status(NOT_FOUND)", 0, gearman_client_unique_status_NOT_FOUND_TEST },
  1908. {"gearman_client_unique_status()", 0, gearman_client_unique_status_TEST },
  1909. {0, 0, 0}
  1910. };
  1911. test_st gearman_client_set_workload_malloc_fn_tests[] ={
  1912. {"gearman_client_set_workload_malloc_fn()", 0, gearman_client_set_workload_malloc_fn_test },
  1913. {"gearman_client_set_workload_free_fn()", 0, gearman_client_set_workload_free_fn_test },
  1914. {"submit job and check for usage of both malloc/free", 0, gearman_client_set_workload_allocators_test },
  1915. {0, 0, 0}
  1916. };
  1917. test_st regression_tests[] ={
  1918. #if 0
  1919. {"lp:768317", 0, regression_768317_test },
  1920. #endif
  1921. {"lp:785203 gearman_client_do()", 0, regression_785203_do_test },
  1922. {"lp:785203 gearman_client_do_background()", 0, regression_785203_do_background_test },
  1923. {"lp:833394 long function names", 0, regression_833394_test },
  1924. {"lp:975591 Increase the work size past the standard buffer size", 0, regression_975591_TEST },
  1925. {"lp:518512", 0, bug_518512_test },
  1926. {0, 0, 0}
  1927. };
  1928. test_st gearman_client_do_tests[] ={
  1929. {"gearman_client_do() fail huge unique", 0, gearman_client_do_huge_unique },
  1930. {"gearman_client_do() with active background task", 0, gearman_client_do_with_active_background_task },
  1931. {0, 0, 0}
  1932. };
  1933. test_st gearman_execute_tests[] ={
  1934. {"gearman_execute()", 0, gearman_execute_test },
  1935. {"gearman_execute() epoch", 0, gearman_execute_epoch_test },
  1936. {"gearman_execute() epoch and test gearman_job_handle_t", 0, gearman_execute_epoch_check_job_handle_test },
  1937. {"gearman_execute(GEARMAN_TIMEOUT)", 0, gearman_execute_timeout_test },
  1938. {"gearman_execute() background", 0, gearman_execute_bg_test },
  1939. {"gearman_execute() multiple background", 0, gearman_execute_multile_bg_test },
  1940. {"gearman_execute() with NULL workload", 0, gearman_execute_NULL_workload_TEST },
  1941. {"gearman_execute() with NULL workload", 0, gearman_execute_NULL_attr_NULL_workload_TEST },
  1942. {"gearman_execute(GEARMAN_WORK_FAIL)", 0, gearman_execute_fail_test }, // Fail test must be run last
  1943. {0, 0, 0}
  1944. };
  1945. test_st gearman_client_do_background_tests[] ={
  1946. {"gearman_client_do_background()", 0, gearman_client_do_background_basic },
  1947. {"gearman_client_do_high_background()", 0, gearman_client_do_high_background_basic },
  1948. {"gearman_client_do_low_background()", 0, gearman_client_do_low_background_basic },
  1949. {0, 0, 0}
  1950. };
  1951. test_st gearman_client_do_job_handle_tests[] ={
  1952. {"gearman_client_do_job_handle() no active tasks", 0, gearman_client_do_job_handle_no_active_task },
  1953. {"gearman_client_do_job_handle() follow do command", 0, gearman_client_do_job_handle_follow_do },
  1954. {0, 0, 0}
  1955. };
  1956. test_st gearman_execute_partition_tests[] ={
  1957. {"gearman_execute_by_partition() map reduce", 0, gearman_execute_partition_basic },
  1958. {"gearman_execute_by_partition(GEARMAN_ARGUMENT_TOO_LARGE) map reduce", 0, gearman_execute_partition_check_parameters },
  1959. {"gearman_execute_by_partition(GEARMAN_WORK_FAIL) map reduce", 0, gearman_execute_partition_workfail },
  1960. {"gearman_execute_by_partition() fail in reduction", 0, gearman_execute_partition_fail_in_reduction },
  1961. #if 0
  1962. {"gearman_execute() with V2 Worker that has aggregate defined", 0, gearman_execute_partition_use_as_function },
  1963. {"gearman_execute_by_partition() no aggregate function", 0, gearman_execute_partition_no_aggregate },
  1964. #endif
  1965. {0, 0, 0}
  1966. };
  1967. test_st gearman_client_set_server_option_tests[] ={
  1968. {"gearman_client_set_server_option(exceptions)", 0, gearman_client_set_server_option_exception},
  1969. {"gearman_client_set_server_option(bad)", 0, gearman_client_set_server_option_bad},
  1970. {0, 0, 0}
  1971. };
  1972. test_st gearman_task_tests[] ={
  1973. {"gearman_client_add_task() ", 0, gearman_client_add_task_test},
  1974. {"gearman_client_add_task() bad workload", 0, gearman_client_add_task_test_bad_workload},
  1975. {"gearman_client_add_task_background()", 0, gearman_client_add_task_background_test},
  1976. {"gearman_client_add_task_low_background()", 0, gearman_client_add_task_low_background_test},
  1977. {"gearman_client_add_task_high_background()", 0, gearman_client_add_task_high_background_test},
  1978. {"gearman_client_add_task() exception", 0, gearman_client_add_task_exception},
  1979. {"gearman_client_add_task() exception check returned string", 0, gearman_client_add_task_check_exception_TEST},
  1980. {"gearman_client_add_task() warning", 0, gearman_client_add_task_warning},
  1981. {"gearman_client_add_task(GEARMAN_NO_SERVERS)", 0, gearman_client_add_task_no_servers},
  1982. {"gearman_client_set_task_context_free_fn()", 0, gearman_client_set_task_context_free_fn_test},
  1983. {"gearman_client_add_task_status_by_unique(NOT_FOUND)", 0, gearman_client_add_task_status_by_unique_NOT_FOUND_TEST },
  1984. {"gearman_client_add_task_status_by_unique()", 0, gearman_client_add_task_status_by_unique_TEST },
  1985. {"gearman_client_add_task() fail", 0, gearman_client_add_task_test_fail}, // Fail needs to go last
  1986. {0, 0, 0}
  1987. };
  1988. test_st gearman_client_st_NULL_invocation_TESTS[] ={
  1989. {"gearman_client_free()", 0, gearman_client_free_TEST },
  1990. {"gearman_client_error()", 0, gearman_client_error_TEST },
  1991. {"gearman_client_error() no error", 0, gearman_client_error_no_error_TEST },
  1992. {"gearman_client_errno()", 0, gearman_client_errno_TEST },
  1993. {"gearman_client_errno() no error", 0, gearman_client_errno_no_error_TEST },
  1994. {"gearman_client_options()", 0, gearman_client_options_TEST },
  1995. {"gearman_client_options(SSL)", 0, gearman_client_options_SSL_TEST },
  1996. {0, 0, 0}
  1997. };
  1998. test_st gearman_task_pause_tests[] ={
  1999. {"gearman_client_add_task(GEARMAN_PAUSE)", 0, gearman_client_add_task_pause_test},
  2000. {0, 0, 0}
  2001. };
  2002. test_st limit_tests[] ={
  2003. {"GEARMAN_FUNCTION_MAX_SIZE", 0, function_name_limit_test},
  2004. {"GEARMAN_UNIQUE_MAX_SIZE", 0, unique_name_limit_test},
  2005. {0, 0, 0}
  2006. };
  2007. collection_st collection[] ={
  2008. {"gearman_return_t", 0, 0, gearman_return_t_TESTS},
  2009. {"init", 0, 0, gearman_client_st_init_TESTS},
  2010. {"gearman_client_cancel_job()", 0, 0, gearman_client_cancel_job_TESTS },
  2011. {"gearman_client_st GEARMAN_INVALID_ARGUMENT", 0, 0, gearman_client_st_GEARMAN_INVALID_ARGUMENT_TESTS },
  2012. {"gearman_task_st GEARMAN_INVALID_ARGUMENT", 0, 0, gearman_task_st_GEARMAN_INVALID_ARGUMENT_TESTS },
  2013. {"gearman_job_st GEARMAN_INVALID_ARGUMENT", 0, 0, gearman_job_st_GEARMAN_INVALID_ARGUMENT_TESTS },
  2014. {"gearman_id_t", 0, 0, gearman_id_t_TESTS},
  2015. {"gearman_strerror()", 0, 0, gearman_strerror_tests },
  2016. {"gearman_client_st init", 0, 0, gearman_client_st_init_TESTS },
  2017. {"gearman_client_add_server()", 0, 0, gearman_client_add_server_TESTS },
  2018. {"gearman_client_st", default_v2_SETUP, 0, gearman_client_st_TESTS},
  2019. {"gearman_client_st chunky", chunk_v1_SETUP, 0, gearman_client_st_TESTS}, // Test with a worker that will respond in part
  2020. {"gearman_task_add_task() v1 workers", default_v1_SETUP, 0, gearman_task_tests},
  2021. {"gearman_task_add_task() v2 workers", default_v2_SETUP, 0, gearman_task_tests},
  2022. {"gearman_task_add_task() namespace v1", namespace_v1_SETUP, 0, gearman_task_tests},
  2023. {"gearman_task_add_task() namespace v2", namespace_v2_SETUP, 0, gearman_task_tests},
  2024. {"gearman_task_add_task() chunky v1 workers", chunk_v1_SETUP, 0, gearman_task_tests},
  2025. {"gearman_task_add_task() chunky v2 workers", chunk_v2_SETUP, 0, gearman_task_tests},
  2026. {"gearman_task_add_task(GEARMAN_CLIENT_FREE_TASKS)", pre_free_tasks, 0, gearman_task_tests},
  2027. {"gearman_task_add_task(GEARMAN_CLIENT_GENERATE_UNIQUE)", GEARMAN_CLIENT_GENERATE_UNIQUE_SETUP, 0, gearman_task_tests},
  2028. {"gearman_task_add_task(GEARMAN_PAUSE)", chunk_v1_SETUP, 0, gearman_task_pause_tests},
  2029. {"gearman_task_add_task(GEARMAN_PAUSE)", chunk_v2_SETUP, 0, gearman_task_pause_tests},
  2030. {"unique", unique_SETUP, 0, unique_tests},
  2031. {"gearman_client_set_workload_malloc_fn()", default_v2_SETUP, 0, gearman_client_set_workload_malloc_fn_tests},
  2032. {"gearman_client_do()", default_v2_SETUP, 0, gearman_client_do_tests},
  2033. {"gearman_client_do() namespace v1", namespace_v1_SETUP, 0, gearman_client_do_tests},
  2034. {"gearman_client_do() namespace v2", namespace_v2_SETUP, 0, gearman_client_do_tests},
  2035. {"gearman_client_do(GEARMAN_CLIENT_FREE_TASKS)", pre_free_tasks, 0, gearman_client_do_tests},
  2036. {"gearman_client_do_job_handle()", default_v2_SETUP, 0, gearman_client_do_job_handle_tests},
  2037. {"gearman_client_do_job_handle() namespace v1", namespace_v1_SETUP, 0, gearman_client_do_job_handle_tests},
  2038. {"gearman_client_do_job_handle() namespace v2", namespace_v2_SETUP, 0, gearman_client_do_job_handle_tests},
  2039. {"gearman_client_do_job_handle(GEARMAN_CLIENT_FREE_TASKS)", pre_free_tasks, 0, gearman_client_do_job_handle_tests},
  2040. {"gearman_client_do_background()", default_v2_SETUP, 0, gearman_client_do_background_tests},
  2041. {"gearman_client_do_background(GEARMAN_CLIENT_FREE_TASKS)", pre_free_tasks, 0, gearman_client_do_background_tests},
  2042. {"gearman_client_set_server_option", 0, 0, gearman_client_set_server_option_tests},
  2043. {"gearman_execute()", default_v2_SETUP, 0, gearman_execute_tests},
  2044. {"gearman_execute(GEARMAN_CLIENT_FREE_TASKS)", pre_free_tasks, 0, gearman_execute_tests},
  2045. {"gearman_execute() chunked v1 return", chunk_v1_SETUP, 0, gearman_execute_tests},
  2046. {"gearman_execute() chunked v2 return", chunk_v2_SETUP, 0, gearman_execute_tests},
  2047. {"gearman_execute_partition()", partition_SETUP, 0, gearman_execute_partition_tests},
  2048. {"gearman_execute_partition(GEARMAN_CLIENT_FREE_TASKS)", partition_free_SETUP, 0, gearman_execute_partition_tests},
  2049. {"gearman_command_t", 0, 0, gearman_command_t_tests},
  2050. {"coalescence", 0, 0, coalescence_TESTS},
  2051. {"fork", fork_SETUP, 0, client_fork_TESTS },
  2052. {"loop", 0, 0, loop_TESTS},
  2053. {"limits", 0, 0, limit_tests },
  2054. {"client-logging", pre_logging, 0, tests_log_TESTS },
  2055. {"regression", 0, 0, regression_tests},
  2056. {"regression2", reset_SETUP, 0, regression2_TESTS },
  2057. {"gearman_worker_timeout()", default_v2_SETUP, 0, gearman_worker_timeout_TESTS },
  2058. {"gearman_client_set_identifier()", default_v2_SETUP, 0, gearman_client_set_identifier_TESTS },
  2059. {0, 0, 0, 0}
  2060. };
  2061. void get_world(libtest::Framework *world)
  2062. {
  2063. world->collections(collection);
  2064. world->create(world_create);
  2065. world->destroy(world_destroy);
  2066. world->set_runner(new GearmandRunner);
  2067. }