[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))))
- [dhcp] 05/12: dhcp: add in deprecated time-offset option, (continued)
- [dhcp] 05/12: dhcp: add in deprecated time-offset option, Rohan Prinja, 2015/06/06
- [dhcp] 01/12: dhcp: arp hardware address identifiers, Rohan Prinja, 2015/06/06
- [dhcp] 04/12: dhcp: change module names to reflect directory structure, Rohan Prinja, 2015/06/06
- [dhcp] 08/12: dhcp: code for sending packets, incomplete, untested, Rohan Prinja, 2015/06/06
- [dhcp] 10/12: dhcp: source for .so, used by some now-redundant functions in interfaces.scm, Rohan Prinja, 2015/06/06
- [dhcp] 06/12: dhcp: packet objects, untested, Rohan Prinja, 2015/06/06
- [dhcp] 03/12: dhcp: add unused and private-use options, fix some other mistakes, Rohan Prinja, 2015/06/06
- [dhcp] 09/12: dhcp: dhcp configuration objects, Rohan Prinja, 2015/06/06
- [dhcp] 07/12: dhcp: code to read info about network interfaces, untested, Rohan Prinja, 2015/06/06
- [dhcp] 12/12: dhcp: client code, incomplete, Rohan Prinja, 2015/06/06
- [dhcp] 11/12: dhcp: tests for the (dhcp *) modules, incomplete,
Rohan Prinja <=