Update contrib.
1 // Copyright (c) 2007-2010 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.
22 ///////////////////////////////////////////////////////////////////////////////////////
24 RTest TheTest(_L("t_sqlitetclstarter"));
26 _LIT(KTclExecutableName,"tclsqlite3.exe");
27 _LIT(KTclScriptName,"all.test");
29 _LIT(KStdioConfigFilePath, "C:\\system\\data\\");
30 _LIT(KStdioConfigFile, "C:\\system\\data\\config.ini");
32 _LIT(KLogsFilePath, "C:\\logs\\testexecute\\");
36 ///////////////////////////////////////////////////////////////////////////////////////
39 // Creates the appropriate stdio ini file to redirect stdio output to a file
42 void CreateIniFileForStdoutRedirection(void)
46 // check path exists otherwise create
47 if (!BaflUtils::FolderExists(theFs, KStdioConfigFilePath))
49 err = theFs.MkDirAll(KStdioConfigFilePath);
50 TheTest(err == KErrNone, __LINE__);
56 err = file.Create(theFs, KStdioConfigFile, EFileRead | EFileWrite);
57 TheTest(err == KErrNone, __LINE__);
59 TheTest(KErrNone == file.Write(_L8("[STDIO]\r\n")), __LINE__);
60 TheTest(KErrNone == file.Write(_L8("STDIN = MEDIA1\r\n")), __LINE__);
61 TheTest(KErrNone == file.Write(_L8("STDOUT = MEDIA2\r\n")), __LINE__);
62 TheTest(KErrNone == file.Write(_L8("[MEDIA1]\r\n")), __LINE__);
63 TheTest(KErrNone == file.Write(_L8("type = console\r\n")), __LINE__);
64 TheTest(KErrNone == file.Write(_L8("width = -1\r\n")), __LINE__);
65 TheTest(KErrNone == file.Write(_L8("height = -1\r\n")), __LINE__);
66 TheTest(KErrNone == file.Write(_L8("[MEDIA2]\r\n")), __LINE__);
67 TheTest(KErrNone == file.Write(_L8("type = file\r\n")), __LINE__);
68 TheTest(KErrNone == file.Write(_L8("path = C:\\logs\\testexecute\\t_sqlitetclstarter.htm\r\n")), __LINE__);
69 TheTest(KErrNone == file.Flush(),__LINE__);
75 ///////////////////////////////////////////////////////////////////////////////////////
78 // Deletes the stdio ini file
81 void DeleteIniFileForStdoutRedirection(void)
83 TInt err = theFs.Delete(KStdioConfigFile);
84 TheTest(err == KErrNone || err==KErrNotFound || err==KErrPathNotFound, __LINE__);
87 ///////////////////////////////////////////////////////////////////////////////////////
90 // Ensure the directory for the Logs file exists
93 void EnsureLogsDirectoryExists(void)
97 // check path exists otherwise create
98 if (!BaflUtils::FolderExists(theFs, KLogsFilePath))
100 err = theFs.MkDirAll(KLogsFilePath);
101 TheTest(err == KErrNone, __LINE__);
105 ///////////////////////////////////////////////////////////////////////////////////////
108 // Start the tcl process with a script
111 void StartTclProcess(void)
114 TInt err = process.Create(KTclExecutableName,KTclScriptName);
115 TheTest(err==KErrNone, __LINE__);
117 TRequestStatus processStatus;
118 process.Logon(processStatus);
122 TheTest.Printf(_L("Wait for TCL tests to finish\r\n"));
124 User::WaitForRequest(processStatus);
126 TheTest.Printf(_L("TCL tests finished %d\r\n"),processStatus.Int());
128 TheTest(processStatus.Int() == KErrNone, __LINE__);
131 ///////////////////////////////////////////////////////////////////////////////////////
136 TheTest.Start(_L("TCL tests"));
138 CTrapCleanup* tc = CTrapCleanup::New();
142 TInt err = theFs.Connect();
143 TheTest(err == KErrNone, __LINE__);
145 DeleteIniFileForStdoutRedirection();
147 CreateIniFileForStdoutRedirection();
149 EnsureLogsDirectoryExists();
153 DeleteIniFileForStdoutRedirection();
164 User::Heap().Check();