300
|
1 |
// Copyright (c) 2010 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\dll\t_nestedload.cpp
|
|
15 |
// Overview:
|
|
16 |
// Test that nested loading of DLLs does not cause incorrect constructor calls
|
|
17 |
// API Information:
|
|
18 |
// n/a
|
|
19 |
// Details:
|
|
20 |
// Platforms/Drives/Compatibility:
|
|
21 |
// All.
|
|
22 |
// Assumptions/Requirement/Pre-requisites:
|
|
23 |
// Failures and causes:
|
|
24 |
// Base Port information:
|
|
25 |
//
|
|
26 |
//
|
|
27 |
|
|
28 |
/*
|
|
29 |
|
|
30 |
This EXE links to and dynamically loads seven DLLs, t_nestdll1-7.dll.
|
|
31 |
The diagram below shows the structure of the linkage. Regular arrows
|
|
32 |
are normal static linkage, arrows marked with DY are dynamic loads with
|
|
33 |
RLibrary::Load.
|
|
34 |
|
|
35 |
+-----+ +---+ +---+
|
|
36 |
| EXE |----->| 1 |--DY->| 3 |
|
|
37 |
+-----+ +---+ +---+\
|
|
38 |
| \ \ EXE and 3 both link to 2
|
|
39 |
D \ \ +---+
|
|
40 |
Y +------------------------+-->| 2 |
|
|
41 |
| +---+
|
|
42 |
v
|
|
43 |
+---+
|
|
44 |
| 5 |
|
|
45 |
+---+\
|
|
46 |
| \
|
|
47 |
D \
|
|
48 |
Y \
|
|
49 |
| \
|
|
50 |
v \
|
|
51 |
+---+ \
|
|
52 |
| 6 | \
|
|
53 |
+---+ \
|
|
54 |
| \
|
|
55 |
D \
|
|
56 |
Y \
|
|
57 |
| \
|
|
58 |
v \ 5 and 7 both link to 4
|
|
59 |
+---+ \ +---+
|
|
60 |
| 7 |---------------+-->| 4 |
|
|
61 |
+---+ +---+
|
|
62 |
|
|
63 |
The result should be that the constructors are called in order from 1 to 7,
|
|
64 |
with no constructor being called more than once or omitted.
|
|
65 |
|
|
66 |
*/
|
|
67 |
|
|
68 |
#define __E32TEST_EXTENSION__
|
|
69 |
|
|
70 |
#include <e32test.h>
|
|
71 |
#include <e32svr.h>
|
|
72 |
|
|
73 |
IMPORT_C TInt DataForDLL1();
|
|
74 |
IMPORT_C TInt DataForDLL2();
|
|
75 |
|
|
76 |
TInt E32Main()
|
|
77 |
{
|
|
78 |
RTest test(_L("T_NESTEDLOAD"));
|
|
79 |
test.Title();
|
|
80 |
|
|
81 |
test.Start(_L("Test nested loading"));
|
|
82 |
|
|
83 |
test.Next(_L("Dummy calls to static dependencies"));
|
|
84 |
DataForDLL1();
|
|
85 |
DataForDLL2();
|
|
86 |
|
|
87 |
test.Next(_L("Load library triggering nested load"));
|
|
88 |
RLibrary lib;
|
|
89 |
test_KErrNone(lib.Load(_L("t_nestdll5.dll")));
|
|
90 |
|
|
91 |
test.Next(_L("Retrieve load order array"));
|
|
92 |
TInt* loadOrder = (TInt*)UserSvr::DllTls(0);
|
|
93 |
test_NotNull(loadOrder);
|
|
94 |
|
|
95 |
test.Next(_L("Load order:"));
|
|
96 |
TInt i;
|
|
97 |
for (i = 0; i < 100; ++i)
|
|
98 |
{
|
|
99 |
if (loadOrder[i] == 0)
|
|
100 |
break;
|
|
101 |
test.Printf(_L("%d "), loadOrder[i]);
|
|
102 |
}
|
|
103 |
test.Printf(_L("\n"));
|
|
104 |
|
|
105 |
// We expect DLLs 1-7 to be loaded in numerical order, with no repeats.
|
|
106 |
for (i = 0; i < 7; ++i)
|
|
107 |
test_Equal(i+1, loadOrder[i]);
|
|
108 |
test_Equal(0, loadOrder[7]);
|
|
109 |
|
|
110 |
test.End();
|
|
111 |
return(KErrNone);
|
|
112 |
}
|
|
113 |
|