diff --git a/ChangeLog b/ChangeLog index c48552b..1f61455 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-02-04 Holger Hans Peter Freyther + * tests/testsuite.at: Add the Sockets test. + +2011-02-04 Holger Hans Peter Freyther + * libgst/sockets.c: Add size check for the socket addr. 2011-02-02 Holger Hans Peter Freyther diff --git a/packages/sockets/ChangeLog b/packages/sockets/ChangeLog index 4e53b51..2cb65f7 100644 --- a/packages/sockets/ChangeLog +++ b/packages/sockets/ChangeLog @@ -1,3 +1,8 @@ +2011-02-04 Holger Hans Peter Freyther + + * package.xml: Add test section. + * UnitTest.st: Add SUnit based testcase. + 2011-01-19 Holger Hans Peter Freyther * Sockets.st: Use errno to test outcome of bind. diff --git a/packages/sockets/UnitTest.st b/packages/sockets/UnitTest.st new file mode 100644 index 0000000..abd59c2 --- /dev/null +++ b/packages/sockets/UnitTest.st @@ -0,0 +1,53 @@ +"====================================================================== +| +| SUnit Test Cases for the Socket Code +| +| + ======================================================================" + +"====================================================================== +| +| Copyright 2011 Free Software Foundation, Inc. +| Written by Holger Hans Peter Freyther. +| +| This file is part of GNU Smalltalk. +| +| GNU Smalltalk 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 2, or (at your option) any later version. +| +| GNU Smalltalk 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 Smalltalk; see the file COPYING. If not, write to the Free Software +| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +| + ======================================================================" + +TestCase subclass: SocketTest [ + testDoNotCrashOnSendto [ + " + The objective of this test is to check if the c code is + crashing with 'invalid' input. + " + | socket addrLen datagram | + socket := DatagramSocket new. + + "Passing the wrong bits to the call out will abort." + addrLen := CInt gcValue: 0. + socket implementation + accept: -1 peer: nil addrLen: addrLen; + bind: -1 to: nil addrLen: 0; + connect: -1 to: nil addrLen: 0; + getPeerName: -1 addr: nil addrLen: addrLen; + getSockName: -1 addr: nil addrLen: addrLen; + receive: -1 buffer: nil size: 0 flags: 0 from: nil size: addrLen. + + "Pass a datagram with no destination." + datagram := Datagram new. + socket nextPut: datagram. + ] +] diff --git a/packages/sockets/package.xml b/packages/sockets/package.xml index 079ea0c..fd9e7b5 100644 --- a/packages/sockets/package.xml +++ b/packages/sockets/package.xml @@ -15,5 +15,11 @@ Tests.st cfuncs.st init.st + + + Sockets.SocketTest + UnitTest.st + + ChangeLog diff --git a/tests/testsuite.at b/tests/testsuite.at index ac21ad1..093ddb0 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -160,6 +160,7 @@ AT_PACKAGE_TEST([Magritte]) AT_OPTIONAL_PACKAGE_TEST([ROE]) AT_PACKAGE_TEST([SandstoneDb]) AT_OPTIONAL_PACKAGE_TEST([Seaside-Core]) +AT_OPTIONAL_PACKAGE_TEST([Sockets]) AT_PACKAGE_TEST([Sport]) AT_PACKAGE_TEST([Swazoo]) AT_OPTIONAL_PACKAGE_TEST([XML-XMLParser])