From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OHBFK5ZneWElIQAAgWs5BA (envelope-from ) for ; Wed, 27 Oct 2021 16:52:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 0Br4JpZneWEiQAAAB5/wlQ (envelope-from ) for ; Wed, 27 Oct 2021 14:52:06 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3967216046 for ; Wed, 27 Oct 2021 16:52:02 +0200 (CEST) Received: from localhost ([::1]:54538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkHZ-0001i6-Av for larch@yhetil.org; Wed, 27 Oct 2021 10:52:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjX8-0008Je-Ba for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38540) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjX8-0005Fc-2Q for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjX7-0002Yl-UM for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 01/10] tests: Add 'static-networking' test. References: <20211027135918.18833-1-ludo@gnu.org> In-Reply-To: <20211027135918.18833-1-ludo@gnu.org> Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353433839630 (code B ref 51440); Wed, 27 Oct 2021 14:04:01 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:03 +0000 Received: from localhost ([127.0.0.1]:50052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWB-0002VG-AZ for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjW9-0002UZ-60 for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjW3-00057C-Jr; Wed, 27 Oct 2021 10:02:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=nIMYMSxGuVBBp0yBxrJ8NiTzp8VkdLuICWMDvMaM/7M=; b=LQDQbBJ8WERjiw r26s9bCgxillYF+2glRFmODt+dSJZDomJGnVODNMkZO6EHApZBZd2FAaARGeaPh5KGJ/v2olUrZKP 5V9RPgiWfqp3c5kc9OTdWNOBdEmedD00lRhvRWZbHF4L8LSj8tlGNM3wKF3NA9/UWTOVV6JKrvJCE eWLTxpKLDIOrnMhjRN2KY6n+0SPv0yjd1XkYL/gIh71VeNjXr6ru/XHgxh5fUBCljMAZgaaxqMEhE 1M8FwO4uYn0ZMIG1logivZVbNM1+KbrTmRY+HmRaEvvLjAo0Vpu+K1p8g9uxQyOCELJQIo2X1msw+ HaQnw+CZBcv6HjR51rJQ==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjW1-0002Tf-0w; Wed, 27 Oct 2021 10:02:53 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:36 +0200 Message-Id: <20211027140245.18970-1-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1635346322; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=SipEqxxEtJ2BSYgmBO9aidqUF7DsNjA9vepqQg/Wqfo=; b=k94CqKy9H/MuqCbUGMUtQEdw0IWyHRJn1FvfXPhKJ4UKZeBbiMXBMmTdhQrdg6NZPKJxh1 R/R6Ugkpr4CMg3K0CWQ518EcW5WkchoZ1fPp7LGSx5WylL6yA7mqYGO9xnglTSLbvoIrCO zZfoxb0mKRDR/Y4M+FsiGBWxKSNPC/oDj8dVqOfKeLwIkSa3+ncy57Oz5RQuxlbi7W19zM jF+IWjQ2GrywS0OEA5aEyGGN3S+axV0MYjDbUPV4FtvJRALoxdNKsD4d+d/vGzaXcYss86 XVQtMP32LhlVp1wROMdTqwC0uBUfuk+PvKuGJL4AgC0nJX4FNSwc0cuxDB++Sw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635346322; a=rsa-sha256; cv=none; b=ue5cYvn+oKLYTLX+g+R0NiQoK1/AayAEDVORTuhGm5t4bzqG97HiWNxSaZPIsxJWzoeNp4 OaFZPvvePYoVKSI81DI2SX/AyROl3VaiHFWNF6EL20nYb7zVPv8xcvbZNsVCo3Ub20+AIG 62KQdokCCk6N4DKddhFz/8Ad/3moSGRnk7QItY3FJSylnodES7XR6L4oaX4OWGjDpuSeRs Wvrir4aLi+bOvT6Hw+wPVeP8E+DP8nR5weTRuPLNmQBFVP3uHiKZ1FY62x7rgpSImup5VR Tq0OGS/UyD3QkNajHcUK+5BRzib8B+1DOGWHgg+9dno9awymZ2rVDtsc9wpzOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=LQDQbBJ8; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.43 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=LQDQbBJ8; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 3967216046 X-Spam-Score: -0.43 X-Migadu-Scanner: scn0.migadu.com X-TUID: 48pyDRPFxSxC * gnu/tests/networking.scm (run-static-networking-test): New procedure. (%test-static-networking): New variable. --- gnu/tests/networking.scm | 99 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 453e63f52d..5da1c91da6 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2018 Chris Marusich ;;; Copyright © 2018 Arun Isaac ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,8 +38,102 @@ (define-module (gnu tests networking) #:use-module (gnu packages guile) #:use-module (gnu services shepherd) #:use-module (ice-9 match) - #:export (%test-inetd %test-openvswitch %test-dhcpd %test-tor %test-iptables - %test-ipfs)) + #:export (%test-static-networking + %test-inetd + %test-openvswitch + %test-dhcpd + %test-tor + %test-iptables + %test-ipfs)) + + +;;; +;;; Static networking. +;;; + +(define (run-static-networking-test vm) + (define test + (with-imported-modules '((gnu build marionette) + (guix build syscalls)) + #~(begin + (use-modules (gnu build marionette) + (guix build syscalls) + (srfi srfi-64)) + + (define marionette + (make-marionette + '(#$vm "-nic" "user,model=virtio-net-pci"))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "static-networking") + + (test-assert "service is up" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'networking)) + marionette)) + + (test-assert "network interfaces" + (marionette-eval + '(begin + (use-modules (guix build syscalls)) + (network-interface-names)) + marionette)) + + (test-equal "address of eth0" + "10.0.2.15" + (marionette-eval + '(let* ((sock (socket AF_INET SOCK_STREAM 0)) + (addr (network-interface-address sock "eth0"))) + (close-port sock) + (inet-ntop (sockaddr:fam addr) (sockaddr:addr addr))) + marionette)) + + (test-equal "netmask of eth0" + "255.255.255.0" + (marionette-eval + '(let* ((sock (socket AF_INET SOCK_STREAM 0)) + (mask (network-interface-netmask sock "eth0"))) + (close-port sock) + (inet-ntop (sockaddr:fam mask) (sockaddr:addr mask))) + marionette)) + + (test-equal "eth0 is up" + IFF_UP + (marionette-eval + '(let* ((sock (socket AF_INET SOCK_STREAM 0)) + (flags (network-interface-flags sock "eth0"))) + (logand flags IFF_UP)) + marionette)) + + (test-end) + + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "static-networking" test)) + +(define %test-static-networking + (system-test + (name "static-networking") + (description "Test the 'static-networking' service.") + (value + (let ((os (marionette-operating-system + (simple-operating-system + (static-networking-service "eth0" "10.0.2.15" + #:netmask "255.255.255.0" + #:gateway "10.0.2.2" + #:name-servers '("10.0.2.2"))) + #:imported-modules '((gnu services herd) + (guix combinators))))) + (run-static-networking-test (virtual-machine os)))))) + + +;;; +;;; Inetd. +;;; (define %inetd-os ;; Operating system with 2 inetd services. -- 2.33.0