[systemd-devel] [PATCH 07/28] build: Add DHCP option test

Patrik Flykt patrik.flykt at linux.intel.com
Wed Nov 13 13:22:35 PST 2013


---
 Makefile.am                 |   10 ++++++++++
 src/dhcp/test-dhcp-option.c |   16 +++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index cc52f01..aeca484 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3740,6 +3740,15 @@ endif
 
 # ------------------------------------------------------------------------------
 if ENABLE_DHCP
+test_dhcp_option_SOURCES = \
+	src/dhcp/protocol.h \
+	src/dhcp/internal.h \
+	src/dhcp/option.c \
+	src/dhcp/test-dhcp-option.c
+
+test_dhcp_option_LDADD = \
+	libsystemd-shared.la
+
 test_dhcp_client_SOURCES = \
 	src/dhcp/protocol.h \
 	src/dhcp/client.h \
@@ -3750,6 +3759,7 @@ test_dhcp_client_LDADD = \
 	libsystemd-shared.la
 
 tests += \
+	test-dhcp-option \
 	test-dhcp-client
 endif
 
diff --git a/src/dhcp/test-dhcp-option.c b/src/dhcp/test-dhcp-option.c
index 25cb17c..9302fd6 100644
--- a/src/dhcp/test-dhcp-option.c
+++ b/src/dhcp/test-dhcp-option.c
@@ -12,23 +12,23 @@
 
 static void test_invalid_buffer_length(void)
 {
-        struct dhcp_message message;
+        DHCPMessage message;
 
         assert(__dhcp_option_parse(&message, INT32_MIN, NULL, NULL) ==
-                        -EINVAL);
-        assert(__dhcp_option_parse(&message, sizeof(struct dhcp_message),
-                                        NULL, NULL) == -EINVAL);
+               -EINVAL);
+        assert(__dhcp_option_parse(&message, sizeof(DHCPMessage),
+                                   NULL, NULL) == -EINVAL);
 }
 
 static void test_cookie(void)
 {
-        struct dhcp_message *message;
-        uint32_t len = sizeof(struct dhcp_message) + 4;
+        DHCPMessage *message;
+        uint32_t len = sizeof(DHCPMessage) + 4;
         uint8_t *opt;
 
         message = malloc0(len);
 
-        opt = (uint8_t *) message + 1;
+        opt = (uint8_t *)(message + 1);
         opt[0] = 0xff;
 
         assert(__dhcp_option_parse(message, len, NULL, NULL) == -EINVAL);
@@ -45,8 +45,6 @@ static void test_cookie(void)
 
 int main(int argc, char *argv[])
 {
-        unsigned int i;
-
         test_invalid_buffer_length();
         test_cookie();
 
-- 
1.7.10.4



More information about the systemd-devel mailing list