guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dhcp] 11/12: dhcp: tests for the (dhcp *) modules, incomplete


From: Rohan Prinja
Subject: [dhcp] 11/12: dhcp: tests for the (dhcp *) modules, incomplete
Date: Sat, 06 Jun 2015 18:16:58 +0000

wenderen pushed a commit to branch master
in repository dhcp.

commit 34690bc3c95db3ee0cb5086fbf6c2cc321b736cd
Author: Rohan Prinja <address@hidden>
Date:   Sat Jun 6 23:45:28 2015 +0530

    dhcp: tests for the (dhcp *) modules, incomplete
---
 tests/dhcp-dhcp.scm       |   32 +++++++++++++++++++++++++++
 tests/dhcp-interfaces.scm |   50 ++++++++++++++++++++++++++++++++++++++++++
 tests/dhcp-messages.scm   |   45 ++++++++++++++++++++++++++++++++++++++
 tests/dhcp-send.scm       |   53 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 180 insertions(+), 0 deletions(-)

diff --git a/tests/dhcp-dhcp.scm b/tests/dhcp-dhcp.scm
new file mode 100644
index 0000000..2dba34d
--- /dev/null
+++ b/tests/dhcp-dhcp.scm
@@ -0,0 +1,32 @@
+;;; GNU Guix DHCP Client.
+;;;
+;;; Copyright 2015 Free Software Foundation, Inc.
+;;;
+;;; This program 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.
+;;;
+;;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+(add-to-load-path (string-append (dirname (current-filename))
+                                "/.."))
+
+(define-module (test-dhcp-dhcp))
+
+(use-modules (oop goops)
+            (srfi srfi-64)
+            (dhcp dhcp)
+            (dhcp interfaces))
+
+(test-begin "dhcp-dhcp")
+
+'TODO
+
+(exit (zero? (test-runner-fail-count (test-runner-current))))
diff --git a/tests/dhcp-interfaces.scm b/tests/dhcp-interfaces.scm
new file mode 100644
index 0000000..7f65b12
--- /dev/null
+++ b/tests/dhcp-interfaces.scm
@@ -0,0 +1,50 @@
+;;; GNU Guix DHCP Client.
+;;;
+;;; Copyright 2015 Free Software Foundation, Inc.
+;;;
+;;; This program 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.
+;;;
+;;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+(add-to-load-path (string-append (dirname (current-filename))
+                                "/.."))
+
+(define-module (test-dhcp-interfaces))
+
+(use-modules (srfi srfi-64)
+            (dhcp interfaces)
+            (arp identifiers)
+            ((guix build syscalls) #:select (all-network-interfaces))
+            ((ice-9 popen) #:select (open-pipe)))
+
+(test-begin "dhcp-interfaces")
+
+(define ifaces (all-network-interfaces))
+
+(define eth (car (retain-ethernet-interfaces ifaces)))
+
+(print-hardware-address (hardware-address eth))
+
+(open-pipe "ls -l" OPEN_BOTH)
+
+(test-eq "correct-family"
+        ARPHRD_ETHER
+        (hardware-family eth))
+
+;(define iaddr (network-interface-address sock (cadr ifaces)))
+;(display iaddr) (newline)b;(define ifaddrs (get-first-interface-ptr))
+;(define ifaces (find-interfaces ifaddrs))
+;(free-interfaces ifaddrs)
+
+(test-end)
+
+(exit (zero? (test-runner-fail-count (test-runner-current))))
diff --git a/tests/dhcp-messages.scm b/tests/dhcp-messages.scm
new file mode 100644
index 0000000..2ed435d
--- /dev/null
+++ b/tests/dhcp-messages.scm
@@ -0,0 +1,45 @@
+;;; GNU Guix DHCP Client.
+;;;
+;;; Copyright 2015 Free Software Foundation, Inc.
+;;;
+;;; This program 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.
+;;;
+;;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+                                       
+(add-to-load-path (string-append (dirname (current-filename))
+                                "/.."))
+
+(define-module (test-dhcp-messages))
+
+(use-modules (srfi srfi-64)
+            ((guix build syscalls) #:select (all-network-interfaces))
+            (dhcp interfaces)
+            (dhcp messages))
+
+(define netif
+  (make-network-interface
+   (car
+    (retain-ethernet-interfaces
+     (all-network-interfaces)))))
+
+(define msg
+  (make-dhcpdiscover netif (make-vector 255 0)))
+
+(test-begin "dhcp-messages")
+
+(test-eq "message-type"
+        (map-type-to-code 'DHCPDISCOVER)
+        (message-type msg))
+
+(test-end)
+
+(exit (zero? (test-runner-fail-count (test-runner-current))))
diff --git a/tests/dhcp-send.scm b/tests/dhcp-send.scm
new file mode 100644
index 0000000..d28542d
--- /dev/null
+++ b/tests/dhcp-send.scm
@@ -0,0 +1,53 @@
+;;; GNU Guix DHCP Client.
+;;;
+;;; Copyright 2015 Free Software Foundation, Inc.
+;;;
+;;; This program 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.
+;;;
+;;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+(add-to-load-path (string-append (dirname (current-filename))
+                                "/.."))
+
+(define-module (test-dhcp-send))
+
+(use-modules (srfi srfi-64)
+            (dhcp send))
+
+(test-begin "dhcp-send")
+
+'TODO
+
+(define sock (make-dgram-sock))
+
+(if (= (fileno sock) -1)
+    (begin
+      (display "error creating sock\n")
+      (exit)))
+
+; Enable broadcast for the socket.
+(setsockopt sock SOL_SOCKET SO_BROADCAST 1)
+
+; Default broadcast address for DHCP.
+(define broadcast-sockaddr
+  (make-broadcast-sockaddr *client-out-port*))
+
+(let ((bytes-sent (sendto sock
+                         #vu8(1 2 3 4)
+                         broadcast-sockaddr)))
+  (test-eqv "sendto-works"
+           bytes-sent
+           4))
+
+(test-end)
+
+(exit (zero? (test-runner-fail-count (test-runner-current))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]