forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stackless issue python#218: Cleanups and test infrastructure for embe…
…dded SLP - Fix test_outside to reset cstack_base and cstack_root. Now the simulation of a call from outside is complete. - Add test_slp_embed to test embedding Stackless
- Loading branch information
Anselm Kruis
committed
Jul 1, 2019
1 parent
8ae5fe5
commit 7047bf0
Showing
8 changed files
with
120 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <stackless_api.h> | ||
|
||
|
||
static int slp_test_schedule(void) | ||
{ | ||
_testembed_Py_Initialize(); | ||
PyRun_SimpleString( | ||
"import stackless\n" | ||
"import sysconfig\n" | ||
"stackless.tasklet(print)('Hello, World!')\n" | ||
); | ||
if (!PyStackless_Schedule(Py_None, 0)) | ||
PyErr_Print(); | ||
Py_Finalize(); | ||
return 0; | ||
} | ||
|
||
|
||
static struct TestCase SlpTestCases[] = { | ||
{ "slp_schedule", slp_test_schedule }, | ||
{ NULL, NULL } | ||
}; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int wrapped_main(int, char **); | ||
|
||
if (argc > 1) { | ||
for (struct TestCase *tc = SlpTestCases; tc && tc->name; tc++) { | ||
if (strcmp(argv[1], tc->name) == 0) | ||
return (*tc->func)(); | ||
} | ||
return wrapped_main(argc, argv); | ||
} | ||
|
||
/* No match found, or no test name provided, so display usage */ | ||
wrapped_main(argc, argv); | ||
for (struct TestCase *tc = SlpTestCases; tc && tc->name; tc++) { | ||
printf(" %s\n", tc->name); | ||
} | ||
|
||
/* Non-zero exit code will cause test_embed.py tests to fail. | ||
This is intentional. */ | ||
return -1; | ||
} | ||
|
||
|
||
#define main wrapped_main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Run the tests in Stackless/unittests/_testembed_slp.c | ||
# (tests for the Stackless Python embedding APIs) | ||
"""Test the (Stackless)-Python C-API | ||
Tests not relevant for pure Python code. | ||
""" | ||
|
||
from __future__ import print_function, absolute_import, division | ||
|
||
import unittest | ||
import os | ||
import sys | ||
|
||
from support import test_main # @UnusedImport | ||
|
||
from test.test_embed import EmbeddingTestsMixin | ||
from test.support import verbose | ||
|
||
|
||
@unittest.skip("Stackless issue 218") | ||
class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase): | ||
def test_schedule(self): | ||
env = dict(os.environ) | ||
out, err = self.run_embedded_interpreter("slp_schedule", env=env) | ||
if verbose > 1: | ||
print() | ||
print(out) | ||
print(err) | ||
expected_output = '\n'.join([ | ||
"Hello, World!"]) | ||
# This is useful if we ever trip over odd platform behaviour | ||
self.maxDiff = None | ||
self.assertEqual(out.strip(), expected_output) | ||
|
||
|
||
if __name__ == "__main__": | ||
if not sys.argv[1:]: | ||
sys.argv.append('-v') | ||
unittest.main() |