From patchwork Fri Aug 18 20:22:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ulfvonbelow X-Patchwork-Id: 16045 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9329627BBE9; Fri, 18 Aug 2023 21:24:34 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1199D27BBE2 for ; Fri, 18 Aug 2023 21:24:33 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX60p-0008RT-8s; Fri, 18 Aug 2023 16:24:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qX60n-0008Qj-GS for guix-patches@gnu.org; Fri, 18 Aug 2023 16:24:01 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX60n-0008FV-92 for guix-patches@gnu.org; Fri, 18 Aug 2023 16:24:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qX60n-0006ey-Qq for guix-patches@gnu.org; Fri, 18 Aug 2023 16:24:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65221] [PATCH 1/6] tests: add extra-ports.sh test. References: <20230811090352.3572-1-striness@tilde.club> In-Reply-To: <20230811090352.3572-1-striness@tilde.club> Resent-From: ulfvonbelow Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Aug 2023 20:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65221 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65221@debbugs.gnu.org Cc: ulfvonbelow Received: via spool by 65221-submit@debbugs.gnu.org id=B65221.169239018225451 (code B ref 65221); Fri, 18 Aug 2023 20:24:01 +0000 Received: (at 65221) by debbugs.gnu.org; 18 Aug 2023 20:23:02 +0000 Received: from localhost ([127.0.0.1]:48881 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qX5zq-0006cR-77 for submit@debbugs.gnu.org; Fri, 18 Aug 2023 16:23:02 -0400 Received: from tilde.club ([142.44.150.184]:46950 ident=postfix) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qX5zo-0006bv-EH for 65221@debbugs.gnu.org; Fri, 18 Aug 2023 16:23:01 -0400 Received: by tilde.club (Postfix, from userid 5378) id CBC512250B9BD; Fri, 18 Aug 2023 20:22:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 tilde.club CBC512250B9BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tilde.club; s=mail; t=1692390178; bh=M1guxpFVdxF/8sHdzbvplvOIyQlVxQ1fObnPTcoY/oE=; h=From:To:Cc:Subject:Date:From; b=sHP0JZ2b0S79xYhakbGDlJ5NgwE60Gy2ldDuRGbq19vCb25P81zD5eT8RMM7lXyt/ hKZ4yNWj5RpMGWiqB5nEtHngNGnZ7aCzW9uGPoheO77Tg1juYwx6z+Wqs+2jOlNobh xYG4+xJcns49yWZ8Cx4WL2I8cL6ItOoZfB8aFD8s= From: ulfvonbelow Date: Fri, 18 Aug 2023 15:22:34 -0500 Message-Id: <20230818202239.21177-1-striness@tilde.club> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * tests/extra-ports.sh: new test. --- tests/extra-ports.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/extra-ports.sh diff --git a/tests/extra-ports.sh b/tests/extra-ports.sh new file mode 100644 index 0000000..51b91b7 --- /dev/null +++ b/tests/extra-ports.sh @@ -0,0 +1,76 @@ +socket="t-socket-$$" +conf="t-conf-$$" +log="t-log-$$" +pid="t-pid-$$" +testfile1="t-testfile1-$$" +testfile2="t-testfile2-$$" +resultfile="t-resultfile-$$" + +herd="herd -s $socket" + +trap "cat $log || true; + rm -f $socket $conf $log $testfile1 $testfile2 $resultfile; + test -f $pid && kill \`cat $pid\` || true; rm -f $pid" EXIT + +printf "test1" > "$testfile1" +printf "test2" > "$testfile2" + +cat > "$conf"< (fileno a) + (fileno b)))))) + + (define command + (list + "sh" + "-c" + (string-append + "set -x;" + " cat >> ${resultfile}.tmp <&" (number->string + (fileno test1)) + "; cat >> ${resultfile}.tmp <&" (number->string + (fileno test2)) + "; mv ${resultfile}.tmp ${resultfile}"))) + + (fork+exec-command command + #:extra-ports + ports + #:directory + "$(pwd)")))))) + #:stop (const #f) + #:respawn? #f))) +EOF + +rm -f "$pid" +shepherd -I -s "$socket" -c "$conf" -l "$log" --pid="$pid" & + +while ! test -f "$pid" ; do sleep 0.3 ; done + +shepherd_pid="`cat $pid`" +kill -0 $shepherd_pid + +$herd start test-extra-ports + +while ! test -f "$resultfile" ; do sleep 0.3 ; done + +result="$(cat $resultfile)" +test "$result" = "test1test2" -o "$result" = "test2test1"