os/kernelhwsrv/kerneltest/e32test/nkern/t_implicit.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-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
// e32test\nkern\t_implicit.cpp
sl@0
    15
// Overview:
sl@0
    16
// Test nanokernel implicit system lock
sl@0
    17
// API Information:
sl@0
    18
// NKern::LockSystem and NKern::UnlockSystem
sl@0
    19
// Details:
sl@0
    20
// - Load and open the logical device driver ("D_IMPLICIT"). Verify results.
sl@0
    21
// - The LDD uses three separate threads to test the nanokernel implicit 
sl@0
    22
// system lock with changing priorities, round-robin and a "dry run".
sl@0
    23
// - Close the channels and verify results are as expected.
sl@0
    24
// Platforms/Drives/Compatibility:
sl@0
    25
// All.
sl@0
    26
// Assumptions/Requirement/Pre-requisites:
sl@0
    27
// Failures and causes:
sl@0
    28
// Base Port information:
sl@0
    29
// 
sl@0
    30
//
sl@0
    31
sl@0
    32
#include <e32test.h>
sl@0
    33
#include "d_implicit.h"
sl@0
    34
#include <u32hal.h>
sl@0
    35
#include <e32svr.h>
sl@0
    36
sl@0
    37
RTest test(_L("T_IMPLICIT"));
sl@0
    38
sl@0
    39
void Wait(TInt aSeconds)
sl@0
    40
	{
sl@0
    41
	while (aSeconds>0)
sl@0
    42
		{
sl@0
    43
		--aSeconds;
sl@0
    44
		User::After(1000000);
sl@0
    45
		test.Printf(_L("."));
sl@0
    46
		}
sl@0
    47
	}
sl@0
    48
sl@0
    49
TInt Display(const SStats& a)
sl@0
    50
	{
sl@0
    51
	test.Printf(_L("\nc1=%6d c2=%6d c3=%6d f=%6d\n"),a.iCount1,a.iCount2,a.iCount3,a.iFailCount);
sl@0
    52
	return a.iFailCount;
sl@0
    53
	}
sl@0
    54
sl@0
    55
GLDEF_C TInt E32Main()
sl@0
    56
	{
sl@0
    57
sl@0
    58
	test.Title();
sl@0
    59
sl@0
    60
	if (UserSvr::HalFunction(EHalGroupKernel, EKernelHalSmpSupported, 0, 0) == KErrNone)
sl@0
    61
		{
sl@0
    62
		test.Printf(_L("*********************************\n"));
sl@0
    63
		test.Printf(_L("*  NOT SUPPORTED ON SMP SYSTEMS *\n"));
sl@0
    64
		test.Printf(_L("*********************************\n"));
sl@0
    65
		User::After(2000000);
sl@0
    66
		return(0);
sl@0
    67
		}
sl@0
    68
sl@0
    69
	test.Start(_L("Load LDD"));
sl@0
    70
	TInt r=User::LoadLogicalDevice(_L("D_IMPLICIT"));
sl@0
    71
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
    72
	test.Next(_L("Open channel"));
sl@0
    73
	RImpSysTest impSys;
sl@0
    74
	r=impSys.Open();
sl@0
    75
	test(r==KErrNone);
sl@0
    76
sl@0
    77
	SStats s;
sl@0
    78
	test.Next(_L("Test with changing priorities"));
sl@0
    79
	r=impSys.Start(RImpSysTest::ETestPriority);
sl@0
    80
	test(r==KErrNone);
sl@0
    81
	Wait(30);
sl@0
    82
	r=impSys.Stop(s);
sl@0
    83
	test(r==KErrNone);
sl@0
    84
	TInt f1=Display(s);
sl@0
    85
sl@0
    86
	test.Next(_L("Test with round-robin"));
sl@0
    87
	r=impSys.Start(RImpSysTest::ETestRoundRobin);
sl@0
    88
	test(r==KErrNone);
sl@0
    89
	Wait(30);
sl@0
    90
	r=impSys.Stop(s);
sl@0
    91
	test(r==KErrNone);
sl@0
    92
	TInt f2=Display(s);
sl@0
    93
sl@0
    94
	test.Next(_L("Dry run"));
sl@0
    95
	r=impSys.Start(RImpSysTest::ETestDummy);
sl@0
    96
	test(r==KErrNone);
sl@0
    97
	Wait(30);
sl@0
    98
	r=impSys.Stop(s);
sl@0
    99
	test(r==KErrNone);
sl@0
   100
	TInt f3=Display(s);
sl@0
   101
sl@0
   102
	test.Next(_L("Close channel"));
sl@0
   103
	impSys.Close();
sl@0
   104
sl@0
   105
	test(f1==0);
sl@0
   106
	test(f2==0);
sl@0
   107
	test(f3==0);
sl@0
   108
sl@0
   109
	test.End();
sl@0
   110
	return KErrNone;
sl@0
   111
	}