You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

701 lines
19 KiB

  1. #include <Python.h>
  2. #include "pythread.h"
  3. #include <inttypes.h>
  4. #include <stdio.h>
  5. #include <wchar.h>
  6. /*********************************************************
  7. * Embedded interpreter tests that need a custom exe
  8. *
  9. * Executed via 'EmbeddingTests' in Lib/test/test_capi.py
  10. *********************************************************/
  11. static void _testembed_Py_Initialize(void)
  12. {
  13. /* HACK: the "./" at front avoids a search along the PATH in
  14. Modules/getpath.c */
  15. Py_SetProgramName(L"./_testembed");
  16. Py_Initialize();
  17. }
  18. /*****************************************************
  19. * Test repeated initialisation and subinterpreters
  20. *****************************************************/
  21. static void print_subinterp(void)
  22. {
  23. /* Output information about the interpreter in the format
  24. expected in Lib/test/test_capi.py (test_subinterps). */
  25. PyThreadState *ts = PyThreadState_Get();
  26. PyInterpreterState *interp = ts->interp;
  27. int64_t id = PyInterpreterState_GetID(interp);
  28. printf("interp %" PRId64 " <0x%" PRIXPTR ">, thread state <0x%" PRIXPTR ">: ",
  29. id, (uintptr_t)interp, (uintptr_t)ts);
  30. fflush(stdout);
  31. PyRun_SimpleString(
  32. "import sys;"
  33. "print('id(modules) =', id(sys.modules));"
  34. "sys.stdout.flush()"
  35. );
  36. }
  37. static int test_repeated_init_and_subinterpreters(void)
  38. {
  39. PyThreadState *mainstate, *substate;
  40. PyGILState_STATE gilstate;
  41. int i, j;
  42. for (i=0; i<15; i++) {
  43. printf("--- Pass %d ---\n", i);
  44. _testembed_Py_Initialize();
  45. mainstate = PyThreadState_Get();
  46. PyEval_InitThreads();
  47. PyEval_ReleaseThread(mainstate);
  48. gilstate = PyGILState_Ensure();
  49. print_subinterp();
  50. PyThreadState_Swap(NULL);
  51. for (j=0; j<3; j++) {
  52. substate = Py_NewInterpreter();
  53. print_subinterp();
  54. Py_EndInterpreter(substate);
  55. }
  56. PyThreadState_Swap(mainstate);
  57. print_subinterp();
  58. PyGILState_Release(gilstate);
  59. PyEval_RestoreThread(mainstate);
  60. Py_Finalize();
  61. }
  62. return 0;
  63. }
  64. /*****************************************************
  65. * Test forcing a particular IO encoding
  66. *****************************************************/
  67. static void check_stdio_details(const char *encoding, const char * errors)
  68. {
  69. /* Output info for the test case to check */
  70. if (encoding) {
  71. printf("Expected encoding: %s\n", encoding);
  72. } else {
  73. printf("Expected encoding: default\n");
  74. }
  75. if (errors) {
  76. printf("Expected errors: %s\n", errors);
  77. } else {
  78. printf("Expected errors: default\n");
  79. }
  80. fflush(stdout);
  81. /* Force the given IO encoding */
  82. Py_SetStandardStreamEncoding(encoding, errors);
  83. _testembed_Py_Initialize();
  84. PyRun_SimpleString(
  85. "import sys;"
  86. "print('stdin: {0.encoding}:{0.errors}'.format(sys.stdin));"
  87. "print('stdout: {0.encoding}:{0.errors}'.format(sys.stdout));"
  88. "print('stderr: {0.encoding}:{0.errors}'.format(sys.stderr));"
  89. "sys.stdout.flush()"
  90. );
  91. Py_Finalize();
  92. }
  93. static int test_forced_io_encoding(void)
  94. {
  95. /* Check various combinations */
  96. printf("--- Use defaults ---\n");
  97. check_stdio_details(NULL, NULL);
  98. printf("--- Set errors only ---\n");
  99. check_stdio_details(NULL, "ignore");
  100. printf("--- Set encoding only ---\n");
  101. check_stdio_details("iso8859-1", NULL);
  102. printf("--- Set encoding and errors ---\n");
  103. check_stdio_details("iso8859-1", "replace");
  104. /* Check calling after initialization fails */
  105. Py_Initialize();
  106. if (Py_SetStandardStreamEncoding(NULL, NULL) == 0) {
  107. printf("Unexpected success calling Py_SetStandardStreamEncoding");
  108. }
  109. Py_Finalize();
  110. return 0;
  111. }
  112. /*********************************************************
  113. * Test parts of the C-API that work before initialization
  114. *********************************************************/
  115. /* The pre-initialization tests tend to break by segfaulting, so explicitly
  116. * flushed progress messages make the broken API easier to find when they fail.
  117. */
  118. #define _Py_EMBED_PREINIT_CHECK(msg) \
  119. do {printf(msg); fflush(stdout);} while (0);
  120. static int test_pre_initialization_api(void)
  121. {
  122. /* Leading "./" ensures getpath.c can still find the standard library */
  123. _Py_EMBED_PREINIT_CHECK("Checking Py_DecodeLocale\n");
  124. wchar_t *program = Py_DecodeLocale("./spam", NULL);
  125. if (program == NULL) {
  126. fprintf(stderr, "Fatal error: cannot decode program name\n");
  127. return 1;
  128. }
  129. _Py_EMBED_PREINIT_CHECK("Checking Py_SetProgramName\n");
  130. Py_SetProgramName(program);
  131. _Py_EMBED_PREINIT_CHECK("Initializing interpreter\n");
  132. Py_Initialize();
  133. _Py_EMBED_PREINIT_CHECK("Check sys module contents\n");
  134. PyRun_SimpleString("import sys; "
  135. "print('sys.executable:', sys.executable)");
  136. _Py_EMBED_PREINIT_CHECK("Finalizing interpreter\n");
  137. Py_Finalize();
  138. _Py_EMBED_PREINIT_CHECK("Freeing memory allocated by Py_DecodeLocale\n");
  139. PyMem_RawFree(program);
  140. return 0;
  141. }
  142. /* bpo-33042: Ensure embedding apps can predefine sys module options */
  143. static int test_pre_initialization_sys_options(void)
  144. {
  145. /* We allocate a couple of the options dynamically, and then delete
  146. * them before calling Py_Initialize. This ensures the interpreter isn't
  147. * relying on the caller to keep the passed in strings alive.
  148. */
  149. const wchar_t *static_warnoption = L"once";
  150. const wchar_t *static_xoption = L"also_not_an_option=2";
  151. size_t warnoption_len = wcslen(static_warnoption);
  152. size_t xoption_len = wcslen(static_xoption);
  153. wchar_t *dynamic_once_warnoption = \
  154. (wchar_t *) calloc(warnoption_len+1, sizeof(wchar_t));
  155. wchar_t *dynamic_xoption = \
  156. (wchar_t *) calloc(xoption_len+1, sizeof(wchar_t));
  157. wcsncpy(dynamic_once_warnoption, static_warnoption, warnoption_len+1);
  158. wcsncpy(dynamic_xoption, static_xoption, xoption_len+1);
  159. _Py_EMBED_PREINIT_CHECK("Checking PySys_AddWarnOption\n");
  160. PySys_AddWarnOption(L"default");
  161. _Py_EMBED_PREINIT_CHECK("Checking PySys_ResetWarnOptions\n");
  162. PySys_ResetWarnOptions();
  163. _Py_EMBED_PREINIT_CHECK("Checking PySys_AddWarnOption linked list\n");
  164. PySys_AddWarnOption(dynamic_once_warnoption);
  165. PySys_AddWarnOption(L"module");
  166. PySys_AddWarnOption(L"default");
  167. _Py_EMBED_PREINIT_CHECK("Checking PySys_AddXOption\n");
  168. PySys_AddXOption(L"not_an_option=1");
  169. PySys_AddXOption(dynamic_xoption);
  170. /* Delete the dynamic options early */
  171. free(dynamic_once_warnoption);
  172. dynamic_once_warnoption = NULL;
  173. free(dynamic_xoption);
  174. dynamic_xoption = NULL;
  175. _Py_EMBED_PREINIT_CHECK("Initializing interpreter\n");
  176. _testembed_Py_Initialize();
  177. _Py_EMBED_PREINIT_CHECK("Check sys module contents\n");
  178. PyRun_SimpleString("import sys; "
  179. "print('sys.warnoptions:', sys.warnoptions); "
  180. "print('sys._xoptions:', sys._xoptions); "
  181. "warnings = sys.modules['warnings']; "
  182. "latest_filters = [f[0] for f in warnings.filters[:3]]; "
  183. "print('warnings.filters[:3]:', latest_filters)");
  184. _Py_EMBED_PREINIT_CHECK("Finalizing interpreter\n");
  185. Py_Finalize();
  186. return 0;
  187. }
  188. /* bpo-20891: Avoid race condition when initialising the GIL */
  189. static void bpo20891_thread(void *lockp)
  190. {
  191. PyThread_type_lock lock = *((PyThread_type_lock*)lockp);
  192. PyGILState_STATE state = PyGILState_Ensure();
  193. if (!PyGILState_Check()) {
  194. fprintf(stderr, "PyGILState_Check failed!");
  195. abort();
  196. }
  197. PyGILState_Release(state);
  198. PyThread_release_lock(lock);
  199. PyThread_exit_thread();
  200. }
  201. static int test_bpo20891(void)
  202. {
  203. /* bpo-20891: Calling PyGILState_Ensure in a non-Python thread before
  204. calling PyEval_InitThreads() must not crash. PyGILState_Ensure() must
  205. call PyEval_InitThreads() for us in this case. */
  206. PyThread_type_lock lock = PyThread_allocate_lock();
  207. if (!lock) {
  208. fprintf(stderr, "PyThread_allocate_lock failed!");
  209. return 1;
  210. }
  211. _testembed_Py_Initialize();
  212. unsigned long thrd = PyThread_start_new_thread(bpo20891_thread, &lock);
  213. if (thrd == PYTHREAD_INVALID_THREAD_ID) {
  214. fprintf(stderr, "PyThread_start_new_thread failed!");
  215. return 1;
  216. }
  217. PyThread_acquire_lock(lock, WAIT_LOCK);
  218. Py_BEGIN_ALLOW_THREADS
  219. /* wait until the thread exit */
  220. PyThread_acquire_lock(lock, WAIT_LOCK);
  221. Py_END_ALLOW_THREADS
  222. PyThread_free_lock(lock);
  223. return 0;
  224. }
  225. static int test_initialize_twice(void)
  226. {
  227. _testembed_Py_Initialize();
  228. /* bpo-33932: Calling Py_Initialize() twice should do nothing
  229. * (and not crash!). */
  230. Py_Initialize();
  231. Py_Finalize();
  232. return 0;
  233. }
  234. static int test_initialize_pymain(void)
  235. {
  236. wchar_t *argv[] = {L"PYTHON", L"-c",
  237. L"import sys; print(f'Py_Main() after Py_Initialize: sys.argv={sys.argv}')",
  238. L"arg2"};
  239. _testembed_Py_Initialize();
  240. /* bpo-34008: Calling Py_Main() after Py_Initialize() must not crash */
  241. Py_Main(Py_ARRAY_LENGTH(argv), argv);
  242. Py_Finalize();
  243. return 0;
  244. }
  245. static int
  246. dump_config_impl(void)
  247. {
  248. PyObject *config = NULL;
  249. PyObject *dict = NULL;
  250. config = PyDict_New();
  251. if (config == NULL) {
  252. goto error;
  253. }
  254. /* global config */
  255. dict = _Py_GetGlobalVariablesAsDict();
  256. if (dict == NULL) {
  257. goto error;
  258. }
  259. if (PyDict_SetItemString(config, "global_config", dict) < 0) {
  260. goto error;
  261. }
  262. Py_CLEAR(dict);
  263. /* core config */
  264. PyInterpreterState *interp = _PyInterpreterState_Get();
  265. const _PyCoreConfig *core_config = &interp->core_config;
  266. dict = _PyCoreConfig_AsDict(core_config);
  267. if (dict == NULL) {
  268. goto error;
  269. }
  270. if (PyDict_SetItemString(config, "core_config", dict) < 0) {
  271. goto error;
  272. }
  273. Py_CLEAR(dict);
  274. /* main config */
  275. const _PyMainInterpreterConfig *main_config = &interp->config;
  276. dict = _PyMainInterpreterConfig_AsDict(main_config);
  277. if (dict == NULL) {
  278. goto error;
  279. }
  280. if (PyDict_SetItemString(config, "main_config", dict) < 0) {
  281. goto error;
  282. }
  283. Py_CLEAR(dict);
  284. PyObject *json = PyImport_ImportModule("json");
  285. PyObject *res = PyObject_CallMethod(json, "dumps", "O", config);
  286. Py_DECREF(json);
  287. Py_CLEAR(config);
  288. if (res == NULL) {
  289. goto error;
  290. }
  291. PySys_FormatStdout("%S\n", res);
  292. Py_DECREF(res);
  293. return 0;
  294. error:
  295. Py_XDECREF(config);
  296. Py_XDECREF(dict);
  297. return -1;
  298. }
  299. static void
  300. dump_config(void)
  301. {
  302. if (dump_config_impl() < 0) {
  303. fprintf(stderr, "failed to dump the configuration:\n");
  304. PyErr_Print();
  305. }
  306. }
  307. static int test_init_default_config(void)
  308. {
  309. _testembed_Py_Initialize();
  310. dump_config();
  311. Py_Finalize();
  312. return 0;
  313. }
  314. static int test_init_global_config(void)
  315. {
  316. /* FIXME: test Py_IgnoreEnvironmentFlag */
  317. putenv("PYTHONUTF8=0");
  318. Py_UTF8Mode = 1;
  319. /* Test initialization from global configuration variables (Py_xxx) */
  320. Py_SetProgramName(L"./globalvar");
  321. /* Py_IsolatedFlag is not tested */
  322. Py_NoSiteFlag = 1;
  323. Py_BytesWarningFlag = 1;
  324. putenv("PYTHONINSPECT=");
  325. Py_InspectFlag = 1;
  326. putenv("PYTHONOPTIMIZE=0");
  327. Py_InteractiveFlag = 1;
  328. putenv("PYTHONDEBUG=0");
  329. Py_OptimizeFlag = 2;
  330. /* Py_DebugFlag is not tested */
  331. putenv("PYTHONDONTWRITEBYTECODE=");
  332. Py_DontWriteBytecodeFlag = 1;
  333. putenv("PYTHONVERBOSE=0");
  334. Py_VerboseFlag = 1;
  335. Py_QuietFlag = 1;
  336. Py_NoUserSiteDirectory = 1;
  337. putenv("PYTHONUNBUFFERED=");
  338. Py_UnbufferedStdioFlag = 1;
  339. Py_FrozenFlag = 1;
  340. /* FIXME: test Py_LegacyWindowsFSEncodingFlag */
  341. /* FIXME: test Py_LegacyWindowsStdioFlag */
  342. Py_Initialize();
  343. dump_config();
  344. Py_Finalize();
  345. return 0;
  346. }
  347. static int test_init_from_config(void)
  348. {
  349. /* Test _Py_InitializeFromConfig() */
  350. _PyCoreConfig config = _PyCoreConfig_INIT;
  351. config.install_signal_handlers = 0;
  352. /* FIXME: test use_environment */
  353. putenv("PYTHONHASHSEED=42");
  354. config.use_hash_seed = 1;
  355. config.hash_seed = 123;
  356. putenv("PYTHONMALLOC=malloc");
  357. config.allocator = "malloc_debug";
  358. /* dev_mode=1 is tested in test_init_dev_mode() */
  359. putenv("PYTHONFAULTHANDLER=");
  360. config.faulthandler = 1;
  361. putenv("PYTHONTRACEMALLOC=0");
  362. config.tracemalloc = 2;
  363. putenv("PYTHONPROFILEIMPORTTIME=0");
  364. config.import_time = 1;
  365. config.show_ref_count = 1;
  366. config.show_alloc_count = 1;
  367. /* FIXME: test dump_refs: bpo-34223 */
  368. putenv("PYTHONMALLOCSTATS=0");
  369. config.malloc_stats = 1;
  370. /* FIXME: test coerce_c_locale and coerce_c_locale_warn */
  371. putenv("PYTHONUTF8=0");
  372. Py_UTF8Mode = 0;
  373. config.utf8_mode = 1;
  374. putenv("PYTHONPYCACHEPREFIX=env_pycache_prefix");
  375. config.pycache_prefix = L"conf_pycache_prefix";
  376. Py_SetProgramName(L"./globalvar");
  377. config.program_name = L"./conf_program_name";
  378. static wchar_t* argv[2] = {
  379. L"-c",
  380. L"pass",
  381. };
  382. config.argc = Py_ARRAY_LENGTH(argv);
  383. config.argv = argv;
  384. config.program = L"conf_program";
  385. static wchar_t* xoptions[3] = {
  386. L"core_xoption1=3",
  387. L"core_xoption2=",
  388. L"core_xoption3",
  389. };
  390. config.nxoption = Py_ARRAY_LENGTH(xoptions);
  391. config.xoptions = xoptions;
  392. static wchar_t* warnoptions[2] = {
  393. L"default",
  394. L"error::ResourceWarning",
  395. };
  396. config.nwarnoption = Py_ARRAY_LENGTH(warnoptions);
  397. config.warnoptions = warnoptions;
  398. /* FIXME: test module_search_path_env */
  399. /* FIXME: test home */
  400. /* FIXME: test path config: module_search_path .. dll_path */
  401. putenv("PYTHONVERBOSE=0");
  402. Py_VerboseFlag = 0;
  403. config.verbose = 1;
  404. Py_NoSiteFlag = 0;
  405. config.site_import = 0;
  406. Py_BytesWarningFlag = 0;
  407. config.bytes_warning = 1;
  408. putenv("PYTHONINSPECT=");
  409. Py_InspectFlag = 0;
  410. config.inspect = 1;
  411. Py_InteractiveFlag = 0;
  412. config.interactive = 1;
  413. putenv("PYTHONOPTIMIZE=0");
  414. Py_OptimizeFlag = 1;
  415. config.optimization_level = 2;
  416. /* FIXME: test parser_debug */
  417. putenv("PYTHONDONTWRITEBYTECODE=");
  418. Py_DontWriteBytecodeFlag = 0;
  419. config.write_bytecode = 0;
  420. Py_QuietFlag = 0;
  421. config.quiet = 1;
  422. putenv("PYTHONUNBUFFERED=");
  423. Py_UnbufferedStdioFlag = 0;
  424. config.buffered_stdio = 0;
  425. putenv("PYTHONIOENCODING=cp424");
  426. Py_SetStandardStreamEncoding("ascii", "ignore");
  427. #ifdef MS_WINDOWS
  428. /* Py_SetStandardStreamEncoding() sets Py_LegacyWindowsStdioFlag to 1.
  429. Force it to 0 through the config. */
  430. config.legacy_windows_stdio = 0;
  431. #endif
  432. config.stdio_encoding = "iso8859-1";
  433. config.stdio_errors = "replace";
  434. putenv("PYTHONNOUSERSITE=");
  435. Py_NoUserSiteDirectory = 0;
  436. config.user_site_directory = 0;
  437. config._check_hash_pycs_mode = "always";
  438. Py_FrozenFlag = 0;
  439. config._frozen = 1;
  440. _PyInitError err = _Py_InitializeFromConfig(&config);
  441. /* Don't call _PyCoreConfig_Clear() since all strings are static */
  442. if (_Py_INIT_FAILED(err)) {
  443. _Py_FatalInitError(err);
  444. }
  445. dump_config();
  446. Py_Finalize();
  447. return 0;
  448. }
  449. static void test_init_env_putenvs(void)
  450. {
  451. putenv("PYTHONHASHSEED=42");
  452. putenv("PYTHONMALLOC=malloc_debug");
  453. putenv("PYTHONTRACEMALLOC=2");
  454. putenv("PYTHONPROFILEIMPORTTIME=1");
  455. putenv("PYTHONMALLOCSTATS=1");
  456. putenv("PYTHONUTF8=1");
  457. putenv("PYTHONVERBOSE=1");
  458. putenv("PYTHONINSPECT=1");
  459. putenv("PYTHONOPTIMIZE=2");
  460. putenv("PYTHONDONTWRITEBYTECODE=1");
  461. putenv("PYTHONUNBUFFERED=1");
  462. putenv("PYTHONPYCACHEPREFIX=env_pycache_prefix");
  463. putenv("PYTHONNOUSERSITE=1");
  464. putenv("PYTHONFAULTHANDLER=1");
  465. putenv("PYTHONDEVMODE=1");
  466. putenv("PYTHONIOENCODING=iso8859-1:replace");
  467. /* FIXME: test PYTHONWARNINGS */
  468. /* FIXME: test PYTHONEXECUTABLE */
  469. /* FIXME: test PYTHONHOME */
  470. /* FIXME: test PYTHONDEBUG */
  471. /* FIXME: test PYTHONDUMPREFS */
  472. /* FIXME: test PYTHONCOERCECLOCALE */
  473. /* FIXME: test PYTHONPATH */
  474. }
  475. static int test_init_env(void)
  476. {
  477. /* Test initialization from environment variables */
  478. Py_IgnoreEnvironmentFlag = 0;
  479. test_init_env_putenvs();
  480. _testembed_Py_Initialize();
  481. dump_config();
  482. Py_Finalize();
  483. return 0;
  484. }
  485. static int test_init_isolated(void)
  486. {
  487. /* Test _PyCoreConfig.isolated=1 */
  488. _PyCoreConfig config = _PyCoreConfig_INIT;
  489. /* Set coerce_c_locale and utf8_mode to not depend on the locale */
  490. config.coerce_c_locale = 0;
  491. config.utf8_mode = 0;
  492. /* Use path starting with "./" avoids a search along the PATH */
  493. config.program_name = L"./_testembed";
  494. Py_IsolatedFlag = 0;
  495. config.isolated = 1;
  496. test_init_env_putenvs();
  497. _PyInitError err = _Py_InitializeFromConfig(&config);
  498. if (_Py_INIT_FAILED(err)) {
  499. _Py_FatalInitError(err);
  500. }
  501. dump_config();
  502. Py_Finalize();
  503. return 0;
  504. }
  505. static int test_init_dev_mode(void)
  506. {
  507. _PyCoreConfig config = _PyCoreConfig_INIT;
  508. putenv("PYTHONFAULTHANDLER=");
  509. putenv("PYTHONMALLOC=");
  510. config.dev_mode = 1;
  511. config.program_name = L"./_testembed";
  512. _PyInitError err = _Py_InitializeFromConfig(&config);
  513. if (_Py_INIT_FAILED(err)) {
  514. _Py_FatalInitError(err);
  515. }
  516. dump_config();
  517. Py_Finalize();
  518. return 0;
  519. }
  520. /* *********************************************************
  521. * List of test cases and the function that implements it.
  522. *
  523. * Names are compared case-sensitively with the first
  524. * argument. If no match is found, or no first argument was
  525. * provided, the names of all test cases are printed and
  526. * the exit code will be -1.
  527. *
  528. * The int returned from test functions is used as the exit
  529. * code, and test_capi treats all non-zero exit codes as a
  530. * failed test.
  531. *********************************************************/
  532. struct TestCase
  533. {
  534. const char *name;
  535. int (*func)(void);
  536. };
  537. static struct TestCase TestCases[] = {
  538. { "forced_io_encoding", test_forced_io_encoding },
  539. { "repeated_init_and_subinterpreters", test_repeated_init_and_subinterpreters },
  540. { "pre_initialization_api", test_pre_initialization_api },
  541. { "pre_initialization_sys_options", test_pre_initialization_sys_options },
  542. { "bpo20891", test_bpo20891 },
  543. { "initialize_twice", test_initialize_twice },
  544. { "initialize_pymain", test_initialize_pymain },
  545. { "init_default_config", test_init_default_config },
  546. { "init_global_config", test_init_global_config },
  547. { "init_from_config", test_init_from_config },
  548. { "init_env", test_init_env },
  549. { "init_dev_mode", test_init_dev_mode },
  550. { "init_isolated", test_init_isolated },
  551. { NULL, NULL }
  552. };
  553. int main(int argc, char *argv[])
  554. {
  555. if (argc > 1) {
  556. for (struct TestCase *tc = TestCases; tc && tc->name; tc++) {
  557. if (strcmp(argv[1], tc->name) == 0)
  558. return (*tc->func)();
  559. }
  560. }
  561. /* No match found, or no test name provided, so display usage */
  562. printf("Python " PY_VERSION " _testembed executable for embedded interpreter tests\n"
  563. "Normally executed via 'EmbeddingTests' in Lib/test/test_embed.py\n\n"
  564. "Usage: %s TESTNAME\n\nAll available tests:\n", argv[0]);
  565. for (struct TestCase *tc = TestCases; tc && tc->name; tc++) {
  566. printf(" %s\n", tc->name);
  567. }
  568. /* Non-zero exit code will cause test_embed.py tests to fail.
  569. This is intentional. */
  570. return -1;
  571. }