1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * CTestStep derived class implementation to print OS build version to log file output |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file TEFBuildInfoLogStep.cpp |
|
23 */ |
|
24 |
|
25 #include "tefbuildinfologstep.h" |
|
26 #include <test/wrapperutilsplugin.h> |
|
27 #include <test/tefutils.h> |
|
28 |
|
29 CTEFBuildInfoLogStep::CTEFBuildInfoLogStep() |
|
30 { |
|
31 SetTestStepName(KPrintBuildInfo); |
|
32 } |
|
33 |
|
34 /** |
|
35 * Run preamble scripts for the test |
|
36 * Make the connection with the File Server and creates a session object |
|
37 * @return - TVerdict code |
|
38 * Override of base class pure virtual |
|
39 */ |
|
40 TVerdict CTEFBuildInfoLogStep::doTestStepPreambleL() |
|
41 { |
|
42 User::LeaveIfError(iFs.Connect()); |
|
43 iSessionConnected=ETrue; |
|
44 return TestStepResult(); |
|
45 } |
|
46 |
|
47 /** |
|
48 * Run postample scripts for the test |
|
49 * @return - TVerdict code |
|
50 * Override of base class pure virtual |
|
51 */ |
|
52 TVerdict CTEFBuildInfoLogStep::doTestStepPostambleL() |
|
53 { |
|
54 iFs.Close(); |
|
55 iSessionConnected=EFalse; |
|
56 return TestStepResult(); |
|
57 } |
|
58 |
|
59 /** |
|
60 * Overrides base class virtual |
|
61 * @return - TVerdict codes |
|
62 * Parses buildinfo.txt from \epoc32\... and prints it to TEF log file outout |
|
63 */ |
|
64 TVerdict CTEFBuildInfoLogStep::doTestStepL() |
|
65 { |
|
66 const TInt KBuildVersionMaxLength = 128; |
|
67 const TInt KBuildInfoFileMaxLength = 256; |
|
68 |
|
69 RFs fileServer; |
|
70 TVersionName version(fileServer.Version().Name()); |
|
71 TDriveName defaultSysDrive(_L("C:")); |
|
72 RLibrary pluginLibrary; |
|
73 CWrapperUtilsPlugin* plugin = TEFUtils::WrapperPluginNew(pluginLibrary); |
|
74 |
|
75 if (plugin!=NULL) |
|
76 { |
|
77 TDriveUnit driveUnit(plugin->GetSystemDrive()); |
|
78 defaultSysDrive.Copy(driveUnit.Name()); |
|
79 delete plugin; |
|
80 pluginLibrary.Close(); |
|
81 } |
|
82 |
|
83 TBuf<KBuildVersionMaxLength> text; |
|
84 TInt startOfData; |
|
85 TBuf8<KBuildInfoFileMaxLength> buf; |
|
86 |
|
87 TFileName buildInfoFilePath(KBuildInfoFilePath); |
|
88 buildInfoFilePath.Replace(0, 2, defaultSysDrive); |
|
89 |
|
90 SetTestStepResult(EFail); |
|
91 if(BaflUtils::FileExists(iFs,buildInfoFilePath)) |
|
92 { |
|
93 if (!(iFs.IsFileOpen(buildInfoFilePath,iSessionConnected))) |
|
94 { |
|
95 RFile file; |
|
96 User::LeaveIfError(file.Open(iFs, buildInfoFilePath, EFileShareAny)); |
|
97 User::LeaveIfError(file.Read(buf)); |
|
98 startOfData = buf.Find(KBuildNumberFlag); |
|
99 if(!(startOfData==KErrNotFound)) // if build number flag present |
|
100 { |
|
101 startOfData += KOffsetToBuildNumber; |
|
102 if((KLengthOfBuildNumber+startOfData)<=buf.Length()) // if build number present |
|
103 { |
|
104 text.Copy(buf.Mid(startOfData)); |
|
105 INFO_PRINTF2(_L("Build version is %S"),&text); |
|
106 SetTestStepResult(EPass); |
|
107 } |
|
108 else |
|
109 { |
|
110 INFO_PRINTF1(_L("Build number is not specified along with ManufacturerSoftwareBuild flag")); |
|
111 } |
|
112 } |
|
113 else |
|
114 { |
|
115 INFO_PRINTF1(_L("ManufacturerSoftwareBuild flag is not found in the buildinfo.txt file")); |
|
116 } |
|
117 file.Close(); |
|
118 } |
|
119 } |
|
120 else |
|
121 { |
|
122 INFO_PRINTF2(_L("%S - file not found"), &buildInfoFilePath); |
|
123 } |
|
124 return TestStepResult(); |
|
125 } |
|