sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Test of the unsupported option values in setsockopt sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "CTEST.H" /* includes C interface to EPOC32 threads, and SpawnPosixServer */ sl@0: sl@0: test_Data; sl@0: sl@0: struct sockaddr_in testaddr; sl@0: sl@0: //The structure _reent contains *all* globals needed by the library. sl@0: struct _reent* p; sl@0: sl@0: unsigned short int port = 2001; sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-STDLIB-CT-1119 sl@0: @SYMTestCaseDesc Tests for the unsupported option values in setsockopt sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for creation of a socket and setting unsupported options on a socket sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void testSimple() sl@0: { sl@0: int fd1; sl@0: int err; sl@0: int optionbuf[20]; sl@0: size_t optionsize; sl@0: sl@0: //Creating stream sockets to be used in the test sl@0: test_Next("Create stream sockets"); sl@0: fd1=socket(AF_INET, SOCK_STREAM, 0); sl@0: test_ok(fd1>=0); sl@0: sl@0: optionbuf[0]=7*1024; sl@0: optionsize=sizeof(optionbuf[0]); sl@0: sl@0: //valid option e.g SO_SNDBUF(positive value 3) sl@0: err=setsockopt(fd1,SOL_SOCKET,SO_SNDBUF,optionbuf,optionsize); sl@0: p=_REENT; sl@0: //No error in setsockopt with returned value in p->_errno=0 sl@0: test(err==0); sl@0: test(p->_errno==0); sl@0: sl@0: sl@0: //invalid(not supported) option e.g IP_ADD_MEMBERSHIP(negative value -8) sl@0: err=setsockopt(fd1,SOL_SOCKET,IP_ADD_MEMBERSHIP,optionbuf,optionsize); sl@0: p=_REENT; sl@0: //Error in setsockopt with returned value in p->_errno=ENOSYS(88) sl@0: test(err==-1); sl@0: test(p->_errno==ENOSYS); sl@0: sl@0: } sl@0: sl@0: int main() sl@0: { sl@0: int err; sl@0: test_Title("AF_INET Streams"); sl@0: sl@0: err=CommInit(0); /* ensure a workable comms environment */ sl@0: test(err==0); sl@0: IN_SET_LOOPBACK_ADDR(&testaddr); sl@0: sl@0: testSimple(); sl@0: sl@0: test_Close(); sl@0: return 0; sl@0: }