sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* Test of the unsupported option values in setsockopt
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <stdio.h>
|
sl@0
|
23 |
#include <errno.h>
|
sl@0
|
24 |
#include <stdlib.h>
|
sl@0
|
25 |
#include <string.h>
|
sl@0
|
26 |
#include <unistd.h>
|
sl@0
|
27 |
#include <sys/types.h>
|
sl@0
|
28 |
#include <sys/socket.h>
|
sl@0
|
29 |
#include <sys/ioctl.h>
|
sl@0
|
30 |
#include <libc/netinet/in.h>
|
sl@0
|
31 |
#include <libc/arpa/inet.h>
|
sl@0
|
32 |
#include <netdb.h>
|
sl@0
|
33 |
#include <reent.h>
|
sl@0
|
34 |
|
sl@0
|
35 |
#include "CTEST.H" /* includes C interface to EPOC32 threads, and SpawnPosixServer */
|
sl@0
|
36 |
|
sl@0
|
37 |
test_Data;
|
sl@0
|
38 |
|
sl@0
|
39 |
struct sockaddr_in testaddr;
|
sl@0
|
40 |
|
sl@0
|
41 |
//The structure _reent contains *all* globals needed by the library.
|
sl@0
|
42 |
struct _reent* p;
|
sl@0
|
43 |
|
sl@0
|
44 |
unsigned short int port = 2001;
|
sl@0
|
45 |
|
sl@0
|
46 |
/**
|
sl@0
|
47 |
@SYMTestCaseID SYSLIB-STDLIB-CT-1119
|
sl@0
|
48 |
@SYMTestCaseDesc Tests for the unsupported option values in setsockopt
|
sl@0
|
49 |
@SYMTestPriority High
|
sl@0
|
50 |
@SYMTestActions Tests for creation of a socket and setting unsupported options on a socket
|
sl@0
|
51 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
52 |
@SYMREQ REQ0000
|
sl@0
|
53 |
*/
|
sl@0
|
54 |
void testSimple()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
int fd1;
|
sl@0
|
57 |
int err;
|
sl@0
|
58 |
int optionbuf[20];
|
sl@0
|
59 |
size_t optionsize;
|
sl@0
|
60 |
|
sl@0
|
61 |
//Creating stream sockets to be used in the test
|
sl@0
|
62 |
test_Next("Create stream sockets");
|
sl@0
|
63 |
fd1=socket(AF_INET, SOCK_STREAM, 0);
|
sl@0
|
64 |
test_ok(fd1>=0);
|
sl@0
|
65 |
|
sl@0
|
66 |
optionbuf[0]=7*1024;
|
sl@0
|
67 |
optionsize=sizeof(optionbuf[0]);
|
sl@0
|
68 |
|
sl@0
|
69 |
//valid option e.g SO_SNDBUF(positive value 3)
|
sl@0
|
70 |
err=setsockopt(fd1,SOL_SOCKET,SO_SNDBUF,optionbuf,optionsize);
|
sl@0
|
71 |
p=_REENT;
|
sl@0
|
72 |
//No error in setsockopt with returned value in p->_errno=0
|
sl@0
|
73 |
test(err==0);
|
sl@0
|
74 |
test(p->_errno==0);
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
//invalid(not supported) option e.g IP_ADD_MEMBERSHIP(negative value -8)
|
sl@0
|
78 |
err=setsockopt(fd1,SOL_SOCKET,IP_ADD_MEMBERSHIP,optionbuf,optionsize);
|
sl@0
|
79 |
p=_REENT;
|
sl@0
|
80 |
//Error in setsockopt with returned value in p->_errno=ENOSYS(88)
|
sl@0
|
81 |
test(err==-1);
|
sl@0
|
82 |
test(p->_errno==ENOSYS);
|
sl@0
|
83 |
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
int main()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
int err;
|
sl@0
|
89 |
test_Title("AF_INET Streams");
|
sl@0
|
90 |
|
sl@0
|
91 |
err=CommInit(0); /* ensure a workable comms environment */
|
sl@0
|
92 |
test(err==0);
|
sl@0
|
93 |
IN_SET_LOOPBACK_ADDR(&testaddr);
|
sl@0
|
94 |
|
sl@0
|
95 |
testSimple();
|
sl@0
|
96 |
|
sl@0
|
97 |
test_Close();
|
sl@0
|
98 |
return 0;
|
sl@0
|
99 |
}
|