From b67a024460e3d3d98d6e2a593375767757453957 Mon Sep 17 00:00:00 2001 From: Thomas Orozco Date: Fri, 4 Nov 2016 17:13:08 +0100 Subject: [PATCH] Rename NO_ARGS to MINIMAL --- .travis.yml | 10 +++++----- CMakeLists.txt | 6 +++--- ci/run_build.sh | 28 +++++++++++++++++----------- ddist.sh | 2 +- src/tini.c | 10 +++++----- test/run_inner_tests.py | 4 ++-- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7598e6..4720717 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,10 @@ language: generic env: matrix: - - CC=gcc ARCH_SUFFIX=amd64 ARCH_NATIVE=1 NO_ARGS= - - CC=arm-linux-gnueabihf-gcc ARCH_SUFFIX=armhf ARCH_NATIVE= NO_ARGS= - - CC=aarch64-linux-gnu-gcc ARCH_SUFFIX=arm64 ARCH_NATIVE= NO_ARGS= - - CC=gcc ARCH_SUFFIX=amd64 ARCH_NATIVE=1 NO_ARGS=1 + - CC=gcc ARCH_SUFFIX=amd64 ARCH_NATIVE=1 MINIMAL= + - CC=arm-linux-gnueabihf-gcc ARCH_SUFFIX=armhf ARCH_NATIVE= MINIMAL= + - CC=aarch64-linux-gnu-gcc ARCH_SUFFIX=arm64 ARCH_NATIVE= MINIMAL= + - CC=gcc ARCH_SUFFIX=amd64 ARCH_NATIVE=1 MINIMAL=1 global: - SIGN_BINARIES=1 - secure: "RKF9Z9gLxp6k/xITqn7ma1E9HfpYcDXuJFf4862WeH9EMnK9lDq+TWnGsQfkIlqh8h9goe7U+BvRiTibj9MiD5u7eluLo3dlwsLxPpYtyswYeLeC1wKKdT5LPGAXbRKomvBalRYMI+dDnGIM4w96mHgGGvx2zZXGkiAQhm6fJ3k=" @@ -31,4 +31,4 @@ deploy: on: repo: krallin/tini tags: true - condition: '-z "$NO_ARGS"' + condition: '-z "$MINIMAL"' diff --git a/CMakeLists.txt b/CMakeLists.txt index e664e1b..894d280 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,10 @@ set (tini_VERSION_MINOR 12) set (tini_VERSION_PATCH 0) # Build options -option(NO_ARGS "Disable argument parsing" OFF) +option(MINIMAL "Disable argument parsing and verbose output" OFF) -if(NO_ARGS) - add_definitions(-DTINI_NO_ARGS=1) +if(MINIMAL) + add_definitions(-DTINI_MINIMAL=1) endif() # Extract git version and dirty-ness diff --git a/ci/run_build.sh b/ci/run_build.sh index 1f1abda..728da5c 100755 --- a/ci/run_build.sh +++ b/ci/run_build.sh @@ -45,8 +45,8 @@ export PATH="${SOURCE_DIR}/ci/util:${PATH}" # Build CMAKE_ARGS=(-B"${BUILD_DIR}" -H"${SOURCE_DIR}") -if [[ -n "${NO_ARGS:-}" ]]; then - CMAKE_ARGS+=(-DNO_ARGS=ON) +if [[ -n "${MINIMAL:-}" ]]; then + CMAKE_ARGS+=(-DMINIMAL=ON) fi cmake "${CMAKE_ARGS[@]}" @@ -77,7 +77,15 @@ if [[ -n "${ARCH_NATIVE:=}" ]]; then echo "Testing ${tini} --version" "$tini" --version | grep -q "tini version" - if [[ -n "${NO_ARGS:-}" ]]; then + echo "Testing ${tini} without arguments exits with 1" + ! "$tini" 2>/dev/null + + echo "Testing ${tini} shows help message" + { + ! "$tini" 2>&1 + } | grep -q "supervision of a valid init process" + + if [[ -n "${MINIMAL:-}" ]]; then echo "Testing $tini with: true" "${tini}" true @@ -86,14 +94,7 @@ if [[ -n "${ARCH_NATIVE:=}" ]]; then exit 1 fi - echo "Testing ${tini} without arguments exits with 1" - ! "$tini" 2>/dev/null - - echo "Testing ${tini} shows help message" - { - ! "$tini" 2>&1 - } | grep -q "supervision of a valid init process" - + echo "Testing ${tini} does not reference options that don't exist" ! { ! "$tini" 2>&1 } | grep -q "more verbose" @@ -126,6 +127,11 @@ if [[ -n "${ARCH_NATIVE:=}" ]]; then if "${tini}" -vvv false; then exit 1 fi + + echo "Testing ${tini} references options that exist" + { + ! "$tini" 2>&1 + } | grep -q "more verbose" fi echo "Testing ${tini} supports TINI_VERBOSITY" diff --git a/ddist.sh b/ddist.sh index 52d9d4c..9370912 100755 --- a/ddist.sh +++ b/ddist.sh @@ -24,5 +24,5 @@ docker run -it --rm \ -e CC="${CC:=gcc}" \ -e ARCH_NATIVE="${ARCH_NATIVE-1}" \ -e ARCH_SUFFIX="${ARCH_SUFFIX-}" \ - -e NO_ARGS="${NO_ARGS-}" \ + -e MINIMAL="${MINIMAL-}" \ "${IMG}" "${SRC}/ci/run_build.sh" diff --git a/src/tini.c b/src/tini.c index 842f158..267a0de 100644 --- a/src/tini.c +++ b/src/tini.c @@ -17,7 +17,7 @@ #include "tiniConfig.h" #include "tiniLicense.h" -#if TINI_NO_ARGS +#if TINI_MINIMAL #define PRINT_FATAL(...) fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); #define PRINT_WARNING(...) if (verbosity > 0) { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); } #define PRINT_INFO(...) if (verbosity > 1) { fprintf(stdout, __VA_ARGS__); fprintf(stdout, "\n"); } @@ -72,7 +72,7 @@ static const char reaper_warning[] = "Tini is not running as PID 1 " Zombie processes will not be re-parented to Tini, so zombie reaping won't work.\n\ To fix the problem, " #if HAS_SUBREAPER -#ifndef TINI_NO_ARGS +#ifndef TINI_MINIMAL "use the -s option " #endif "or set the environment variable " SUBREAPER_ENV_VAR " to register Tini as a child subreaper, or " @@ -174,7 +174,7 @@ int spawn(const signal_configuration_t* const sigconf_ptr, char* const argv[], i void print_usage(char* const name, FILE* const file) { fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING); -#if TINI_NO_ARGS +#if TINI_MINIMAL fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", basename(name)); #else fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] | --version\n\n", basename(name)); @@ -185,7 +185,7 @@ void print_usage(char* const name, FILE* const file) { fprintf(file, " --version: Show version and exit.\n"); -#if TINI_NO_ARGS +#if TINI_MINIMAL #else fprintf(file, " -h: Show this help message and exit.\n"); #if HAS_SUBREAPER @@ -222,7 +222,7 @@ int parse_args(const int argc, char* const argv[], char* (**child_args_ptr_ptr)[ return 1; } -#ifndef TINI_NO_ARGS +#ifndef TINI_MINIMAL int c; while ((c = getopt(argc, argv, OPT_STRING)) != -1) { switch (c) { diff --git a/test/run_inner_tests.py b/test/run_inner_tests.py index b65d153..e79338e 100755 --- a/test/run_inner_tests.py +++ b/test/run_inner_tests.py @@ -29,7 +29,7 @@ def main(): src = os.environ["SOURCE_DIR"] build = os.environ["BUILD_DIR"] - args_disabled = os.environ.get("NO_ARGS") + args_disabled = os.environ.get("MINIMAL") proxy = os.path.join(src, "test", "subreaper-proxy.py") tini = os.path.join(build, "tini") @@ -81,7 +81,7 @@ def main(): busy_wait(lambda: p.poll() is not None, 10) # Run failing test. Force verbosity to 1 so we see the subreaper warning - # regardless of whether NO_ARGS is set. + # regardless of whether MINIMAL is set. print "Running zombie reaping failure test (Tini should warn)" p = subprocess.Popen( [tini, os.path.join(src, "test", "reaping", "stage_1.py")],