From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C3D521384B4 for ; Tue, 24 Nov 2015 17:04:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AEB1121C090; Tue, 24 Nov 2015 17:04:05 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3D7E721C090 for ; Tue, 24 Nov 2015 17:04:05 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3E63C34078E for ; Tue, 24 Nov 2015 17:04:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2B44F706 for ; Tue, 24 Nov 2015 17:03:58 +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: <1448384629.ddd7a0bc1e06c0f7737799b784c110b7903f0a58.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_loadavg.sh X-VCS-Directories: eclass/ eclass/tests/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: ddd7a0bc1e06c0f7737799b784c110b7903f0a58 X-VCS-Branch: master Date: Tue, 24 Nov 2015 17:03:58 +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: 65ecf283-f9a8-45b4-ae64-2f0abdb4e5e4 X-Archives-Hash: 9bcfab499750483406e5bfb05d545d22 commit: ddd7a0bc1e06c0f7737799b784c110b7903f0a58 Author: Mike Frysinger gentoo org> AuthorDate: Tue Nov 24 17:02:31 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Tue Nov 24 17:03:49 2015 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ddd7a0bc multiprocessing.eclass: makeopts_loadavg: various fixes #543116 - Add support for --max-load option - Fix default load value if not specified (999) - Fix trailing flag consumption so we don't leave garbage behind - Add tests! eclass/multiprocessing.eclass | 7 +++-- eclass/tests/multiprocessing_makeopts_loadavg.sh | 36 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass index 534b35c..06e004a 100644 --- a/eclass/multiprocessing.eclass +++ b/eclass/multiprocessing.eclass @@ -86,9 +86,10 @@ makeopts_loadavg() { # 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 \ - -e 's:.*[[:space:]](-l|--load-average[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+)[^0-9.]*:\2:p' \ - -e 's:.*[[:space:]](-l|--load-average)[[:space:]].*:999:p') - echo ${lavg:-1} + -e 's:.*[[:space:]](-l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \ + -e 's:.*[[:space:]](-l|--(load-average|max-load))[[:space:]].*:999:p') + # Default to 999 since the default is to not use a load limit. + echo ${lavg:-999} } # @FUNCTION: multijob_init diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh new file mode 100755 index 0000000..12f9d01 --- /dev/null +++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit multiprocessing + +test-makeopts_loadavg() { + local exp=$1; shift + tbegin "makeopts_loadavg($*) == ${exp}" + local act=$(makeopts_loadavg "$@") + [[ ${act} == "${exp}" ]] + tend $? "Got back: ${act}" +} + +tests=( + 999 "-j" + 999 "-l" + 999 "" + 9 "-l9 -w" + 9 "-l 9 -w-j4" + 3 "-l3 -j 4 -w" + 5 "--load-average=5" + 6 "--load-average 6" + 7 "-l3 --load-average 7 -w" + 4 "-j1 -j 2 --load-average 3 --load-average=4" + 3 " --max-load=3 -x" + 8 " -l 8 " +) +for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do + test-makeopts_loadavg "${tests[i]}" "${tests[i+1]}" +done + +texit