1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_findcapnone.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,131 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32test\server\t_findcapnone.cpp
1.18 +// PlatSec compatibility test. Application capability is NONE
1.19 +// TFindFile should return KErrPermissionDenied for FindByDir requests
1.20 +// in /sys and /private/anyOther folders, if path is avialable.
1.21 +// z:\sys\bin\t_findcaptestfile.txt is used for testing.
1.22 +// If the file is not avialable in the location, test will not panic.
1.23 +// This is because, TFindFile returns KErrPermissionDenied,
1.24 +// whether the file is available or not, in such folders.
1.25 +//
1.26 +//
1.27 +
1.28 +#include <e32test.h>
1.29 +#include <f32file.h>
1.30 +
1.31 +_LIT(KTestString,"t_findcapnone");
1.32 +
1.33 +LOCAL_C RTest test(KTestString);
1.34 +
1.35 +LOCAL_C RFs FileServer;
1.36 +
1.37 +LOCAL_C TInt TestFind(const TPtrC16 aTestDesc, const TPtrC16 aFPath, const TPtrC16 aFName)
1.38 + {
1.39 + TInt Err;
1.40 + test.Next(aTestDesc);
1.41 + TFindFile FindFile(FileServer);
1.42 + Err=FindFile.FindByDir(aFName,aFPath);
1.43 + return Err;
1.44 + }
1.45 +
1.46 +
1.47 +GLDEF_C TInt E32Main()
1.48 + {
1.49 + TInt Err;
1.50 +
1.51 + test.Title();
1.52 +
1.53 + Err=FileServer.Connect();
1.54 +
1.55 + test(Err==KErrNone);
1.56 +
1.57 + // RTest.Next is called from function "TestFind()".
1.58 + // RTest.Start is called here to start the test.
1.59 + test.Start(_L("Test Starts : Dummy Test"));
1.60 +
1.61 + // Test: Find non existing file in existing /sys folder
1.62 + //
1.63 + // Drive Name : Z:
1.64 + // Path : sys\bin
1.65 + // File Name : nonexistingfile.txt
1.66 + //
1.67 + // Expected return value: KErrPermissionDenied
1.68 + Err=TestFind(_L("Drive specified & available Path exists File does not exist"),
1.69 + _L("z:\\sys\\bin\\"),
1.70 + _L("nonexistingfile.txt"));
1.71 +
1.72 + test(Err==KErrPermissionDenied);
1.73 +
1.74 + // Test: Find existing file in existing /sys folder
1.75 + //
1.76 + // Drive Name : Z:
1.77 + // Path : sys\bin
1.78 + // File Name : t_findcaptestfile.txt
1.79 + //
1.80 + // Expected return value: KErrPermissionDenied
1.81 + Err=TestFind(_L("Drive specified & available Path exists File exists"),
1.82 + _L("z:\\sys\\bin\\"),
1.83 + _L("t_findcaptestfile.txt"));
1.84 +
1.85 + test(Err==KErrPermissionDenied);
1.86 +
1.87 + // Test: Find non existing file in existing / non existing /sys folder
1.88 + //
1.89 + // Drive Name : C:
1.90 + // Path : sys
1.91 + // File Name : nonexisting.txt
1.92 + //
1.93 + // Expected return value: KErrPermissionDenied
1.94 + Err=TestFind(_L("Drive specified & available Path may exist File does not exist"),
1.95 + _L("c:\\sys\\"),
1.96 + _L("nonexisting.txt"));
1.97 +
1.98 + test(Err==KErrPermissionDenied);
1.99 +
1.100 + // Test: Find existing file in /sys folder without specifying the path
1.101 + //
1.102 + // Drive Name : Not specified.
1.103 + // Path : sys\bin
1.104 + // File Name : t_findcaptestfile.txt
1.105 + //
1.106 + // Expected return value: KErrPermissionDenied
1.107 + Err=TestFind(_L("Drive not specified Path exists File exists"),
1.108 + _L("\\sys\\bin\\"),
1.109 + _L("t_findcaptestfile.txt"));
1.110 +
1.111 + test(Err==KErrPermissionDenied);
1.112 +
1.113 + // Test: Find non existing file in /sys folder without specifying the path
1.114 + //
1.115 + // Drive Name : Not specified
1.116 + // Path : sys
1.117 + // File Name : nonexistingfile.txt
1.118 + //
1.119 + // Expected return value: KErrPermissionDenied
1.120 + Err=TestFind(_L("Drive not specified Path exists File does not exist"),
1.121 + _L("\\sys\\"),
1.122 + _L("nonexisting.txt"));
1.123 +
1.124 + test(Err==KErrPermissionDenied);
1.125 +
1.126 + FileServer.Close();
1.127 +
1.128 + test.Printf(_L("Test completed\n"));
1.129 +
1.130 + test.End();
1.131 + test.Close();
1.132 +
1.133 + return KErrNone;
1.134 + }