forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntests.c
More file actions
48 lines (39 loc) · 1.11 KB
/
runtests.c
File metadata and controls
48 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <check.h>
#include <Python.h>
void register_PyObject(Suite *s);
void register_PyTuple(Suite *s);
int main(void)
{
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x03080000
_PyCoreConfig config = _PyCoreConfig_INIT;
config._frozen = 1; /* Disable warnings about missing prefix */
_PyInitError err = _Py_InitializeFromConfig(&config);
if (_Py_INIT_FAILED(err)) {
_Py_FatalInitError(err);
}
#else
Py_Initialize();
#endif
int exitcode;
#ifdef Py_REF_DEBUG
Py_ssize_t ref_total = _Py_RefTotal;
#endif
Suite *s = suite_create("CAPI");
register_PyObject(s);
register_PyTuple(s);
SRunner *sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
int number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
exitcode = (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
#ifdef Py_REF_DEBUG
Py_ssize_t ref_diff = _Py_RefTotal - ref_total;
if (ref_diff != 0) {
printf("ERROR: total reference count changed: %+zi!\n", ref_diff);
exitcode = EXIT_FAILURE;
}
#endif
Py_Finalize();
return exitcode;
}