From nobody Fri Apr 14 20:16:17 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PynlQ1XMDz44hRq; Fri, 14 Apr 2023 20:16:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PynlQ15bJz3DKc; Fri, 14 Apr 2023 20:16:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681503378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=45DtQRukQJQEq9xXfkLXmwzBKFDIlb6lo0z04GpeYi4=; b=I9v8flQrUQnHXDad68mLsiasUrODb/2uiLfbYxZrf99sgSr5kXCnao8PTj2CoFQPskvrYu +i84AZBJs55xWc1yTCe8lar9r9LEQi5wz+O/EhCeShYIMVNEmYTnSa9VE1eaKGM5430X9z P9ClUdxasQc/mHGxb6UliYQTDqygTw6KdOVh1QacYVC2nA6eKNztuX31vRd94fnzRDD/LF 2NfJE+uwaoKV5jgB98KRk4lBJbylez+H1taTW3IoNLSONQno+PLc2zqNP6qyiew/HJR6Ge Pg2zKNgO0/BISBcxPIkQr5zBmxuECNAdcDu7hJUppkP3lKvapSNgH6CT7n1PRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681503378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=45DtQRukQJQEq9xXfkLXmwzBKFDIlb6lo0z04GpeYi4=; b=X8Kxgt+jps4ucUkjMymm39ux4vBP1Gin3Dvy8FkbgrcBuKA1dWs7tiVp6F5xcxpF0dw8cc E08WVRDWNCXDL/sHPL++ARVRipDerm0sL+t/yJaUnESBlxSQNuAfT9gSzagrYN3TlgbhB0 VuwzihGD7DvViq3DSwakfbykkB8rGs+AABUfJrIk7U/2QKjepzaxjgwl5F2m8N4dqwJnQA JsQUY0RbpqBJY0Q7tCepFFTiaYYdIM1SISxTbdQu2mgI30Jz2xwx5/X9mmpki8/sKwKnXf vL0WaKwWwIJX/nVEdTC1zxjgdAN42lBAGWub7+W9Rhs5Evd8p6YTZoyFrzjncQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681503378; a=rsa-sha256; cv=none; b=A7UjElHI/dwC6QPCxc4dYb7dzmzIV9NDNVG92GQjEPl9nCXSNxGvn5oQUBiJO1P4p9+Xik +h0VlxjMZvUc7nZfjxsT0Ws4Ukd0kZQ3Rk4erHNupDFKz6KxZC1aLLqO7aikIudTYAhl/P yqT7sgs2AAE0PthbfjUhSZB/U9+xeosf4ETw6LUp1rU6/qEYuLlSf2QrFJaMtXhXnP5Aus jgw3yi3MSeUHE9wnBrnc7Uap5vBRQLLlRT+prp92eR99oDEV/u0LFc9qUdBtphM3KXhzRQ sqW/YEjv5jhRZMTZAF7B4/sQmaemuk4+f6/Mq4MhUrzJW0a60+LgIqeG/OaS5A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PynlQ08MRzdfX; Fri, 14 Apr 2023 20:16:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33EKGHJ3000906; Fri, 14 Apr 2023 20:16:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33EKGHen000905; Fri, 14 Apr 2023 20:16:17 GMT (envelope-from git) Date: Fri, 14 Apr 2023 20:16:17 GMT Message-Id: <202304142016.33EKGHen000905@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 485f783f882e - main - limits_test: validate CPU time used, not real time List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 485f783f882ed026cdbfede89aa7bddad3fffdf3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=485f783f882ed026cdbfede89aa7bddad3fffdf3 commit 485f783f882ed026cdbfede89aa7bddad3fffdf3 Author: Eric van Gyzen AuthorDate: 2023-04-14 21:11:29 +0000 Commit: Eric van Gyzen CommitDate: 2023-04-14 21:16:05 +0000 limits_test: validate CPU time used, not real time RLIMIT_CPU applies to CPU time, not real (wall-clock) time. This test failed in AWS, where the real time was 5-7 seconds. Sum the user and system CPU time used, and validate that. While I'm here, don't bother specifying -s exit:0 or -e empty, since those are checked by default. MFC after: 1 week Sponsored by: Dell EMC Isilon --- usr.bin/limits/tests/limits_test.sh | 44 ++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/usr.bin/limits/tests/limits_test.sh b/usr.bin/limits/tests/limits_test.sh index 63f60e8eedf5..195813d322a6 100755 --- a/usr.bin/limits/tests/limits_test.sh +++ b/usr.bin/limits/tests/limits_test.sh @@ -31,30 +31,58 @@ # shell interpretation of time(1) TIME=/usr/bin/time -atf_test_case cputime_hard_flag +validate_time_output() +{ + local time_output=$1 + + # RLIMIT_CPU is enforced by a 1-second timer. Allow 3 + 1 + a little. + atf_check awk ' + /^(user|sys) / { + sum += $2 + } + END { + if (sum < 3 || sum >= 4.5) { + print(sum); + exit(1); + } + } + ' < $time_output +} + +atf_test_case cputime_hard_flag cleanup cputime_hard_flag_body() { - atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \ + atf_check -o match:'cputime[[:space:]]+3 secs' \ limits -H -t 3 limits -H - atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \ + atf_check -o match:'cputime[[:space:]]+3 secs' \ limits -H -t 3 limits -S - atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:sigkill \ + atf_check -e save:time_output -s signal:sigkill \ limits -H -t 3 $TIME -p sh -c 'while : ; do : ; done' + validate_time_output time_output +} +cputime_hard_flag_cleanup() +{ + rm -f time_output } SIGXCPU=24 # atf_check doesn't know sigxcpu -atf_test_case cputime_soft_flag +atf_test_case cputime_soft_flag cleanup cputime_soft_flag_body() { - atf_check -e empty -o match:'cputime-max[[:space:]]+infinity secs' -s exit:0 \ + atf_check -o match:'cputime-max[[:space:]]+infinity secs' \ limits -S -t 3 limits -H - atf_check -e empty -o match:'cputime-cur[[:space:]]+3 secs' -s exit:0 \ + atf_check -o match:'cputime-cur[[:space:]]+3 secs' \ limits -S -t 3 limits -S - atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:$SIGXCPU \ + atf_check -e save:time_output -s signal:$SIGXCPU \ limits -S -t 3 $TIME -p sh -c 'while : ; do : ; done' + validate_time_output time_output +} +cputime_soft_flag_cleanup() +{ + rm -f time_output } atf_init_test_cases()