From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 64A3C139694 for ; Thu, 9 Feb 2017 18:16:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 42568E0CB9; Thu, 9 Feb 2017 18:16:26 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0F435E0CB9 for ; Thu, 9 Feb 2017 18:16:26 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DCDBA33FECD for ; Thu, 9 Feb 2017 18:16:24 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 805AE3EA3 for ; Thu, 9 Feb 2017 18:16:23 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1486664167.9470312c23d126f0055f82c0e656003b3945430b.vapier@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/multiprocessing.eclass eclass/tests/multiprocessing_makeopts_jobs.sh eclass/tests/multiprocessing_makeopts_loadavg.sh X-VCS-Directories: eclass/ eclass/tests/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 9470312c23d126f0055f82c0e656003b3945430b X-VCS-Branch: master Date: Thu, 9 Feb 2017 18:16:23 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: fd6ee940-b2f0-4a1a-a3a7-563db288f425 X-Archives-Hash: 632ccbaea4a1ef9b3c39fecff5a2bc70 commit: 9470312c23d126f0055f82c0e656003b3945430b Author: Mike Frysinger gentoo org> AuthorDate: Thu Feb 9 18:15:13 2017 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Thu Feb 9 18:16:07 2017 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9470312c multiprocess.eclass: makeopts_{jobs,loadavg}: fix implicit handling of $MAKEOPTS #608242 We missed quoting on ${MAKEOPTS} to set it as the first arg which meant we might load invalid values into the second arg which is the "infinite" scenario. eclass/multiprocessing.eclass | 4 ++-- eclass/tests/multiprocessing_makeopts_jobs.sh | 12 +++++++++--- eclass/tests/multiprocessing_makeopts_loadavg.sh | 11 ++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass index 67f7e2d65b..73d852410b 100644 --- a/eclass/multiprocessing.eclass +++ b/eclass/multiprocessing.eclass @@ -96,7 +96,7 @@ get_nproc() { # no way to represent infinity, we return ${inf} (defaults to 999) if the user # has -j without a number. makeopts_jobs() { - [[ $# -eq 0 ]] && set -- ${MAKEOPTS} + [[ $# -eq 0 ]] && set -- "${MAKEOPTS}" # This assumes the first .* will be more greedy than the second .* # since POSIX doesn't specify a non-greedy match (i.e. ".*?"). local jobs=$(echo " $* " | sed -r -n \ @@ -117,7 +117,7 @@ makeopts_jobs() { # If no limit is specified or --load-average is used without a number, ${inf} # (defaults to 999) is returned. makeopts_loadavg() { - [[ $# -eq 0 ]] && set -- ${MAKEOPTS} + [[ $# -eq 0 ]] && set -- "${MAKEOPTS}" # This assumes the first .* will be more greedy than the second .* # since POSIX doesn't specify a non-greedy match (i.e. ".*?"). local lavg=$(echo " $* " | sed -r -n \ diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh index ef477277ab..cc4f91b694 100755 --- a/eclass/tests/multiprocessing_makeopts_jobs.sh +++ b/eclass/tests/multiprocessing_makeopts_jobs.sh @@ -10,14 +10,20 @@ inherit multiprocessing test-makeopts_jobs() { local exp=$1; shift tbegin "makeopts_jobs($1${2+; inf=${2}}) == ${exp}" - local act=$(makeopts_jobs "$@") - [[ ${act} == "${exp}" ]] - tend $? "Got back: ${act}" + local indirect=$(MAKEOPTS="$*" makeopts_jobs) + local direct=$(makeopts_jobs "$@") + if [[ "${direct}" != "${indirect}" ]] ; then + tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'" + else + [[ ${direct} == "${exp}" ]] + tend $? "Got back: ${act}" + fi } tests=( 999 "-j" 999 "--jobs" + 999 "-j -l9" 1 "" 1 "-l9 -w" 1 "-l9 -w-j4" diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh index 6b976beb1a..ffa679d13e 100755 --- a/eclass/tests/multiprocessing_makeopts_loadavg.sh +++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh @@ -10,9 +10,14 @@ inherit multiprocessing test-makeopts_loadavg() { local exp=$1; shift tbegin "makeopts_loadavg($1${2+; inf=${2}}) == ${exp}" - local act=$(makeopts_loadavg "$@") - [[ ${act} == "${exp}" ]] - tend $? "Got back: ${act}" + local indirect=$(MAKEOPTS="$*" makeopts_loadavg) + local direct=$(makeopts_loadavg "$@") + if [[ "${direct}" != "${indirect}" ]] ; then + tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'" + else + [[ ${direct} == "${exp}" ]] + tend $? "Got back: ${act}" + fi } tests=(