public_server.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /* Copyright (c) 2015 the Civetweb developers
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. #ifdef _MSC_VER
  22. #define _CRT_SECURE_NO_WARNINGS
  23. #endif
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include <time.h>
  27. #include <sys/types.h>
  28. #include <sys/stat.h>
  29. #include "public_server.h"
  30. #include <civetweb.h>
  31. #if defined(_WIN32)
  32. #include <Windows.h>
  33. #define mg_Sleep(x) (Sleep(x * 1000))
  34. #else
  35. #include <unistd.h>
  36. #define mg_Sleep(x) (sleep(x))
  37. #endif
  38. /* This unit test file uses the excellent Check unit testing library.
  39. * The API documentation is available here:
  40. * http://check.sourceforge.net/doc/check_html/index.html
  41. */
  42. START_TEST(test_the_test_environment)
  43. {
  44. char wd[300];
  45. char buf[500];
  46. FILE *f;
  47. struct stat st;
  48. int ret;
  49. memset(wd, 0, sizeof(wd));
  50. memset(buf, 0, sizeof(buf));
  51. /* Get the current working directory */
  52. #ifdef _WIN32
  53. (void)GetCurrentDirectoryA(sizeof(wd), wd);
  54. wd[sizeof(wd) - 1] = 0;
  55. #else
  56. (void)getcwd(wd, sizeof(wd));
  57. wd[sizeof(wd) - 1] = 0;
  58. #endif
  59. /* Check the pem file */
  60. #ifdef _WIN32
  61. strcpy(buf, wd);
  62. strcat(buf, "..\\..\\..\\resources\\ssl_cert.pem");
  63. f = fopen(buf, "rb");
  64. #else
  65. strcpy(buf, wd);
  66. strcat(buf, "../../resources/ssl_cert.pem");
  67. f = fopen(buf, "r");
  68. #endif
  69. if (f) {
  70. fclose(f);
  71. } else {
  72. fprintf(stderr, "%s not found", buf);
  73. }
  74. /* Check the test dir */
  75. #ifdef _WIN32
  76. strcpy(buf, wd);
  77. strcat(buf, "\\test");
  78. #else
  79. strcpy(buf, wd);
  80. strcat(buf, "/test");
  81. #endif
  82. memset(&st, 0, sizeof(st));
  83. ret = stat(buf, &st);
  84. if (ret) {
  85. fprintf(stderr, "%s not found", buf);
  86. }
  87. }
  88. END_TEST
  89. static int log_msg_func(const struct mg_connection *conn, const char *message)
  90. {
  91. struct mg_context *ctx;
  92. char *ud;
  93. ck_assert(conn != NULL);
  94. ctx = mg_get_context(conn);
  95. ck_assert(ctx != NULL);
  96. ud = (char *)mg_get_user_data(ctx);
  97. strncpy(ud, message, 255);
  98. ud[255] = 0;
  99. return 1;
  100. }
  101. START_TEST(test_mg_start_stop_http_server)
  102. {
  103. struct mg_context *ctx;
  104. const char *OPTIONS[] = {
  105. #if !defined(NO_FILES)
  106. "document_root",
  107. ".",
  108. #endif
  109. "listening_ports",
  110. "8080",
  111. NULL,
  112. };
  113. size_t ports_cnt;
  114. int ports[16];
  115. int ssl[16];
  116. struct mg_callbacks callbacks;
  117. char errmsg[256];
  118. memset(ports, 0, sizeof(ports));
  119. memset(ssl, 0, sizeof(ssl));
  120. memset(&callbacks, 0, sizeof(callbacks));
  121. memset(errmsg, 0, sizeof(errmsg));
  122. callbacks.log_message = log_msg_func;
  123. ctx = mg_start(&callbacks, (void *)errmsg, OPTIONS);
  124. mg_Sleep(1);
  125. ck_assert_str_eq(errmsg, "");
  126. ck_assert(ctx != NULL);
  127. ports_cnt = mg_get_ports(ctx, 16, ports, ssl);
  128. ck_assert_uint_eq(ports_cnt, 1);
  129. ck_assert_int_eq(ports[0], 8080);
  130. ck_assert_int_eq(ssl[0], 0);
  131. ck_assert_int_eq(ports[1], 0);
  132. ck_assert_int_eq(ssl[1], 0);
  133. mg_Sleep(1);
  134. mg_stop(ctx);
  135. }
  136. END_TEST
  137. START_TEST(test_mg_start_stop_https_server)
  138. {
  139. struct mg_context *ctx;
  140. const char *OPTIONS[] = {
  141. #if !defined(NO_FILES)
  142. "document_root",
  143. ".",
  144. #endif
  145. "listening_ports",
  146. "8080r,8443s",
  147. "ssl_certificate",
  148. #ifdef _WIN32
  149. "..\\..\\..\\resources/ssl_cert.pem", // TODO: the different paths used
  150. // in the different test system is
  151. // an unsolved problem
  152. #else
  153. "../../resources/ssl_cert.pem", // TODO: fix path in CI test environment
  154. #endif
  155. NULL,
  156. };
  157. size_t ports_cnt;
  158. int ports[16];
  159. int ssl[16];
  160. struct mg_callbacks callbacks;
  161. char errmsg[256];
  162. memset(ports, 0, sizeof(ports));
  163. memset(ssl, 0, sizeof(ssl));
  164. memset(&callbacks, 0, sizeof(callbacks));
  165. memset(errmsg, 0, sizeof(errmsg));
  166. callbacks.log_message = log_msg_func;
  167. ctx = mg_start(&callbacks, (void *)errmsg, OPTIONS);
  168. mg_Sleep(1);
  169. ck_assert_str_eq(errmsg, "");
  170. ck_assert(ctx != NULL);
  171. ports_cnt = mg_get_ports(ctx, 16, ports, ssl);
  172. ck_assert_uint_eq(ports_cnt, 2);
  173. ck_assert_int_eq(ports[0], 8080);
  174. ck_assert_int_eq(ssl[0], 0);
  175. ck_assert_int_eq(ports[1], 8443);
  176. ck_assert_int_eq(ssl[1], 1);
  177. ck_assert_int_eq(ports[2], 0);
  178. ck_assert_int_eq(ssl[2], 0);
  179. mg_Sleep(1);
  180. mg_stop(ctx);
  181. }
  182. END_TEST
  183. static struct mg_context *g_ctx;
  184. static int request_test_handler(struct mg_connection *conn, void *cbdata)
  185. {
  186. int i;
  187. char chunk_data[32];
  188. const struct mg_request_info *ri;
  189. struct mg_context *ctx;
  190. void *ud, *cud;
  191. ctx = mg_get_context(conn);
  192. ud = mg_get_user_data(ctx);
  193. ri = mg_get_request_info(conn);
  194. ck_assert(ri != NULL);
  195. ck_assert(ctx == g_ctx);
  196. ck_assert(ud == &g_ctx);
  197. mg_set_user_connection_data(conn, (void *)6543);
  198. cud = mg_get_user_connection_data(conn);
  199. ck_assert(cud == (void *)6543);
  200. ck_assert(cbdata == (void *)7);
  201. strcpy(chunk_data, "123456789A123456789B123456789C");
  202. mg_printf(conn,
  203. "HTTP/1.1 200 OK\r\n"
  204. "Transfer-Encoding: chunked\r\n"
  205. "Content-Type: text/plain\r\n\r\n");
  206. for (i = 1; i <= 10; i++) {
  207. mg_printf(conn, "%x\r\n", i);
  208. mg_write(conn, chunk_data, (unsigned)i);
  209. mg_printf(conn, "\r\n");
  210. }
  211. mg_printf(conn, "0\r\n\r\n");
  212. return 1;
  213. }
  214. START_TEST(test_request_handlers)
  215. {
  216. char ebuf[100];
  217. struct mg_context *ctx;
  218. struct mg_connection *conn;
  219. const struct mg_request_info *ri;
  220. char uri[64];
  221. char buf[1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 8];
  222. const char *expected =
  223. "112123123412345123456123456712345678123456789123456789A";
  224. int i;
  225. const char *request = "GET /U7 HTTP/1.0\r\n\r\n";
  226. #if defined(USE_IPV6) && defined(NO_SSL)
  227. const char *HTTP_PORT = "8084,[::]:8086";
  228. short ipv4_port = 8084;
  229. short ipv6_port = 8086;
  230. #elif !defined(USE_IPV6) && defined(NO_SSL)
  231. const char *HTTP_PORT = "8084";
  232. short ipv4_port = 8084;
  233. #elif defined(USE_IPV6) && !defined(NO_SSL)
  234. const char *HTTP_PORT = "8084,[::]:8086,8194r,[::]:8196r,8094s,[::]:8096s";
  235. short ipv4_port = 8084;
  236. short ipv4s_port = 8094;
  237. short ipv4r_port = 8194;
  238. short ipv6_port = 8086;
  239. short ipv6s_port = 8096;
  240. short ipv6r_port = 8196;
  241. #elif !defined(USE_IPV6) && !defined(NO_SSL)
  242. const char *HTTP_PORT = "8084,8194r,8094s";
  243. short ipv4_port = 8084;
  244. short ipv4s_port = 8094;
  245. short ipv4r_port = 8194;
  246. #endif
  247. const char *OPTIONS[8]; /* initializer list here is rejected by CI test */
  248. const char *opt;
  249. FILE *f;
  250. int opt_idx = 0;
  251. memset((void *)OPTIONS, 0, sizeof(OPTIONS));
  252. OPTIONS[opt_idx++] = "listening_ports";
  253. OPTIONS[opt_idx++] = HTTP_PORT;
  254. #if !defined(NO_FILES)
  255. OPTIONS[opt_idx++] = "document_root";
  256. OPTIONS[opt_idx++] = ".";
  257. #endif
  258. #ifndef NO_SSL
  259. OPTIONS[opt_idx++] = "ssl_certificate";
  260. #ifdef _WIN32
  261. OPTIONS[opt_idx++] =
  262. "..\\..\\..\\resources/ssl_cert.pem"; // TODO: the different
  263. // paths used in the
  264. // different test system
  265. // is an unsolved problem
  266. #else
  267. OPTIONS[opt_idx++] =
  268. "../../resources/ssl_cert.pem"; // TODO: fix path in CI test environment
  269. #endif
  270. #endif
  271. ck_assert_int_le(opt_idx, (int)(sizeof(OPTIONS) / sizeof(OPTIONS[0])));
  272. ck_assert(OPTIONS[sizeof(OPTIONS) / sizeof(OPTIONS[0]) - 1] == NULL);
  273. ck_assert(OPTIONS[sizeof(OPTIONS) / sizeof(OPTIONS[0]) - 2] == NULL);
  274. ctx = mg_start(NULL, &g_ctx, OPTIONS);
  275. ck_assert(ctx != NULL);
  276. g_ctx = ctx;
  277. opt = mg_get_option(ctx, "listening_ports");
  278. ck_assert_str_eq(opt, HTTP_PORT);
  279. opt = mg_get_option(ctx, "cgi_environment");
  280. ck_assert_str_eq(opt, "");
  281. opt = mg_get_option(ctx, "unknown_option_name");
  282. ck_assert(opt == NULL);
  283. for (i = 0; i < 1000; i++) {
  284. sprintf(uri, "/U%u", i);
  285. mg_set_request_handler(ctx, uri, request_test_handler, NULL);
  286. }
  287. for (i = 500; i < 800; i++) {
  288. sprintf(uri, "/U%u", i);
  289. mg_set_request_handler(ctx, uri, NULL, (void *)1);
  290. }
  291. for (i = 600; i >= 0; i--) {
  292. sprintf(uri, "/U%u", i);
  293. mg_set_request_handler(ctx, uri, NULL, (void *)2);
  294. }
  295. for (i = 750; i <= 1000; i++) {
  296. sprintf(uri, "/U%u", i);
  297. mg_set_request_handler(ctx, uri, NULL, (void *)3);
  298. }
  299. for (i = 5; i < 9; i++) {
  300. sprintf(uri, "/U%u", i);
  301. mg_set_request_handler(
  302. ctx, uri, request_test_handler, (void *)(ptrdiff_t)i);
  303. }
  304. /* Try to load non existing file */
  305. conn = mg_download("localhost",
  306. ipv4_port,
  307. 0,
  308. ebuf,
  309. sizeof(ebuf),
  310. "%s",
  311. "GET /file/not/found HTTP/1.0\r\n\r\n");
  312. ck_assert(conn != NULL);
  313. ri = mg_get_request_info(conn);
  314. ck_assert(ri != NULL);
  315. ck_assert_str_eq(ri->uri, "404");
  316. mg_close_connection(conn);
  317. /* Get data from callback */
  318. conn = mg_download(
  319. "localhost", ipv4_port, 0, ebuf, sizeof(ebuf), "%s", request);
  320. ck_assert(conn != NULL);
  321. ri = mg_get_request_info(conn);
  322. ck_assert(ri != NULL);
  323. ck_assert_str_eq(ri->uri, "200");
  324. i = mg_read(conn, buf, sizeof(buf));
  325. ck_assert_int_eq(i, (int)strlen(expected));
  326. buf[i] = 0;
  327. ck_assert_str_eq(buf, expected);
  328. mg_close_connection(conn);
  329. /* Get data from callback using http://127.0.0.1 */
  330. conn = mg_download(
  331. "127.0.0.1", ipv4_port, 0, ebuf, sizeof(ebuf), "%s", request);
  332. ck_assert(conn != NULL);
  333. ri = mg_get_request_info(conn);
  334. ck_assert(ri != NULL);
  335. ck_assert_str_eq(ri->uri, "200");
  336. i = mg_read(conn, buf, sizeof(buf));
  337. ck_assert_int_eq(i, (int)strlen(expected));
  338. buf[i] = 0;
  339. ck_assert_str_eq(buf, expected);
  340. mg_close_connection(conn);
  341. #if defined(USE_IPV6)
  342. /* Get data from callback using http://[::1] */
  343. conn =
  344. mg_download("[::1]", ipv6_port, 0, ebuf, sizeof(ebuf), "%s", request);
  345. ck_assert(conn != NULL);
  346. ri = mg_get_request_info(conn);
  347. ck_assert(ri != NULL);
  348. ck_assert_str_eq(ri->uri, "200");
  349. i = mg_read(conn, buf, sizeof(buf));
  350. ck_assert_int_eq(i, (int)strlen(expected));
  351. buf[i] = 0;
  352. ck_assert_str_eq(buf, expected);
  353. mg_close_connection(conn);
  354. #endif
  355. #if !defined(NO_SSL)
  356. /* Get data from callback using https://127.0.0.1 */
  357. conn = mg_download(
  358. "127.0.0.1", ipv4s_port, 1, ebuf, sizeof(ebuf), "%s", request);
  359. ck_assert(conn != NULL);
  360. ri = mg_get_request_info(conn);
  361. ck_assert(ri != NULL);
  362. ck_assert_str_eq(ri->uri, "200");
  363. i = mg_read(conn, buf, sizeof(buf));
  364. ck_assert_int_eq(i, (int)strlen(expected));
  365. buf[i] = 0;
  366. ck_assert_str_eq(buf, expected);
  367. mg_close_connection(conn);
  368. /* Get redirect from callback using http://127.0.0.1 */
  369. conn = mg_download(
  370. "127.0.0.1", ipv4r_port, 0, ebuf, sizeof(ebuf), "%s", request);
  371. ck_assert(conn != NULL);
  372. ri = mg_get_request_info(conn);
  373. ck_assert(ri != NULL);
  374. ck_assert_str_eq(ri->uri, "302");
  375. i = mg_read(conn, buf, sizeof(buf));
  376. ck_assert_int_eq(i, -1);
  377. mg_close_connection(conn);
  378. #endif
  379. #if defined(USE_IPV6) && !defined(NO_SSL)
  380. /* Get data from callback using https://[::1] */
  381. conn =
  382. mg_download("[::1]", ipv6s_port, 1, ebuf, sizeof(ebuf), "%s", request);
  383. ck_assert(conn != NULL);
  384. ri = mg_get_request_info(conn);
  385. ck_assert(ri != NULL);
  386. ck_assert_str_eq(ri->uri, "200");
  387. i = mg_read(conn, buf, sizeof(buf));
  388. ck_assert_int_eq(i, (int)strlen(expected));
  389. buf[i] = 0;
  390. ck_assert_str_eq(buf, expected);
  391. mg_close_connection(conn);
  392. /* Get redirect from callback using http://127.0.0.1 */
  393. conn =
  394. mg_download("[::1]", ipv6r_port, 0, ebuf, sizeof(ebuf), "%s", request);
  395. ck_assert(conn != NULL);
  396. ri = mg_get_request_info(conn);
  397. ck_assert(ri != NULL);
  398. ck_assert_str_eq(ri->uri, "302");
  399. i = mg_read(conn, buf, sizeof(buf));
  400. ck_assert_int_eq(i, -1);
  401. mg_close_connection(conn);
  402. #endif
  403. /* It seems to be impossible to find out what the actual working
  404. * directory of the CI test environment is. Before breaking another
  405. * dozen of builds by trying blindly with different paths, just
  406. * create the file here */
  407. #ifdef _WIN32
  408. f = fopen("test.txt", "wb");
  409. #else
  410. f = fopen("test.txt", "w");
  411. #endif
  412. fwrite("simple text file\n", 17, 1, f);
  413. fclose(f);
  414. /* Get static data */
  415. conn = mg_download("localhost",
  416. ipv4_port,
  417. 0,
  418. ebuf,
  419. sizeof(ebuf),
  420. "%s",
  421. "GET /test.txt HTTP/1.0\r\n\r\n");
  422. ck_assert(conn != NULL);
  423. ri = mg_get_request_info(conn);
  424. ck_assert(ri != NULL);
  425. #if defined(NO_FILES)
  426. ck_assert_str_eq(ri->uri, "404");
  427. #else
  428. ck_assert_str_eq(ri->uri, "200");
  429. i = mg_read(conn, buf, sizeof(buf));
  430. ck_assert_int_eq(i, 17);
  431. if ((i >= 0) && (i < (int)sizeof(buf))) {
  432. buf[i] = 0;
  433. }
  434. ck_assert_str_eq(buf, "simple text file\n");
  435. #endif
  436. mg_close_connection(conn);
  437. /* Get directory listing */
  438. conn = mg_download("localhost",
  439. ipv4_port,
  440. 0,
  441. ebuf,
  442. sizeof(ebuf),
  443. "%s",
  444. "GET / HTTP/1.0\r\n\r\n");
  445. ck_assert(conn != NULL);
  446. ri = mg_get_request_info(conn);
  447. ck_assert(ri != NULL);
  448. #if defined(NO_FILES)
  449. ck_assert_str_eq(ri->uri, "404");
  450. #else
  451. ck_assert_str_eq(ri->uri, "200");
  452. i = mg_read(conn, buf, sizeof(buf));
  453. ck_assert(i > 6);
  454. buf[6] = 0;
  455. ck_assert_str_eq(buf, "<html>");
  456. #endif
  457. mg_close_connection(conn);
  458. /* POST to static file (will not work) */
  459. conn = mg_download("localhost",
  460. ipv4_port,
  461. 0,
  462. ebuf,
  463. sizeof(ebuf),
  464. "%s",
  465. "POST /test.txt HTTP/1.0\r\n\r\n");
  466. ck_assert(conn != NULL);
  467. ri = mg_get_request_info(conn);
  468. ck_assert(ri != NULL);
  469. ck_assert_str_eq(ri->uri, "405");
  470. i = mg_read(conn, buf, sizeof(buf));
  471. ck_assert(i >= 29);
  472. buf[29] = 0;
  473. ck_assert_str_eq(buf, "Error 405: Method Not Allowed");
  474. mg_close_connection(conn);
  475. /* PUT to static file (will not work) */
  476. conn = mg_download("localhost",
  477. ipv4_port,
  478. 0,
  479. ebuf,
  480. sizeof(ebuf),
  481. "%s",
  482. "PUT /test.txt HTTP/1.0\r\n\r\n");
  483. ck_assert(conn != NULL);
  484. ri = mg_get_request_info(conn);
  485. ck_assert(ri != NULL);
  486. ck_assert_str_eq(ri->uri, "401"); /* not authorized */
  487. mg_close_connection(conn);
  488. /* TODO: Test websockets */
  489. /* Close the server */
  490. g_ctx = NULL;
  491. mg_stop(ctx);
  492. mg_Sleep(1);
  493. }
  494. END_TEST
  495. Suite *make_public_server_suite(void)
  496. {
  497. Suite *const suite = suite_create("PublicServer");
  498. TCase *const checktestenv = tcase_create("Check test environment");
  499. TCase *const startstophttp = tcase_create("Start Stop HTTP Server");
  500. TCase *const startstophttps = tcase_create("Start Stop HTTPS Server");
  501. TCase *const serverrequests = tcase_create("Server Requests");
  502. tcase_add_test(checktestenv, test_the_test_environment);
  503. suite_add_tcase(suite, checktestenv);
  504. tcase_add_test(startstophttp, test_mg_start_stop_http_server);
  505. suite_add_tcase(suite, startstophttp);
  506. tcase_add_test(startstophttps, test_mg_start_stop_https_server);
  507. suite_add_tcase(suite, startstophttps);
  508. tcase_add_test(serverrequests, test_request_handlers);
  509. suite_add_tcase(suite, serverrequests);
  510. return suite;
  511. }
  512. #ifdef REPLACE_CHECK_FOR_LOCAL_DEBUGGING
  513. /* Used to debug test cases without using the check framework */
  514. static int chk_ok = 0;
  515. static int chk_failed = 0;
  516. void main(void)
  517. {
  518. test_the_test_environment(0);
  519. test_mg_start_stop_http_server(0);
  520. test_mg_start_stop_https_server(0);
  521. test_request_handlers(0);
  522. printf("\nok: %i\nfailed: %i\n\n", chk_ok, chk_failed);
  523. }
  524. void _ck_assert_failed(const char *file, int line, const char *expr, ...)
  525. {
  526. va_list va;
  527. va_start(va, expr);
  528. fprintf(stderr, "Error: %s, line %i\n", file, line); /* breakpoint here ! */
  529. vfprintf(stderr, expr, va);
  530. va_end(va);
  531. chk_failed++;
  532. }
  533. void _mark_point(const char *file, int line) { chk_ok++; }
  534. void tcase_fn_start(const char *fname, const char *file, int line) {}
  535. void suite_add_tcase(Suite *s, TCase *tc){};
  536. void _tcase_add_test(TCase *tc,
  537. TFun tf,
  538. const char *fname,
  539. int _signal,
  540. int allowed_exit_value,
  541. int start,
  542. int end){};
  543. TCase *tcase_create(const char *name) { return NULL; };
  544. Suite *suite_create(const char *name) { return NULL; };
  545. #endif