Update contrib.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include <stdlib.h> /* definition of exit() */
24 #include <sys/unistd.h>
25 #include <sys/ioctl.h>
32 @SYMTestCaseID SYSLIB-STDLIB-CT-1109
33 @SYMTestCaseDesc Tests for serial port
35 @SYMTestActions Open and configures the serial ports
36 @SYMTestExpectedResults Test must not fail
39 void OpenAndConfigure(void)
43 GlobalPort = open("COM1:",0);
44 (void)ioctl(GlobalPort, COMMIOCTL_GETCONFIG, &sc);
46 sc.iParity = ParityNone;
47 (void)ioctl(GlobalPort, COMMIOCTL_SETCONFIG, &sc);
51 @SYMTestCaseID SYSLIB-STDLIB-CT-1110
52 @SYMTestCaseDesc Tests for serial port
54 @SYMTestActions Notifies a thread for events on port
55 @SYMTestExpectedResults Test must not fail
59 void WaitForNotifyThread(void)
70 ret = ioctl(GlobalPort, COMMIOCTL_NOTIFYSUPPORTED, &signals);
71 val[0] = KNotifyDataAvailable;
72 ret = ioctl(GlobalPort, COMMIOCTL_NOTIFY, &val[0]);
73 if ((ret != -1) || (val[0] != KNotifyDataAvailable))
74 printf("NotifyThread returned %d, val[0] %d when checking data available\n", ret, val[0]);
77 val[0] = signals & ~KNotifyDataAvailable; //no data avail as it returns an error
78 ret = ioctl(GlobalPort, COMMIOCTL_NOTIFY, &val[0]);
79 printf("NotifyThread ret = %d, val[0] is %d, val[1] is %d, errno is %d\n", ret, val[0], val[1], errno);
85 @SYMTestCaseID SYSLIB-STDLIB-CT-1111
86 @SYMTestCaseDesc Tests for serial port
88 @SYMTestActions Keep reading infinitely from the port
89 @SYMTestExpectedResults Test must not fail
97 while (readcount-- > 0)
99 read(GlobalPort, buf, 100);
100 printf("ReadThread got %x\n", buf[0]);
109 start_posix_server(); /* calls SpawnPosixServer from C++ code */
114 t1 = create_thread(WaitForNotifyThread, "notify");
115 t2 = create_thread(readloop, "readloop");
120 (void)wait_for_thread(t2);
121 close(GlobalPort); //closing the port will force a notify
122 (void)wait_for_thread(t1);