diff --git a/.gitignore b/.gitignore index 84ad830..8cfcf4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.swp /cbits/*.exe /dist/ +/test/dist diff --git a/cbits/network-unix.c b/cbits/network-unix.c index cf8a336..9e88511 100644 --- a/cbits/network-unix.c +++ b/cbits/network-unix.c @@ -25,7 +25,7 @@ void maccopy(unsigned char *dst, struct sockaddr *addr) #else /* TODO check that sdl_alen is equal to 6 (MAC_SIZE) */ struct sockaddr_dl *sdl = (struct sockaddr_dl *)addr; - memcpy(dst, sdl->sdl_data + sdl-> sdl_nlen, MAC_SIZE); + memcpy(dst, sdl->sdl_data + sdl->sdl_nlen, MAC_SIZE); #endif } diff --git a/network-info.cabal b/network-info.cabal index 29b8763..55647eb 100644 --- a/network-info.cabal +++ b/network-info.cabal @@ -1,37 +1,32 @@ -Name: network-info -version: 0.1.0.1 -synopsis: Access the local computer's basic network configuration -description: This library provides simple read-only access to the local computer's - networking configuration. It is currently capable of getting a list of - all the network interfaces and their respective IPv4, IPv6 and MAC - addresses. - . - The executable 'test-network-info' will only be built if the flag 'test' - has been set. -homepage: http://github.com/jystic/network-info -license: BSD3 -license-file: LICENSE -author: Jacob Stanley -maintainer: jacob@stanley.io -category: Network -build-type: Simple -cabal-version: >=1.8.0.4 +name: network-info +version: 0.1.0.1 +synopsis: Access the local computer's basic network configuration +description: This library provides simple read-only access to the local computer's + networking configuration. It is currently capable of getting a list of + all the network interfaces and their respective IPv4, IPv6 and MAC + addresses. +homepage: http://github.com/jystic/network-info +license: BSD3 +license-file: LICENSE +author: Jacob Stanley +maintainer: jacob@stanley.io +category: Network +build-type: Simple +cabal-version: >= 1.6 extra-source-files: cbits/common.h, cbits/network.h, - README.mkd, - run-tests.sh, - run-tests.bat + test/src/Main.hs, + test/network-info-test.cabal, + test/run-tests.bat, + test/run-tests.sh, + README.mkd source-repository head type: git location: git://github.com/jystic/network-info.git -Flag test - description: Build test program - default: False - Library hs-source-dirs: src include-dirs: cbits @@ -50,14 +45,3 @@ Library extra-libraries: iphlpapi else buildable: False - -Executable test-network-info - hs-source-dirs: test - main-is: Main.hs - - if flag(test) - build-depends: - base == 4.*, - network-info - else - buildable: False diff --git a/run-tests.bat b/run-tests.bat deleted file mode 100644 index 7eb85b0..0000000 --- a/run-tests.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -cabal configure -ftest && cabal build && dist\build\test-network-info\test-network-info.exe diff --git a/run-tests.sh b/run-tests.sh deleted file mode 100755 index 68bd4cd..0000000 --- a/run-tests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -cabal configure -ftest && cabal build && dist/build/test-network-info/test-network-info diff --git a/test/network-info-test.cabal b/test/network-info-test.cabal new file mode 100644 index 0000000..163ea52 --- /dev/null +++ b/test/network-info-test.cabal @@ -0,0 +1,24 @@ +name: network-info-test +version: 0.1 +build-type: Simple +cabal-version: >= 1.6 + +Executable network-info-test + hs-source-dirs: ../src src + include-dirs: ../cbits + cc-options: -Wall -Werror + + main-is: Main.hs + other-modules: Network.Info + + build-depends: + base == 4.* + + if os(linux) || os(darwin) + c-sources: ../cbits/network-unix.c + else + if os(windows) + c-sources: ../cbits/network-windows.c + extra-libraries: iphlpapi + else + buildable: False diff --git a/test/run-tests.bat b/test/run-tests.bat new file mode 100644 index 0000000..1c0f24f --- /dev/null +++ b/test/run-tests.bat @@ -0,0 +1,2 @@ +@echo off +cabal configure && cabal build && .\dist\build\test-network-info\test-network-info.exe diff --git a/test/run-tests.sh b/test/run-tests.sh new file mode 100755 index 0000000..0e87a65 --- /dev/null +++ b/test/run-tests.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +TESTDIR="$(dirname -- "${0}")" +cd $TESTDIR + +cabal configure && cabal build && ./dist/build/network-info-test/network-info-test diff --git a/test/Main.hs b/test/src/Main.hs similarity index 100% rename from test/Main.hs rename to test/src/Main.hs