44using System ;
55using System . Collections . Generic ;
66using System . IO ;
7- using LTTngDataExtensions . SourceDataCookers ;
7+ using System . IO . Compression ;
8+ using System . Linq ;
89using LTTngDataExtensions . DataOutputTypes ;
10+ using LTTngDataExtensions . SourceDataCookers ;
11+ using LTTngDataExtensions . SourceDataCookers . Diagnostic_Messages ;
12+ using LTTngDataExtensions . SourceDataCookers . Disk ;
13+ using LTTngDataExtensions . SourceDataCookers . Module ;
914using LTTngDataExtensions . SourceDataCookers . Syscall ;
1015using LTTngDataExtensions . SourceDataCookers . Thread ;
1116using Microsoft . Performance . SDK . Extensibility ;
1217using Microsoft . Performance . SDK . Processing ;
1318using Microsoft . Performance . Toolkit . Engine ;
1419using Microsoft . VisualStudio . TestTools . UnitTesting ;
15- using UnitTestCommon ;
16- using LTTngDataExtensions . SourceDataCookers . Diagnostic_Messages ;
17- using LTTngDataExtensions . SourceDataCookers . Module ;
18- using LTTngDataExtensions . SourceDataCookers . Disk ;
19- using System . IO . Compression ;
20- using System . Linq ;
2120
2221namespace LTTngDataExtUnitTest
2322{
@@ -48,41 +47,39 @@ 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-
50+ var runtime = Engine . Create ( new FileDataSource ( lttngDataPath . FullName ) ) ;
51+
52+ // Enable our various types of data
53+ var lttngGenericEventDataCooker = new LTTngGenericEventDataCooker ( ) ;
54+ LTTngGenericEventDataCookerPath = lttngGenericEventDataCooker . Path ;
55+ runtime . EnableCooker ( LTTngGenericEventDataCookerPath ) ;
56+
57+ var lttngSyscallDataCooker = new LTTngSyscallDataCooker ( ) ;
58+ LTTngSyscallDataCookerPath = lttngSyscallDataCooker . Path ;
59+ runtime . EnableCooker ( LTTngSyscallDataCookerPath ) ;
60+
61+ var lttngThreadDataCooker = new LTTngThreadDataCooker ( ) ;
62+ LTTngThreadDataCookerPath = lttngThreadDataCooker . Path ;
63+ runtime . EnableCooker ( LTTngThreadDataCookerPath ) ;
64+
65+ var lttngDmesgDataCooker = new LTTngDmesgDataCooker ( ) ;
66+ LTTngDmesgDataCookerPath = lttngDmesgDataCooker . Path ;
67+ runtime . EnableCooker ( LTTngDmesgDataCookerPath ) ;
68+
69+ var lttngModuleDataCooker = new LTTngModuleDataCooker ( ) ;
70+ LTTngModuleDataCookerPath = lttngModuleDataCooker . Path ;
71+ runtime . EnableCooker ( LTTngModuleDataCookerPath ) ;
72+
73+ var lttngDiskDataCooker = new LTTngDiskDataCooker ( ) ;
74+ LTTngDiskDataCookerPath = lttngDiskDataCooker . Path ;
75+ runtime . EnableCooker ( LTTngDiskDataCookerPath ) ;
76+
77+ //
78+ // Process our data.
79+ //
80+
81+ RuntimeExecutionResults = runtime . Process ( ) ;
82+
8683 IsTraceProcessed = true ;
8784 }
8885 }
@@ -96,18 +93,29 @@ public void ProcessTraceAsFolder()
9693
9794 string tempDirectory = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
9895
99- ZipFile . ExtractToDirectory ( lttngData [ 0 ] , tempDirectory ) ;
100-
101- // Approach #1 - Engine - Doesn't test tables UI but tests processing
102- var runtime = Engine . Create ( ) ;
103-
104- 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 ) ;
110-
96+ using ( var zipFile = ZipFile . OpenRead ( lttngData [ 0 ] ) )
97+ {
98+ zipFile . ExtractToDirectory ( tempDirectory ) ;
99+ }
100+
101+ using ( var dataSourceSet = DataSourceSet . Create ( ) )
102+ {
103+ var ds = new DirectoryDataSource ( tempDirectory ) ;
104+ dataSourceSet . AddDataSource ( ds ) ;
105+
106+ // Approach #1 - Engine - Doesn't test tables UI but tests processing
107+ using ( var runtime = Engine . Create ( new EngineCreateInfo ( dataSourceSet . AsReadOnly ( ) ) ) )
108+ {
109+ //
110+ // We do not assert that any cookers are enabled since we did not explicitly enable cookers here
111+ //
112+
113+ Assert . IsTrue ( ds . IsDirectory ( ) ) ;
114+ Assert . IsTrue ( runtime . AvailableTables . Count ( ) >= 1 ) ;
115+ }
116+ }
117+
118+
111119 Directory . Delete ( tempDirectory , true ) ;
112120 }
113121
0 commit comments