;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2023 Bruno Victal . ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu tests vnstat) #:use-module (gnu tests) #:use-module ((gnu packages networking) #:select (socat vnstat)) #:use-module (gnu services) #:use-module (gnu services
aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'gnu')
: re-add #:output (%make-void-port "w") below on ;; next Guile release. (garbage-pump-pid (spawn socat args))) (test-group-with-cleanup "Logging" ;; To aid debugging, this test returns #t on success ;; and either #f or 'timed-out otherwise. (test-eq "vnstatd is logging" #t (marionette-eval '(begin (use-modules (ice-9 popen) (ice-9 match) (sxml simple) (sxml xpath)) (define selector (let ((xpath '(vnstat interface traffic total))) (compose (node-pos 1) (sxpath xpath)))) (let loop ((i 0)) (let* ((vnstat #$(file-append vnstat "/bin/vnstat")) (query-cmd (format #f "~a --xml" vnstat)) (proc (compose selector xml->sxml)) (result (call-with-port (open-input-pipe query-cmd) proc))) (match result ;; Counter still warming up. ((('total ('rx "0") ('tx "0"))) (sleep 1) (if (< i #$test-timeout) (loop (+ i 1)) 'timed-out)) ;; Count of bytes on iface was non-zero. ((('total ('rx rx) ('tx tx))) #t) ;; Unknown data encountered, perhaps the ;; data format changed? (_ #f))))) marionette)) ;; Cleanup: shutdown garbage pump. (kill garbage-pump-pid SIGTERM))) (test-end))))) (gexp->derivation "vnstat-test" test)) (define %test-vnstat (system-test (name "vnstat") (description "Basic tests for vnstat service.") (value (run-vnstat-test))))