1 # Python 2 compatibility
2 from __future__ import print_function
5 import xml.dom.minidom as DOM
6 from genEventing import parseTemplateNodes
7 from utilities import open_for_update
10 // Licensed to the .NET Foundation under one or more agreements.
11 // The .NET Foundation licenses this file to you under the MIT license.
12 // See the LICENSE file in the project root for more information.
14 /******************************************************************
16 DO NOT MODIFY. AUTOGENERATED FILE.
17 This file is generated using the logic from <root>/src/scripts/genEventing.py
19 ******************************************************************/
23 def generateClralltestEvents(sClrEtwAllMan):
24 tree = DOM.parse(sClrEtwAllMan)
27 for providerNode in tree.getElementsByTagName('provider'):
28 templateNodes = providerNode.getElementsByTagName('template')
29 allTemplates = parseTemplateNodes(templateNodes)
30 eventNodes = providerNode.getElementsByTagName('event')
31 for eventNode in eventNodes:
32 eventName = eventNode.getAttribute('symbol')
33 templateName = eventNode.getAttribute('template')
34 clrtestEvents.append(" EventXplatEnabled" + eventName + "();\n")
35 clrtestEvents.append("Error |= FireEtXplat" + eventName + "(\n")
39 template = allTemplates[templateName]
40 fnSig = template.signature
42 for params in fnSig.paramlist:
43 if params in template.structs:
44 line.append("sizeof(Struct1),\n")
47 fnparam = fnSig.getParam(params)
48 if fnparam.name.lower() == 'count':
51 if fnparam.winType == "win:Binary":
52 argline = 'win_Binary'
53 elif fnparam.winType == "win:Pointer" and fnparam.count == "win:count":
54 argline = "(const void**)&var11"
55 elif fnparam.winType == "win:Pointer" :
56 argline = "(const void*)var11"
57 elif fnparam.winType =="win:AnsiString":
58 argline = '" Testing AniString "'
59 elif fnparam.winType =="win:UnicodeString":
60 argline = 'W(" Testing UnicodeString ")'
62 if fnparam.count == "win:count":
65 argline = fnparam.winType.replace(":","_")
70 #remove trailing commas
75 clrtestEvents.extend(line)
77 return ''.join(clrtestEvents)
79 def generateSanityTest(sClrEtwAllMan,testDir):
81 if not os.path.exists(testDir):
84 test_cpp = testDir + "/clralltestevents.cpp"
85 testinfo = testDir + "/testinfo.dat"
87 with open_for_update(testinfo) as Testinfo:
89 Copyright (c) Microsoft Corporation. All rights reserved.
93 Section = EventProvider
94 Function = EventProvider
95 Name = PAL test for FireEtW* and EventEnabled* functions
97 EXE1 = eventprovidertest
98 Description = This is a sanity test to check that there are no crashes in Xplat eventing
102 with open_for_update(test_cpp) as Test_cpp:
103 Test_cpp.write(stdprolog)
105 /*=====================================================================
107 ** Source: clralltestevents.cpp
109 ** Purpose: Ensure Correctness of Eventing code
112 **===================================================================*/
114 #include <palsuite.h>
116 #include <clrxplatevents.h>
118 typedef struct _Struct1 {
120 unsigned short Data2;
121 unsigned short Data3;
122 unsigned char Data4[8];
125 Struct1 var21[2] = { { 245, 13, 14, "deadbea" }, { 542, 0, 14, "deadflu" } };
127 Struct1* var11 = var21;
128 Struct1* win_Struct = var21;
130 GUID win_GUID ={ 245, 13, 14, "deadbea" };
131 double win_Double =34.04;
132 ULONG win_ULong = 34;
133 BOOL win_Boolean = FALSE;
134 unsigned __int64 win_UInt64 = 114;
135 unsigned int win_UInt32 = 4;
136 unsigned short win_UInt16 = 12;
137 unsigned char win_UInt8 = 9;
139 BYTE* win_Binary =(BYTE*)var21 ;
140 int __cdecl main(int argc, char **argv)
142 #if defined(FEATURE_PAL)
143 /* Initialize the PAL.
146 if(0 != PAL_Initialize(argc, argv))
152 ULONG Error = ERROR_SUCCESS;
153 #if defined(FEATURE_EVENT_TRACE)
154 Trace("\\n Starting functional eventing APIs tests \\n");
157 Test_cpp.write(generateClralltestEvents(sClrEtwAllMan))
160 if (Error != ERROR_SUCCESS)
162 Fail("One or more eventing Apis failed\\n ");
165 Trace("\\n All eventing APIs were fired succesfully \\n");
166 #endif //defined(FEATURE_EVENT_TRACE)
167 #if defined(FEATURE_PAL)
186 #parse the command line
187 parser = argparse.ArgumentParser(description="Generates the Code required to instrument LTTtng logging mechanism")
189 required = parser.add_argument_group('required arguments')
190 required.add_argument('--man', type=str, required=True,
191 help='full path to manifest containig the description of events')
192 required.add_argument('--testdir', type=str, required=True,
193 help='full path to directory where the test assets will be deployed' )
194 args, unknown = parser.parse_known_args(argv)
196 print('Unknown argument(s): ', ', '.join(unknown))
199 sClrEtwAllMan = args.man
200 testDir = args.testdir
202 generateSanityTest(sClrEtwAllMan, testDir)
204 if __name__ == '__main__':
205 return_code = main(sys.argv[1:])
206 sys.exit(return_code)