os/kernelhwsrv/kerneltest/f32test/plugins/version_1/virus/t_virus.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32test\server\t_virus.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <f32file.h>
sl@0
    19
#include <e32test.h>
sl@0
    20
#include <e32svr.h>
sl@0
    21
#include <f32dbg.h>
sl@0
    22
#include "t_server.h"
sl@0
    23
sl@0
    24
GLREF_C void TestIfEqual( TInt aValue, TInt aExpected, TInt aLine, char aFileName[]);
sl@0
    25
sl@0
    26
#define TEST_FOR_ERROR( r )	TestIfEqual( r, KErrNone, __LINE__, __FILE__)
sl@0
    27
#define TEST_FOR_VALUE( r, expected ) TestIfEqual( r, expected, __LINE__, __FILE__)
sl@0
    28
sl@0
    29
_LIT( KValueTestFailMsg, "ERROR Got %d expected %d" );
sl@0
    30
GLDEF_C void TestIfEqual( TInt aValue, TInt aExpected, TInt aLine, char aFileName[])
sl@0
    31
	{
sl@0
    32
	if( aExpected != aValue )
sl@0
    33
		{
sl@0
    34
		TText filenameU[512];
sl@0
    35
		TUint i = 0;
sl@0
    36
		for (; (i < sizeof(filenameU)) && (aFileName[i] != (char)0); i++)
sl@0
    37
			{
sl@0
    38
			filenameU[i]=aFileName[i];
sl@0
    39
			}
sl@0
    40
		filenameU[i]=0;
sl@0
    41
		test.Printf( KValueTestFailMsg, aValue, aExpected );
sl@0
    42
		test.operator()( EFalse, aLine, &filenameU[0]);
sl@0
    43
		}
sl@0
    44
	}
sl@0
    45
sl@0
    46
GLDEF_D RTest test(_L("T_VIRUS"));
sl@0
    47
sl@0
    48
sl@0
    49
void CleanupFiles()
sl@0
    50
	{
sl@0
    51
	test.Next(_L("Delete any files leftover from a previous run"));
sl@0
    52
sl@0
    53
	TheFs.SetAtt(_L("C:\\sys\\bin\\t_vshook.pxt"),0, KEntryAttReadOnly);
sl@0
    54
	TheFs.Delete(_L("C:\\sys\\bin\\t_vshook.pxt"));
sl@0
    55
sl@0
    56
	TheFs.SetAtt(_L("C:\\virusdef.txt"),0, KEntryAttReadOnly);
sl@0
    57
	TheFs.Delete(_L("C:\\virusdef.txt"));
sl@0
    58
	
sl@0
    59
	TheFs.SetAtt(_L("virus1.txt"),0, KEntryAttReadOnly);
sl@0
    60
	TheFs.Delete(_L("virus1.txt"));
sl@0
    61
sl@0
    62
	TheFs.SetAtt(_L("virus2.txt"),0, KEntryAttReadOnly);
sl@0
    63
	TheFs.Delete(_L("virus2.txt"));
sl@0
    64
sl@0
    65
	TheFs.SetAtt(_L("c:\\virus3.txt"),0, KEntryAttReadOnly);
sl@0
    66
	TheFs.Delete(_L("c:\\virus3.txt"));
sl@0
    67
sl@0
    68
	TheFs.SetAtt(_L("clean.txt"),0, KEntryAttReadOnly);
sl@0
    69
	TheFs.Delete(_L("clean.txt"));
sl@0
    70
	}
sl@0
    71
sl@0
    72
void CopyFilesL()
sl@0
    73
	{
sl@0
    74
	//So that we have the same file on WINS and a platform,
sl@0
    75
	//we expect to find all the files on Z:\test.  We then
sl@0
    76
	//copy the virus scanner vsh and the definition file to
sl@0
    77
	//the C: drive and the files to be scanned to whatever
sl@0
    78
	//drive we're testing on.
sl@0
    79
	test.Next(_L("Copying files to the appropriate places"));
sl@0
    80
sl@0
    81
	TInt r = TheFs.MkDirAll(_L("C:\\sys\\bin\\"));
sl@0
    82
	if (r != KErrAlreadyExists)
sl@0
    83
		TEST_FOR_ERROR(r);
sl@0
    84
sl@0
    85
	//If we're not currently on drive C, make a sys\\bin directory
sl@0
    86
	//so we can test attempting to rename it
sl@0
    87
	r = TheFs.MkDirAll(_L("\\sys\\bin\\"));
sl@0
    88
	if (r != KErrAlreadyExists)
sl@0
    89
		TEST_FOR_ERROR(r);
sl@0
    90
sl@0
    91
	CFileMan* pFileMan = CFileMan::NewL(TheFs);
sl@0
    92
	r = pFileMan->Copy(_L("Z:\\test\\t_vshook.pxt"), _L("C:\\sys\\bin\\t_vshook.pxt"));
sl@0
    93
	TEST_FOR_ERROR(r);
sl@0
    94
sl@0
    95
	r = pFileMan->Copy(_L("Z:\\test\\virusdef.txt"), _L("C:\\virusdef.txt"));
sl@0
    96
	TEST_FOR_ERROR(r);
sl@0
    97
sl@0
    98
	r = pFileMan->Copy(_L("Z:\\test\\virus1.txt"), _L("virus1.txt"));
sl@0
    99
	TEST_FOR_ERROR(r);
sl@0
   100
sl@0
   101
	r = pFileMan->Copy(_L("Z:\\test\\virus2.txt"), _L("virus2.txt"));
sl@0
   102
	TEST_FOR_ERROR(r);
sl@0
   103
sl@0
   104
	r = pFileMan->Copy(_L("Z:\\test\\clean.txt"), _L("clean.txt"));
sl@0
   105
	TEST_FOR_ERROR(r);
sl@0
   106
sl@0
   107
	delete pFileMan;
sl@0
   108
	}
sl@0
   109
sl@0
   110
void TestFileAccessBeforeVirusScanner()
sl@0
   111
	{
sl@0
   112
sl@0
   113
	//Check that we can read all the files we want before the
sl@0
   114
	//virus scanner is loaded.
sl@0
   115
	test.Next(_L("Test opening files before virus scanner is installed"));
sl@0
   116
sl@0
   117
	RFile file;
sl@0
   118
	TBuf8<512> buffer;
sl@0
   119
sl@0
   120
	TInt r = file.Open(TheFs, _L("C:\\virusdef.txt"), EFileShareAny);
sl@0
   121
sl@0
   122
	TEST_FOR_ERROR(r);
sl@0
   123
	r = file.Read(buffer);
sl@0
   124
	TEST_FOR_ERROR(r);
sl@0
   125
	file.Close();
sl@0
   126
sl@0
   127
	r = file.Open(TheFs, _L("virus1.txt"), EFileShareAny);
sl@0
   128
	TEST_FOR_ERROR(r);
sl@0
   129
	r = file.Read(buffer);
sl@0
   130
	TEST_FOR_ERROR(r);
sl@0
   131
	file.Close();
sl@0
   132
sl@0
   133
	r = file.Open(TheFs, _L("virus2.txt"), EFileShareAny);
sl@0
   134
	TEST_FOR_ERROR(r);
sl@0
   135
	r = file.Read(buffer);
sl@0
   136
	TEST_FOR_ERROR(r);
sl@0
   137
	file.Close();
sl@0
   138
sl@0
   139
	r = file.Open(TheFs, _L("clean.txt"), EFileShareAny);
sl@0
   140
	TEST_FOR_ERROR(r);
sl@0
   141
	r = file.Read(buffer);
sl@0
   142
	TEST_FOR_ERROR(r);
sl@0
   143
	file.Close();
sl@0
   144
	}
sl@0
   145
sl@0
   146
void TestLoadingOfVirusScanner()
sl@0
   147
	{
sl@0
   148
	test.Next(_L("Test the loading of the virus scanner"));
sl@0
   149
sl@0
   150
	// Try loading the virus scanner.
sl@0
   151
	TInt r = TheFs.AddPlugin(_L("t_vshook"));
sl@0
   152
	TEST_FOR_ERROR(r);
sl@0
   153
sl@0
   154
	// Try loading the virus scanner again.
sl@0
   155
	r = TheFs.AddPlugin(_L("t_vshook"));
sl@0
   156
	TEST_FOR_VALUE(r, KErrAlreadyExists);
sl@0
   157
sl@0
   158
sl@0
   159
	// Try mounting the virus scanner.
sl@0
   160
	r = TheFs.MountPlugin(_L("VsHook"));
sl@0
   161
	TEST_FOR_ERROR(r);
sl@0
   162
sl@0
   163
sl@0
   164
	//Test the name functions
sl@0
   165
	TFullName vsName;
sl@0
   166
	r = TheFs.PluginName(vsName,0,0);
sl@0
   167
	test.Printf(_L("Virus scanner name is: %S\n"), &vsName);
sl@0
   168
sl@0
   169
	}
sl@0
   170
sl@0
   171
void TestUnloadingOfVirusScanner()
sl@0
   172
	{
sl@0
   173
	test.Next(_L("Test unloading the virus scanner"));
sl@0
   174
sl@0
   175
	//Unload the virus scanner
sl@0
   176
	//Wait for it to empty it's input queue.
sl@0
   177
	User::After(3000000);
sl@0
   178
sl@0
   179
	TInt r = TheFs.DismountPlugin(_L("VsHook"));
sl@0
   180
	TEST_FOR_ERROR(r);
sl@0
   181
sl@0
   182
	r = TheFs.DismountPlugin(_L("VsHook"));
sl@0
   183
	TEST_FOR_VALUE(r, KErrNotFound);
sl@0
   184
sl@0
   185
	r = TheFs.RemovePlugin(_L("VsHook"));
sl@0
   186
	TEST_FOR_ERROR(r);
sl@0
   187
sl@0
   188
	r = TheFs.RemovePlugin(_L("VsHook"));
sl@0
   189
	TEST_FOR_VALUE(r, KErrNotFound);
sl@0
   190
	}
sl@0
   191
sl@0
   192
sl@0
   193
void TestFileAccessDuringVirusScannerL()
sl@0
   194
	{
sl@0
   195
sl@0
   196
	RFile file;
sl@0
   197
	TBuf8<512> buffer;
sl@0
   198
sl@0
   199
	test.Next(_L("Test opening files with the virus scanner installed"));
sl@0
   200
sl@0
   201
	TInt r = file.Open(TheFs, _L("C:\\virusdef.txt"), EFileShareAny);
sl@0
   202
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   203
sl@0
   204
	r = file.Open(TheFs, _L("virus1.txt"), EFileShareAny);
sl@0
   205
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   206
sl@0
   207
	r = file.Open(TheFs, _L("virus2.txt"), EFileShareAny);
sl@0
   208
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   209
sl@0
   210
	r = file.Open(TheFs, _L("C:\\sys\\bin\\t_vshook.pxt"), EFileShareAny);
sl@0
   211
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   212
sl@0
   213
	// Set up a change notifier
sl@0
   214
	// - The virus scanner renames files before scanning, so check that the
sl@0
   215
	//	 internal rename operation hasn't caused a notification.
sl@0
   216
	TRequestStatus reqStat;
sl@0
   217
	TheFs.NotifyChange(ENotifyAll, reqStat, _L("C:\\F32-TST\\"));
sl@0
   218
	TEST_FOR_VALUE(reqStat.Int(), KRequestPending);
sl@0
   219
sl@0
   220
	r = file.Open(TheFs, _L("clean.txt"), EFileShareAny);
sl@0
   221
	TEST_FOR_ERROR(r);
sl@0
   222
	r = file.Read(buffer);
sl@0
   223
	TEST_FOR_ERROR(r);
sl@0
   224
	file.Close();
sl@0
   225
sl@0
   226
	// Verify that cleaning file didn't cause a notification
sl@0
   227
	TEST_FOR_VALUE(reqStat.Int(), KRequestPending);
sl@0
   228
	TheFs.NotifyChangeCancel(reqStat);
sl@0
   229
sl@0
   230
	//Files on Z: are not scanned, so we should be able to open
sl@0
   231
	//an infected file
sl@0
   232
	r = file.Open(TheFs, _L("Z:\\test\\virus1.txt"), EFileShareAny);
sl@0
   233
	TEST_FOR_ERROR(r);
sl@0
   234
	r = file.Read(buffer);
sl@0
   235
	TEST_FOR_ERROR(r);
sl@0
   236
	file.Close();
sl@0
   237
sl@0
   238
	test.Next(_L("Test opening of scanner files"));
sl@0
   239
	r = file.Open(TheFs, _L("C:\\sys\\bin\\t_vshook.pxt"), EFileShareAny);
sl@0
   240
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   241
sl@0
   242
	r = file.Open(TheFs, _L("C:\\virusdef.txt"), EFileShareAny);
sl@0
   243
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   244
sl@0
   245
sl@0
   246
sl@0
   247
	test.Next(_L("Test renaming of infected files"));
sl@0
   248
	//With RFs::Rename()
sl@0
   249
	r = TheFs.Rename(_L("virus1.txt"), _L("renamed1.txt"));
sl@0
   250
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   251
sl@0
   252
	//Test RFs::Replace()
sl@0
   253
	r = TheFs.Replace(_L("virus1.txt"), _L("renamed1.txt"));
sl@0
   254
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   255
sl@0
   256
	//CFileMan opens the file for exclusive access,
sl@0
   257
	//so wait for the virus scanner to finish.
sl@0
   258
	User::After(1000000);
sl@0
   259
sl@0
   260
	//With CFileMan
sl@0
   261
	CFileMan* pFileMan = CFileMan::NewL(TheFs);
sl@0
   262
	r = pFileMan->Rename(_L("virus1.txt"), _L("renamed1.txt"));
sl@0
   263
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   264
sl@0
   265
	test.Next(_L("Test renaming virus scanner files"));
sl@0
   266
	//Test renaming of virus definition file
sl@0
   267
	r = TheFs.Rename(_L("C:\\virusdef.txt"), _L("C:\\renameddef.txt"));
sl@0
   268
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   269
sl@0
   270
	//With CFileMan
sl@0
   271
	r = pFileMan->Rename(_L("C:\\virusdef.txt"), _L("C:\\renameddef.txt"));
sl@0
   272
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   273
sl@0
   274
	//Test renaming of virus scanner hook
sl@0
   275
	r = TheFs.Rename(_L("C:\\sys\\bin\\t_vshook.pxt"), _L("C:\\sys\\bin\\renames.pxt"));
sl@0
   276
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   277
sl@0
   278
	//With CFileMan
sl@0
   279
	r = pFileMan->Rename(_L("C:\\sys\\bin\\t_vshook.pxt"), _L("C:\\sys\\bin\\renames.pxt"));
sl@0
   280
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   281
sl@0
   282
sl@0
   283
	test.Next(_L("Test deleting an infected file"));
sl@0
   284
	r = TheFs.SetAtt(_L("virus2.txt"), 0,KEntryAttReadOnly); 
sl@0
   285
	TEST_FOR_ERROR(r);
sl@0
   286
	r = TheFs.Delete(_L("virus2.txt"));
sl@0
   287
	TEST_FOR_ERROR(r);
sl@0
   288
sl@0
   289
	test.Next(_L("Test closing an infected file"));
sl@0
   290
	r = file.Create(TheFs, _L("c:\\virus3.txt"), EFileWrite | EFileShareAny);
sl@0
   291
	TEST_FOR_ERROR(r);
sl@0
   292
	r = file.Write(_L8("This a generated infected file."));
sl@0
   293
	TEST_FOR_ERROR(r);
sl@0
   294
	file.Close();
sl@0
   295
sl@0
   296
	//Test renaming a directory
sl@0
   297
	test.Next(_L("Test renaming a directory"));
sl@0
   298
	r = TheFs.Rename(_L("\\sys\\bin\\"), _L("\\virusdir1\\"));
sl@0
   299
	TEST_FOR_VALUE(r, KErrAccessDenied);
sl@0
   300
sl@0
   301
	delete pFileMan;
sl@0
   302
	}
sl@0
   303
sl@0
   304
void TestReadFileSectionInterceptL()
sl@0
   305
	{
sl@0
   306
	TBuf8<16> testDes;
sl@0
   307
sl@0
   308
	test.Next(_L("Test ReadFileSection intercept GetName and GetFileAccessInfo support"));	
sl@0
   309
	// trigger RFs::ReadFileSection intercept
sl@0
   310
	TInt r = TheFs.ReadFileSection(_L("clean.txt"),0,testDes,8);
sl@0
   311
	test(r==KErrNone);
sl@0
   312
	}
sl@0
   313
sl@0
   314
sl@0
   315
void TestFileAccessAfterVirusScanner()
sl@0
   316
	{
sl@0
   317
sl@0
   318
	test.Next(_L("Test opening files after virus scanner is uninstalled"));
sl@0
   319
sl@0
   320
	RFile file;
sl@0
   321
	TBuf8<512> buffer;
sl@0
   322
sl@0
   323
	test.Next(_L("Test the virus definition file"));
sl@0
   324
	TInt r = file.Open(TheFs, _L("C:\\virusdef.txt"), EFileShareAny);
sl@0
   325
	TEST_FOR_ERROR(r);
sl@0
   326
	r = file.Read(buffer);
sl@0
   327
	TEST_FOR_ERROR(r);
sl@0
   328
	file.Close();
sl@0
   329
sl@0
   330
	if (buffer.Length() == buffer.MaxLength())
sl@0
   331
		{
sl@0
   332
		//The definition file should be less than 512 bytes in length.
sl@0
   333
		r = KErrOverflow;
sl@0
   334
		TEST_FOR_ERROR(r);
sl@0
   335
		}
sl@0
   336
sl@0
   337
	//Make sure that the virus scanner has not "fixed" this file
sl@0
   338
	r = buffer.Find(_L8("infection"));
sl@0
   339
	TEST_FOR_VALUE(r, KErrNotFound);
sl@0
   340
sl@0
   341
	test.Next(_L("Test the clean file has not been corrected"));
sl@0
   342
	r = file.Open(TheFs, _L("clean.txt"), EFileShareAny);
sl@0
   343
	TEST_FOR_ERROR(r);
sl@0
   344
	r = file.Read(buffer);
sl@0
   345
	TEST_FOR_ERROR(r);
sl@0
   346
	file.Close();
sl@0
   347
sl@0
   348
	if (buffer.Length() == buffer.MaxLength())
sl@0
   349
		{
sl@0
   350
		//The clean file should be less than 512 bytes in length.
sl@0
   351
		r = KErrOverflow;
sl@0
   352
		TEST_FOR_ERROR(r);
sl@0
   353
		}
sl@0
   354
sl@0
   355
	//Make sure that the virus scanner has not "fixed" this file
sl@0
   356
	r = buffer.Find(_L8("infection"));
sl@0
   357
	TEST_FOR_VALUE(r, KErrNotFound);
sl@0
   358
	
sl@0
   359
sl@0
   360
	//Virus2.txt should have been successfully deleted.
sl@0
   361
	r = file.Open(TheFs, _L("virus2.txt"), EFileRead);
sl@0
   362
	TEST_FOR_VALUE(r, KErrNotFound);
sl@0
   363
sl@0
   364
	//Virus1.txt should have been corrected several times.
sl@0
   365
	//Here's the order in which we did things to it in
sl@0
   366
	//TestFileAccessDuringVirusScannerL():
sl@0
   367
	//1. Open for read.
sl@0
   368
	//2. Rename using RFS
sl@0
   369
	//3. Rename using CFileMan
sl@0
   370
	test.Next(_L("Test the infected file has been corrected"));
sl@0
   371
	r = file.Open(TheFs, _L("virus1.txt"), EFileShareAny);
sl@0
   372
	TEST_FOR_ERROR(r);
sl@0
   373
	r = file.Read(buffer);
sl@0
   374
	TEST_FOR_ERROR(r);
sl@0
   375
	file.Close();
sl@0
   376
sl@0
   377
	if (buffer.Length() == buffer.MaxLength())
sl@0
   378
		{
sl@0
   379
		//The infected file should be less than 512 bytes in length.
sl@0
   380
		r = KErrOverflow;
sl@0
   381
		TEST_FOR_ERROR(r);
sl@0
   382
		}
sl@0
   383
sl@0
   384
	//Make sure that the virus scanner has "fixed" this file,
sl@0
   385
	//and that the fixing order is correct.
sl@0
   386
	TInt fixPos1 = buffer.Find(_L8("infection detected - file open"));
sl@0
   387
	if (fixPos1 < 0)
sl@0
   388
		{
sl@0
   389
		TEST_FOR_ERROR(fixPos1);
sl@0
   390
		}
sl@0
   391
	TInt fixPos2 = buffer.Find(_L8("infection detected - file rename"));
sl@0
   392
	if (fixPos2 < 0)
sl@0
   393
		{
sl@0
   394
		TEST_FOR_ERROR(fixPos2);
sl@0
   395
		}
sl@0
   396
	//The -32 is the length of the "infection detected - file rename"
sl@0
   397
	TPtrC8 rightPart = buffer.Right((buffer.Length() - fixPos2) - 32);
sl@0
   398
	TInt fixPos3 = rightPart.Find(_L8("infection detected - file rename"));
sl@0
   399
	fixPos3 += fixPos2 + 32;
sl@0
   400
	if (fixPos3 < 0)
sl@0
   401
		{
sl@0
   402
		TEST_FOR_ERROR(fixPos3);
sl@0
   403
		}
sl@0
   404
	
sl@0
   405
	if (!(fixPos3 > fixPos2 && fixPos3 > fixPos1 && fixPos2 > fixPos1))
sl@0
   406
		{
sl@0
   407
		//The fixes have not been written to the file in the correct
sl@0
   408
		//order
sl@0
   409
		r = KErrGeneral;
sl@0
   410
		TEST_FOR_ERROR(r);
sl@0
   411
		}
sl@0
   412
sl@0
   413
sl@0
   414
	test.Next(_L("Test a generated infection is detected"));
sl@0
   415
	r = file.Open(TheFs, _L("c:\\virus3.txt"), EFileShareAny);
sl@0
   416
	TEST_FOR_ERROR(r);
sl@0
   417
	r = file.Read(buffer);
sl@0
   418
	TEST_FOR_ERROR(r);
sl@0
   419
	file.Close();
sl@0
   420
sl@0
   421
	if (buffer.Length() == buffer.MaxLength())
sl@0
   422
		{
sl@0
   423
		//The clean file should be less than 512 bytes in length.
sl@0
   424
		r = KErrOverflow;
sl@0
   425
		TEST_FOR_ERROR(r);
sl@0
   426
		}
sl@0
   427
sl@0
   428
	//Make sure that the virus scanner has "fixed" this file
sl@0
   429
	r = buffer.Find(_L8("infection detected - file close"));
sl@0
   430
	if (r < 0)
sl@0
   431
		TEST_FOR_ERROR(r);
sl@0
   432
	}
sl@0
   433
sl@0
   434
void DeleteFiles()
sl@0
   435
	{
sl@0
   436
sl@0
   437
	test.Next(_L("Cleanup files"));
sl@0
   438
	//Delete all of the files created using CopyFilesL() so
sl@0
   439
	//that the test can run multiple times.
sl@0
   440
	TInt r = TheFs.SetAtt(_L("C:\\sys\\bin\\t_vshook.pxt"),0, KEntryAttReadOnly);
sl@0
   441
	TEST_FOR_ERROR(r);
sl@0
   442
	r = TheFs.Delete(_L("C:\\sys\\bin\\t_vshook.pxt"));
sl@0
   443
	TEST_FOR_ERROR(r);
sl@0
   444
sl@0
   445
	r = TheFs.RmDir(_L("\\sys\\bin\\"));
sl@0
   446
	if (r != KErrInUse)
sl@0
   447
		TEST_FOR_ERROR(r);
sl@0
   448
sl@0
   449
	r = TheFs.SetAtt(_L("C:\\virusdef.txt"),0, KEntryAttReadOnly);
sl@0
   450
	TEST_FOR_ERROR(r);
sl@0
   451
	r = TheFs.Delete(_L("C:\\virusdef.txt"));
sl@0
   452
	TEST_FOR_ERROR(r);
sl@0
   453
sl@0
   454
	r = TheFs.SetAtt(_L("virus1.txt"),0, KEntryAttReadOnly);
sl@0
   455
	TEST_FOR_ERROR(r);
sl@0
   456
	r = TheFs.Delete(_L("virus1.txt"));
sl@0
   457
	TEST_FOR_ERROR(r);
sl@0
   458
sl@0
   459
	r = TheFs.SetAtt(_L("c:\\virus3.txt"),0, KEntryAttReadOnly);
sl@0
   460
	TEST_FOR_ERROR(r);
sl@0
   461
	r = TheFs.Delete(_L("c:\\virus3.txt"));
sl@0
   462
	TEST_FOR_ERROR(r);
sl@0
   463
sl@0
   464
	r = TheFs.SetAtt(_L("clean.txt"),0, KEntryAttReadOnly);
sl@0
   465
	TEST_FOR_ERROR(r);
sl@0
   466
	r = TheFs.Delete(_L("clean.txt"));
sl@0
   467
	TEST_FOR_ERROR(r);
sl@0
   468
	}	
sl@0
   469
sl@0
   470
sl@0
   471
GLDEF_C void CallTestsL()
sl@0
   472
	{
sl@0
   473
sl@0
   474
	CleanupFiles();
sl@0
   475
	CopyFilesL();
sl@0
   476
sl@0
   477
	TestFileAccessBeforeVirusScanner();
sl@0
   478
sl@0
   479
	TestLoadingOfVirusScanner();
sl@0
   480
sl@0
   481
	TestFileAccessDuringVirusScannerL();
sl@0
   482
sl@0
   483
	TestReadFileSectionInterceptL();
sl@0
   484
sl@0
   485
	TestUnloadingOfVirusScanner();
sl@0
   486
sl@0
   487
	TestFileAccessAfterVirusScanner();
sl@0
   488
sl@0
   489
	DeleteFiles();
sl@0
   490
sl@0
   491
	}
sl@0
   492