From 04a61d0e21ca203b1fbfbcc910d164046fcad7fa Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 1 Nov 2017 12:03:59 +0530 Subject: [PATCH] Convert test-launcher into a generic asan-launcher so that it can be used to run kitty as well --- .gitignore | 2 +- .travis.yml | 3 +-- asan-launcher.c | 17 +++++++++++++++++ setup.py | 16 +++++++++------- test-launcher.c | 13 ------------- 5 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 asan-launcher.c delete mode 100644 test-launcher.c diff --git a/.gitignore b/.gitignore index fc236403b..bc2c4adab 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ tags build linux-package logo/*.iconset -test-launcher +asan-launcher kitty-profile dev __pycache__ diff --git a/.travis.yml b/.travis.yml index 57324e289..0cc3ffe98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -114,9 +114,8 @@ install: | before_script: - echo $LD_LIBRARY_PATH - $PYTHON setup.py build --debug $SANITIZE_ARG; - - if [[ "$TRAVIS_OS_NAME" != 'osx' ]]; then ldd ./test-launcher `which $PYTHON`; fi script: - - ./test-launcher + - if [[ -z $SANITIZE_ARG ]]; then $PYTHON test.py; else ./asan-launcher test; fi - if [[ "$RUN_FLAKE" == "1" ]]; then flake8 --count .; fi - if [[ "$BUILD_PKG" == "1" ]]; then $PYTHON setup.py linux-package; fi diff --git a/asan-launcher.c b/asan-launcher.c new file mode 100644 index 000000000..a63bf9c49 --- /dev/null +++ b/asan-launcher.c @@ -0,0 +1,17 @@ +/* + * linux-launcher.c + * Copyright (C) 2017 Kovid Goyal + * + * Distributed under terms of the GPL3 license. + */ + +#include + +#define MAX_ARGC 1024 + +int main(int argc, char *argv[]) { + wchar_t *argvw[MAX_ARGC + 1] = {0}; + argvw[0] = L"kitty"; + for (int i = 1; i < argc; i++) argvw[i] = Py_DecodeLocale(argv[i], NULL); + return Py_Main(argc, argvw); +} diff --git a/setup.py b/setup.py index 2754935b9..5ff69214b 100755 --- a/setup.py +++ b/setup.py @@ -333,15 +333,17 @@ def safe_makedirs(path): os.makedirs(path, exist_ok=True) -def build_test_launcher(args): +def build_asan_launcher(args): + dest = 'asan-launcher' + src = 'asan-launcher.c' + if args.incremental and not newer(dest, src): + return cc, ccver = cc_version() cflags = '-g -Wall -Werror -fpie'.split() pylib = get_python_flags(cflags) - sanitize_lib = (['-lasan'] if cc == 'gcc' else []) if args.sanitize else [] - cflags.extend(get_sanitize_args(cc, ccver) if args.sanitize else []) - cmd = [cc] + cflags + [ - 'test-launcher.c', '-o', 'test-launcher', - ] + sanitize_lib + pylib + sanitize_lib = ['-lasan'] if cc == 'gcc' else [] + cflags.extend(get_sanitize_args(cc, ccver)) + cmd = [cc] + cflags + [src, '-o', dest] + sanitize_lib + pylib run_tool(cmd) @@ -444,7 +446,7 @@ def main(): os.chdir(os.path.dirname(os.path.abspath(__file__))) if args.action == 'build': build(args) - build_test_launcher(args) + build_asan_launcher(args) if args.profile: build_linux_launcher(args) print('kitty profile executable is', 'kitty-profile') diff --git a/test-launcher.c b/test-launcher.c deleted file mode 100644 index 916faaa02..000000000 --- a/test-launcher.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * linux-launcher.c - * Copyright (C) 2017 Kovid Goyal - * - * Distributed under terms of the GPL3 license. - */ - -#include - -int main(int argc, char *argv[]) { - wchar_t *wargv[2] = {L"kitty-test", L"test.py"}; - return Py_Main(2, wargv); -}