ObjFW  Check-in [0765df9754]

Overview
Comment:Add tests for OFSCTPSocket
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0765df975418ee6a2de7e1086ea3e39bb514444fe4ab3ba86a64b3b03a42bde4
User & Date: js on 2020-05-09 13:41:33
Other Links: manifest | tags
Context
2020-05-10
15:33
Fix building with --disable-sockets on Windows check-in: efbb4a8eb4 user: js tags: trunk
2020-05-09
13:41
Add tests for OFSCTPSocket check-in: 0765df9754 user: js tags: trunk
2020-05-06
20:25
Fix Wii build check-in: addbd546c5 user: js tags: trunk
Changes

Modified .travis.yml from [6d385d9409] to [53acd6323f].

   247    247                       amd64 | s390x)
   248    248                               pkgs="gobjc-multilib";
   249    249                               ;;
   250    250                       *)
   251    251                               pkgs="gobjc";
   252    252                               ;;
   253    253               esac;
          254  +
          255  +            pkgs="$pkgs libsctp-dev";
   254    256   
   255    257               if grep precise /etc/lsb-release >/dev/null; then
   256    258                       pkgs="$pkgs ipx";
   257    259               fi;
   258    260   
   259    261               if ! sudo apt-get -qq install -y $pkgs >/tmp/apt_log 2>&1; then
   260    262                       cat /tmp/apt_log;

Modified configure.ac from [e752a768b1] to [a657be6730].

  1329   1329   		AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
  1330   1330   			[Whether we have netinet/tcp.h])
  1331   1331   	])
  1332   1332   	AC_CHECK_HEADER(netinet/sctp.h, [
  1333   1333   		AC_DEFINE(OF_HAVE_SCTP, 1, [Whether we have SCTP])
  1334   1334   		AC_DEFINE(OF_HAVE_NETINET_SCTP_H, 1,
  1335   1335   			[Whether we have netinet/sctp.h])
  1336         -		AC_SUBST(OF_SCTP_SOCKET_M, OFSCTPSocket.m)
         1336  +		AC_SUBST(USE_SRCS_SCTP, '${SRCS_SCTP}')
  1337   1337   	])
  1338   1338   	AC_CHECK_HEADERS([arpa/inet.h netdb.h])
  1339   1339   	AC_CHECK_HEADER(netipx/ipx.h, [
  1340   1340   		AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1,
  1341   1341   			[Whether we have netipx/ipx.h])
  1342   1342   	])
  1343   1343   

Modified extra.mk.in from [66cdcce785] to [13c419ce36].

    80     80   TESTS_LIBS = @TESTS_LIBS@
    81     81   TESTS_STATIC_LIB = @TESTS_STATIC_LIB@
    82     82   UNICODE_M = @UNICODE_M@
    83     83   USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@
    84     84   USE_SRCS_FILES = @USE_SRCS_FILES@
    85     85   USE_SRCS_IPX = @USE_SRCS_IPX@
    86     86   USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@
           87  +USE_SRCS_SCTP = @USE_SRCS_SCTP@
    87     88   USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@
    88     89   USE_SRCS_THREADS = @USE_SRCS_THREADS@
    89     90   USE_SRCS_WINDOWS = @USE_SRCS_WINDOWS@
    90     91   WRAPPER = @WRAPPER@

Modified src/Makefile from [0e01cd00ef] to [fef35a3bdb].

   120    120          of_asprintf.m			\
   121    121          of_strptime.m			\
   122    122          once.m				\
   123    123          pbkdf2.m				\
   124    124          scrypt.m				\
   125    125          ${UNICODE_M}			\
   126    126          ${USE_SRCS_FILES}		\
   127         -       ${USE_SRCS_IPX}			\
   128    127          ${USE_SRCS_PLUGINS}		\
   129    128          ${USE_SRCS_SOCKETS}		\
   130    129          ${USE_SRCS_THREADS}		\
   131    130          ${USE_SRCS_WINDOWS}
   132    131   SRCS_FILES = OFFile.m			\
   133    132   	     OFINICategory.m		\
   134    133   	     OFINIFile.m		\
   135    134   	     OFSettings.m		\
   136    135   	     OFString+PathAdditions.m
   137    136   SRCS_IPX = OFIPXSocket.m	\
   138    137   	   OFSPXSocket.m	\
   139    138   	   OFSPXStreamSocket.m
   140    139   SRCS_PLUGINS = OFPlugin.m
          140  +SRCS_SCTP = OFSCTPSocket.m
   141    141   SRCS_SOCKETS = OFDNSQuery.m			\
   142    142   	       OFDNSResolver.m			\
   143    143   	       OFDNSResourceRecord.m		\
   144    144   	       OFDNSResponse.m			\
   145    145   	       OFDatagramSocket.m		\
   146    146   	       OFHTTPClient.m			\
   147    147   	       OFHTTPCookie.m			\
   148    148   	       OFHTTPCookieManager.m		\
   149    149   	       OFHTTPRequest.m			\
   150    150   	       OFHTTPResponse.m			\
   151    151   	       OFHTTPServer.m			\
   152         -	       ${OF_SCTP_SOCKET_M}		\
   153    152   	       OFSequencedPacketSocket.m	\
   154    153   	       OFStreamSocket.m			\
   155    154   	       OFTCPSocket.m			\
   156    155   	       OFUDPSocket.m			\
   157         -	       socket.m
          156  +	       socket.m				\
          157  +	       ${USE_SRCS_IPX}			\
          158  +	       ${USE_SRCS_SCTP}
   158    159   SRCS_THREADS = OFCondition.m		\
   159    160   	       OFMutex.m		\
   160    161   	       OFRecursiveMutex.m	\
   161    162   	       OFThreadPool.m		\
   162    163   	       condition.m		\
   163    164   	       mutex.m			\
   164    165   	       thread.m			\

Modified tests/Makefile from [a050bf9103] to [a8ea1ae9c1].

    36     36          OFXMLNodeTests.m			\
    37     37          OFXMLParserTests.m		\
    38     38          PBKDF2Tests.m			\
    39     39          RuntimeTests.m			\
    40     40          ScryptTests.m			\
    41     41          TestsAppDelegate.m		\
    42     42          ${USE_SRCS_FILES}		\
    43         -       ${USE_SRCS_IPX}			\
    44     43          ${USE_SRCS_PLUGINS}		\
    45     44          ${USE_SRCS_SOCKETS}		\
    46     45          ${USE_SRCS_THREADS}		\
    47     46          ${USE_SRCS_WINDOWS}
    48     47   SRCS_FILES = OFHMACTests.m		\
    49     48   	     OFINIFileTests.m		\
    50     49   	     OFMD5HashTests.m		\
................................................................................
    55     54   	     OFSHA256HashTests.m	\
    56     55   	     OFSHA384HashTests.m	\
    57     56   	     OFSHA512HashTests.m
    58     57   SRCS_IPX = OFIPXSocketTests.m		\
    59     58   	   OFSPXSocketTests.m		\
    60     59   	   OFSPXStreamSocketTests.m
    61     60   SRCS_PLUGINS = OFPluginTests.m
           61  +SRCS_SCTP = OFSCTPSocketTests.m
    62     62   SRCS_SOCKETS = OFDNSResolverTests.m		\
    63     63   	       ${OF_HTTP_CLIENT_TESTS_M}	\
    64     64   	       OFHTTPCookieTests.m		\
    65     65   	       OFHTTPCookieManagerTests.m	\
    66     66   	       OFKernelEventObserverTests.m	\
    67     67   	       OFTCPSocketTests.m		\
    68     68   	       OFUDPSocketTests.m		\
    69         -	       SocketTests.m
           69  +	       SocketTests.m			\
           70  +	       ${USE_SRCS_IPX}			\
           71  +	       ${USE_SRCS_SCTP}
    70     72   SRCS_THREADS = OFThreadTests.m
    71     73   SRCS_WINDOWS = OFWindowsRegistryKeyTests.m
    72     74   
    73     75   IOS_USER ?= mobile
    74     76   IOS_TMP ?= /tmp/objfw-test
    75     77   
    76     78   include ../buildsys.mk

Added tests/OFSCTPSocketTests.m version [6221b31ff7].

            1  +/*
            2  + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
            3  + *               2018, 2019, 2020
            4  + *   Jonathan Schleifer <js@nil.im>
            5  + *
            6  + * All rights reserved.
            7  + *
            8  + * This file is part of ObjFW. It may be distributed under the terms of the
            9  + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
           10  + * the packaging of this file.
           11  + *
           12  + * Alternatively, it may be distributed under the terms of the GNU General
           13  + * Public License, either version 2 or 3, which can be found in the file
           14  + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
           15  + * file.
           16  + */
           17  +
           18  +#include "config.h"
           19  +
           20  +#include <string.h>
           21  +
           22  +#import "TestsAppDelegate.h"
           23  +
           24  +static OFString *module = @"OFSCTPSocket";
           25  +
           26  +@implementation TestsAppDelegate (OFSCTPSocketTests)
           27  +- (void)SCTPSocketTests
           28  +{
           29  +	void *pool = objc_autoreleasePoolPush();
           30  +	OFSCTPSocket *server, *client = nil, *accepted;
           31  +	uint16_t port;
           32  +	char buf[6];
           33  +
           34  +	TEST(@"+[socket]", (server = [OFSCTPSocket socket]) &&
           35  +	    (client = [OFSCTPSocket socket]))
           36  +
           37  +	TEST(@"-[bindToHost:port:]",
           38  +	    (port = [server bindToHost: @"127.0.0.1"
           39  +				  port: 0]))
           40  +
           41  +	TEST(@"-[listen]", R([server listen]))
           42  +
           43  +	TEST(@"-[connectToHost:port:]",
           44  +	    R([client connectToHost: @"127.0.0.1"
           45  +			       port: port]))
           46  +
           47  +	TEST(@"-[accept]", (accepted = [server accept]))
           48  +
           49  +	TEST(@"-[remoteAddress]",
           50  +	    [of_socket_address_ip_string(accepted.remoteAddress, NULL)
           51  +	    isEqual: @"127.0.0.1"])
           52  +
           53  +	TEST(@"-[sendBuffer:length:]", R([client sendBuffer: "Hello!"
           54  +						     length: 6]))
           55  +
           56  +	TEST(@"-[receiveIntoBuffer:length:]", [accepted receiveIntoBuffer: buf
           57  +								   length: 6] &&
           58  +	    !memcmp(buf, "Hello!", 6))
           59  +
           60  +	objc_autoreleasePoolPop(pool);
           61  +}
           62  +@end

Modified tests/TestsAppDelegate.h from [375477e2d1] to [9dc2ad757b].

   198    198   - (void)RIPEMD160HashTests;
   199    199   @end
   200    200   
   201    201   @interface TestsAppDelegate (ScryptTests)
   202    202   - (void)scryptTests;
   203    203   @end
   204    204   
   205         -@interface TestsAppDelegate (OFSerializationTests)
   206         -- (void)serializationTests;
   207         -@end
   208         -
   209         -@interface TestsAppDelegate (OFSetTests)
   210         -- (void)setTests;
   211         -@end
   212         -
   213    205   @interface TestsAppDelegate (OFSHA1HashTests)
   214    206   - (void)SHA1HashTests;
   215    207   @end
   216    208   
   217    209   @interface TestsAppDelegate (OFSHA224HashTests)
   218    210   - (void)SHA224HashTests;
   219    211   @end
................................................................................
   225    217   @interface TestsAppDelegate (OFSHA384HashTests)
   226    218   - (void)SHA384HashTests;
   227    219   @end
   228    220   
   229    221   @interface TestsAppDelegate (OFSHA512HashTests)
   230    222   - (void)SHA512HashTests;
   231    223   @end
          224  +
          225  +@interface TestsAppDelegate (OFSCTPSocketTests)
          226  +- (void)SCTPSocketTests;
          227  +@end
   232    228   
   233    229   @interface TestsAppDelegate (OFSPXSocketTests)
   234    230   - (void)SPXSocketTests;
   235    231   @end
   236    232   
   237    233   @interface TestsAppDelegate (OFSPXStreamSocketTests)
   238    234   - (void)SPXStreamSocketTests;
   239    235   @end
          236  +
          237  +@interface TestsAppDelegate (OFSerializationTests)
          238  +- (void)serializationTests;
          239  +@end
          240  +
          241  +@interface TestsAppDelegate (OFSetTests)
          242  +- (void)setTests;
          243  +@end
   240    244   
   241    245   @interface TestsAppDelegate (OFSystemInfoTests)
   242    246   - (void)systemInfoTests;
   243    247   @end
   244    248   
   245    249   @interface TestsAppDelegate (OFHMACTests)
   246    250   - (void)HMACTests;

Modified tests/TestsAppDelegate.m from [8dafe87642] to [bf81e047c2].

   411    411   #if defined(OF_HAVE_FILES) && defined(HAVE_CODEPAGE_437)
   412    412   	[self INIFileTests];
   413    413   #endif
   414    414   #ifdef OF_HAVE_SOCKETS
   415    415   	[self socketTests];
   416    416   	[self TCPSocketTests];
   417    417   	[self UDPSocketTests];
          418  +# ifdef OF_HAVE_SCTP
          419  +	[self SCTPSocketTests];
          420  +# endif
   418    421   # ifdef OF_HAVE_IPX
   419    422   	[self IPXSocketTests];
   420    423   	[self SPXSocketTests];
   421    424   	[self SPXStreamSocketTests];
   422    425   # endif
   423    426   	[self kernelEventObserverTests];
   424    427   #endif