os/kernelhwsrv/kerneltest/f32test/server/t_findcapnone.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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 the License "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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\server\t_findcapnone.cpp
    15 // PlatSec compatibility test. Application capability is NONE
    16 // TFindFile should return KErrPermissionDenied for FindByDir requests
    17 // in /sys and /private/anyOther folders, if path is avialable.
    18 // z:\sys\bin\t_findcaptestfile.txt is used for testing.
    19 // If the file is not avialable in the location, test will not panic.
    20 // This is because, TFindFile returns KErrPermissionDenied,
    21 // whether the file is available or not, in such folders.
    22 // 
    23 //
    24 
    25 #include <e32test.h>
    26 #include <f32file.h>
    27 
    28 _LIT(KTestString,"t_findcapnone");
    29 
    30 LOCAL_C RTest test(KTestString);
    31 
    32 LOCAL_C	RFs FileServer;
    33 
    34 LOCAL_C TInt TestFind(const TPtrC16 aTestDesc, const TPtrC16 aFPath, const TPtrC16 aFName)
    35 	{
    36 	TInt Err;
    37 	test.Next(aTestDesc);
    38 	TFindFile FindFile(FileServer);
    39 	Err=FindFile.FindByDir(aFName,aFPath);
    40 	return Err;
    41 	}
    42 
    43 
    44 GLDEF_C TInt E32Main()
    45 	{
    46 	TInt Err;
    47 	
    48 	test.Title();
    49 	
    50 	Err=FileServer.Connect();
    51 	
    52 	test(Err==KErrNone);
    53     
    54     // RTest.Next is called from function "TestFind()".
    55     // RTest.Start is called here to start the test.
    56     test.Start(_L("Test Starts : Dummy Test"));
    57 	
    58 	// Test: Find non existing file in existing /sys folder
    59 	//
    60 	// Drive Name			: Z:
    61 	// Path 				: sys\bin
    62 	// File Name			: nonexistingfile.txt
    63 	//
    64 	// Expected return value: KErrPermissionDenied
    65 	Err=TestFind(_L("Drive specified & available Path exists File does not exist"),
    66 		         _L("z:\\sys\\bin\\"),
    67 		         _L("nonexistingfile.txt"));
    68 	
    69 	test(Err==KErrPermissionDenied);
    70 	
    71 	// Test: Find existing file in existing /sys folder
    72 	//
    73 	// Drive Name			: Z:
    74 	// Path 				: sys\bin
    75 	// File Name			: t_findcaptestfile.txt
    76 	//
    77 	// Expected return value: KErrPermissionDenied
    78 	Err=TestFind(_L("Drive specified & available Path exists File exists"),
    79 		         _L("z:\\sys\\bin\\"),
    80 		         _L("t_findcaptestfile.txt"));
    81 	
    82 	test(Err==KErrPermissionDenied);
    83 	
    84 	// Test: Find non existing file in existing / non existing /sys folder
    85 	//
    86 	// Drive Name			: C:
    87 	// Path 				: sys
    88 	// File Name			: nonexisting.txt
    89 	//
    90 	// Expected return value: KErrPermissionDenied
    91 	Err=TestFind(_L("Drive specified & available Path may exist File does not exist"),
    92 		         _L("c:\\sys\\"),
    93 		         _L("nonexisting.txt"));
    94 	
    95 	test(Err==KErrPermissionDenied);
    96 	
    97 	// Test: Find existing file in /sys folder without specifying the path
    98 	//
    99 	// Drive Name			: Not specified.
   100 	// Path 				: sys\bin
   101 	// File Name			: t_findcaptestfile.txt
   102 	//
   103 	// Expected return value: KErrPermissionDenied
   104 	Err=TestFind(_L("Drive not specified Path exists File exists"),
   105 		         _L("\\sys\\bin\\"),
   106 		         _L("t_findcaptestfile.txt"));
   107 	
   108 	test(Err==KErrPermissionDenied);
   109 	
   110 	// Test: Find non existing file in /sys folder without specifying the path
   111 	//
   112 	// Drive Name			: Not specified
   113 	// Path 				: sys
   114 	// File Name			: nonexistingfile.txt
   115 	//
   116 	// Expected return value: KErrPermissionDenied
   117 	Err=TestFind(_L("Drive not specified Path exists File does not exist"),
   118 		         _L("\\sys\\"),
   119 		         _L("nonexisting.txt"));
   120 	
   121 	test(Err==KErrPermissionDenied);
   122 	
   123 	FileServer.Close();
   124 	
   125     test.Printf(_L("Test completed\n"));
   126     
   127 	test.End();
   128 	test.Close();
   129 	
   130 	return KErrNone;
   131 	}