From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id YC+HBwzgkmFfJQAAgWs5BA (envelope-from ) for ; Mon, 15 Nov 2021 23:32:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id MI89AwzgkmFUTwAA1q6Kng (envelope-from ) for ; Mon, 15 Nov 2021 22:32:44 +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 BA99416A3B for ; Mon, 15 Nov 2021 23:32:43 +0100 (CET) Received: from localhost ([::1]:57656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmkWo-0001VT-NV for larch@yhetil.org; Mon, 15 Nov 2021 17:32:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmkWB-00006J-OW for guix-patches@gnu.org; Mon, 15 Nov 2021 17:32:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmkWB-0002Ar-DQ for guix-patches@gnu.org; Mon, 15 Nov 2021 17:32:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mmkWB-0003lY-Ab for guix-patches@gnu.org; Mon, 15 Nov 2021 17:32:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH v2 01/10] tests: Add 'static-networking' test. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 15 Nov 2021 22:32:03 +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.163701547514321 (code B ref 51440); Mon, 15 Nov 2021 22:32:03 +0000 Received: (at 51440) by debbugs.gnu.org; 15 Nov 2021 22:31:15 +0000 Received: from localhost ([127.0.0.1]:56440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmkVO-0003in-Hb for submit@debbugs.gnu.org; Mon, 15 Nov 2021 17:31:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52512) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmkVA-0003gm-On for 51440@debbugs.gnu.org; Mon, 15 Nov 2021 17:31:10 -0500 Received: from [2001:470:142:3::e] (port=52018 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmkV5-0001zT-HZ; Mon, 15 Nov 2021 17:30:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=nIMYMSxGuVBBp0yBxrJ8NiTzp8VkdLuICWMDvMaM/7M=; b=Pr0GAbckkbi4q1dFVrlj Nw3NxtPdWIxRd0EOxV2yj/aRdMM9Bpuphfc9YNQ/YLd1Th09+SIEAKVMIpnXtiwJndvgd0b5eOGH3 sHDw2bspNSxi3+ynJmx7JyNo8kBgy5wOWUUfLg9VccK8K/g427VCII6KZcSSwBsAOfVUR7SBw+5mo 1YRfl1/QT3vO9eAlXf8W8NUq8oJZUnmBaRYBPLtK4H1bRTC9n8T2/Z4ZTJoNSeME2XrNLrMUKd35+ OBKNX3i1YXuclhFFaE30+GEQYZCnZFBQzC6u8c3dfG0bS+6Fn9ur1XD/uYRaKvZCZUKmIQD9NFrN/ ErU8yqF9bGlosg==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=44414 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 1mmkV5-0001jO-9Y; Mon, 15 Nov 2021 17:30:55 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 15 Nov 2021 23:30:35 +0100 Message-Id: <20211115223044.10943-2-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211115223044.10943-1-ludo@gnu.org> References: <20211027135918.18833-1-ludo@gnu.org> <20211115223044.10943-1-ludo@gnu.org> 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=1637015563; 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=d4SnP/zoN5b/rw8cBmVXv0GDCQg0hDALKvFO+3jFLn11nxDKL2Dnc0FSlo8ScJQPrOnHQU Sgc+ZK8h/Odrh6URds5wIZXq3rj72QxoplZPD43Szt4TP+AGeSWIE8XABecOHy+1cbkbrK Sh/CAlOaUkh56QMQacDlkbd/YDJwF2Cq2cKypdY36foKYWNE85SnLVwH+HBnGTYMXDDL3d mztc2/VE/cTqRnW3A878xFNDfd8OyZXtUoUVF9NC9DQP3mX/bsf9EKNysjQ46YQVi4c2EZ 1/8pwQS2Ur3dVMTBp8jC9G4J9kx+maYZ5eVyVk8FQWRc60J0+vtqbpUHOL/Cjw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1637015563; a=rsa-sha256; cv=none; b=f4OzJhvDZYx0qGTZAj6tlLe+kqJNJIzpizYUgkm+rQOLB/dNnYuR1kVEPsoklmSN10AQCl uUmdYSauLKaT13npRg2Top/K6NVj6zAkma+0xd5w4ZhPY1KHJsd8VUVZgMf5TlSU1ts/L9 X9embVZzocdYMIFsSPaSoiIybIzygW1plpOuVsb9GuFxYidox6u2U27d1BYG6h6zbxe70l sP5pJ/BiB8QntGSHDyG2y4KpiH3M20i9Xu7L5ZfkETkmIXCje3B6FPXDBmPdkgKV6AAPJl efpwMpRSq8rHcBiZ2ONuGF44y3KVeV0gO3kJRmTKBqxnRiJfUQVSp9ZsPGGFaw== 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=Pr0GAbck; 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: -2.54 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=Pr0GAbck; 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: BA99416A3B X-Spam-Score: -2.54 X-Migadu-Scanner: scn1.migadu.com X-TUID: b6tMFA91gcIG * 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