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