Update contrib.
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test of the ESTW32 facilities for accessing Win32 stdin/stdout/stderr
23 void failed(int line, TInt aExpected, TInt aResult)
26 buf.Format(_L("Failed line %d: expected %d, got %d"), line, aExpected, aResult);
30 User::After(5*1000000); // 5 seconds
34 #define test(err,expected) if (err!=expected) failed(__LINE__,expected,err)
35 #define test_status(status,expected) if (status.Int()!=expected) failed(__LINE__,expected,status.Int())
38 @SYMTestCaseID SYSLIB-STDLIB-CT-1042
39 @SYMTestCaseDesc Tests for the ESTW32 facilities for accessing Win32 stdin/stdout/stderr
41 @SYMTestActions Open RWin32Stream::stdin,stdout,stderr and test writing to these streams.
42 Check for KErrNone flag
43 @SYMTestExpectedResults Test must not fail
48 RWin32Stream::StartServer();
54 TRequestStatus status;
56 err=stdin.Open(Kstdin);
58 err=stdout.Open(Kstdout);
60 err=stderr.Open(Kstderr);
67 outbuf=_L8("Writing to stderr\n");
68 stderr.Write(status,outbuf);
69 User::WaitForRequest(status);
70 test_status(status,KErrNone);
72 outbuf=_L8("1234XXX89");
73 stderr.Write(status,outbuf,4);
74 User::WaitForRequest(status);
75 test_status(status,KErrNone);
79 outbuf=_L8("Writing to stdout\n");
80 stdout.Write(status,outbuf);
81 User::WaitForRequest(status);
82 test_status(status,KErrNone);
84 outbuf=_L8("1234XXX89");
85 stdout.Write(status,outbuf,4);
86 User::WaitForRequest(status);
87 test_status(status,KErrNone);
91 stdin.Read(status,outbuf);
92 User::WaitForRequest(status);
94 TRequestStatus outStatus;
96 commentary.Format(_L8("\nread %d, status %d\n"), outbuf.Length(), status.Int());
97 stderr.Write(outStatus,commentary);
98 User::WaitForRequest(outStatus);
99 test_status(outStatus,KErrNone);
101 if (status.Int()==KErrEof)
104 stdout.Write(outStatus,outbuf);
105 User::WaitForRequest(outStatus);
106 test_status(outStatus,KErrNone);
109 outbuf=_L8("Stdin closed\n");
110 stderr.Write(status,outbuf);
111 User::WaitForRequest(status);
112 test_status(status,KErrNone);
116 IMPORT_C void RegisterWsExe(const TDesC &aName);
118 GLDEF_C TInt E32Main()
120 CTrapCleanup* TheTrapCleanup=CTrapCleanup::New();
122 #ifdef USE_FULL_GRAPHICAL_ENVIRONMENT
123 // Cause the Eikon environment to come into existence
125 sem.CreateGlobal(_L("WsExeSem"),0);
126 RegisterWsExe(sem.FullName());
129 User::InfoPrint(_L("Test passed"));
131 sem.Wait(); // continue running Eikon until that exits as well
134 User::InfoPrint(_L("Test passed"));