11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
4- using System ;
5- using System . Collections . Generic ;
6- using System . IO ;
7- using LTTngDataExtensions . SourceDataCookers ;
84using LTTngDataExtensions . DataOutputTypes ;
5+ using LTTngDataExtensions . SourceDataCookers ;
6+ using LTTngDataExtensions . SourceDataCookers . Diagnostic_Messages ;
7+ using LTTngDataExtensions . SourceDataCookers . Disk ;
8+ using LTTngDataExtensions . SourceDataCookers . Module ;
99using LTTngDataExtensions . SourceDataCookers . Syscall ;
1010using LTTngDataExtensions . SourceDataCookers . Thread ;
1111using Microsoft . Performance . SDK . Extensibility ;
1212using Microsoft . Performance . SDK . Processing ;
1313using Microsoft . Performance . Toolkit . Engine ;
1414using Microsoft . VisualStudio . TestTools . UnitTesting ;
15- using UnitTestCommon ;
16- using LTTngDataExtensions . SourceDataCookers . Diagnostic_Messages ;
17- using LTTngDataExtensions . SourceDataCookers . Module ;
18- using LTTngDataExtensions . SourceDataCookers . Disk ;
15+ using System ;
16+ using System . Collections . Generic ;
17+ using System . IO ;
1918using System . IO . Compression ;
2019using System . Linq ;
2120
@@ -48,42 +47,42 @@ public static void ProcessTrace()
4847 Assert . IsTrue ( lttngDataPath . Exists ) ;
4948
5049 // Approach #1 - Engine - Doesn't test tables UI but tests processing
51- var runtime = Engine . Create ( ) ;
52-
53- runtime . AddFile ( lttngDataPath . FullName ) ;
54-
55- // Enable our various types of data
56- var lttngGenericEventDataCooker = new LTTngGenericEventDataCooker ( ) ;
57- LTTngGenericEventDataCookerPath = lttngGenericEventDataCooker . Path ;
58- runtime . EnableCooker ( LTTngGenericEventDataCookerPath ) ;
59-
60- var lttngSyscallDataCooker = new LTTngSyscallDataCooker ( ) ;
61- LTTngSyscallDataCookerPath = lttngSyscallDataCooker . Path ;
62- runtime . EnableCooker ( LTTngSyscallDataCookerPath ) ;
63-
64- var lttngThreadDataCooker = new LTTngThreadDataCooker ( ) ;
65- LTTngThreadDataCookerPath = lttngThreadDataCooker . Path ;
66- runtime . EnableCooker ( LTTngThreadDataCookerPath ) ;
67-
68- var lttngDmesgDataCooker = new LTTngDmesgDataCooker ( ) ;
69- LTTngDmesgDataCookerPath = lttngDmesgDataCooker . Path ;
70- runtime . EnableCooker ( LTTngDmesgDataCookerPath ) ;
71-
72- var lttngModuleDataCooker = new LTTngModuleDataCooker ( ) ;
73- LTTngModuleDataCookerPath = lttngModuleDataCooker . Path ;
74- runtime . EnableCooker ( LTTngModuleDataCookerPath ) ;
75-
76- var lttngDiskDataCooker = new LTTngDiskDataCooker ( ) ;
77- LTTngDiskDataCookerPath = lttngDiskDataCooker . Path ;
78- runtime . EnableCooker ( LTTngDiskDataCookerPath ) ;
79-
80- //
81- // Process our data.
82- //
83-
84- RuntimeExecutionResults = runtime . Process ( ) ;
85-
86- IsTraceProcessed = true ;
50+ using ( var runtime = Engine . Create ( new FileDataSource ( lttngDataPath . FullName ) ) )
51+ {
52+
53+ // Enable our various types of data
54+ var lttngGenericEventDataCooker = new LTTngGenericEventDataCooker ( ) ;
55+ LTTngGenericEventDataCookerPath = lttngGenericEventDataCooker . Path ;
56+ runtime . EnableCooker ( LTTngGenericEventDataCookerPath ) ;
57+
58+ var lttngSyscallDataCooker = new LTTngSyscallDataCooker ( ) ;
59+ LTTngSyscallDataCookerPath = lttngSyscallDataCooker . Path ;
60+ runtime . EnableCooker ( LTTngSyscallDataCookerPath ) ;
61+
62+ var lttngThreadDataCooker = new LTTngThreadDataCooker ( ) ;
63+ LTTngThreadDataCookerPath = lttngThreadDataCooker . Path ;
64+ runtime . EnableCooker ( LTTngThreadDataCookerPath ) ;
65+
66+ var lttngDmesgDataCooker = new LTTngDmesgDataCooker ( ) ;
67+ LTTngDmesgDataCookerPath = lttngDmesgDataCooker . Path ;
68+ runtime . EnableCooker ( LTTngDmesgDataCookerPath ) ;
69+
70+ var lttngModuleDataCooker = new LTTngModuleDataCooker ( ) ;
71+ LTTngModuleDataCookerPath = lttngModuleDataCooker . Path ;
72+ runtime . EnableCooker ( LTTngModuleDataCookerPath ) ;
73+
74+ var lttngDiskDataCooker = new LTTngDiskDataCooker ( ) ;
75+ LTTngDiskDataCookerPath = lttngDiskDataCooker . Path ;
76+ runtime . EnableCooker ( LTTngDiskDataCookerPath ) ;
77+
78+ //
79+ // Process our data.
80+ //
81+
82+ RuntimeExecutionResults = runtime . Process ( ) ;
83+
84+ IsTraceProcessed = true ;
85+ }
8786 }
8887 }
8988 }
@@ -98,15 +97,14 @@ public void ProcessTraceAsFolder()
9897
9998 ZipFile . ExtractToDirectory ( lttngData [ 0 ] , tempDirectory ) ;
10099
101- // Approach #1 - Engine - Doesn't test tables UI but tests processing
102- var runtime = Engine . Create ( ) ;
103-
104100 var ds = new DirectoryDataSource ( tempDirectory ) ;
105- runtime . AddDataSource ( ds ) ;
106-
107- Assert . IsTrue ( ds . IsDirectory ( ) ) ;
108- Assert . IsTrue ( runtime . SourceDataCookers . Count ( ) >= 1 ) ;
109- Assert . IsTrue ( runtime . AvailableTables . Count ( ) >= 1 ) ;
101+ // Approach #1 - Engine - Doesn't test tables UI but tests processing
102+ using ( var runtime = Engine . Create ( ds ) )
103+ {
104+ Assert . IsTrue ( ds . IsDirectory ( ) ) ;
105+ Assert . IsTrue ( runtime . EnabledCookers . Where ( cooker => cooker . DataCookerType == DataCookerType . SourceDataCooker ) . Count ( ) >= 1 ) ;
106+ Assert . IsTrue ( runtime . AvailableTables . Count ( ) >= 1 ) ;
107+ }
110108
111109 Directory . Delete ( tempDirectory , true ) ;
112110 }
0 commit comments