Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ StyleCopReport.xml
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
#*.log
*.vspscc
*.vssscc
.builds
Expand Down
6 changes: 3 additions & 3 deletions CtfUnitTest/CtfUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
25 changes: 25 additions & 0 deletions LTTngDataExtUnitTest/LTTngDataExtUnitTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK.Runtime" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.108.2" />
<PackageReference Include="Moq" Version="4.15.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LttngDataExtensions\LTTngDataExtensions.csproj" />
<ProjectReference Include="..\UnitTestCommon\UnitTestCommon.csproj" />
</ItemGroup>

</Project>
196 changes: 196 additions & 0 deletions LTTngDataExtUnitTest/LTTngUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.IO;
using LttngCds;
using LttngDataExtensions.SourceDataCookers;
using LttngDataExtensions.DataOutputTypes;
using LttngDataExtensions.SourceDataCookers.Syscall;
using LttngDataExtensions.SourceDataCookers.Thread;
using Microsoft.Performance.SDK.Extensibility;
using Microsoft.Performance.SDK.Processing;
using Microsoft.Performance.Toolkit.Engine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using UnitTestCommon;
using LttngDataExtensions.SourceDataCookers.Diagnostic_Messages;
using Microsoft.Performance.SDK;
using LttngDataExtensions.SourceDataCookers.Module;
using LttngDataExtensions.SourceDataCookers.Disk;

namespace LTTngDataExtUnitTest
{
[TestClass]
public class LTTngUnitTest
{
public static bool IsTraceProcessed = false;
public static object IsTraceProcessedLock = new object();

private static RuntimeExecutionResults RuntimeExecutionResults;

private static DataCookerPath LTTngGenericEventDataCookerPath;
private static DataCookerPath LTTngSyscallDataCookerPath;
private static DataCookerPath LTTngThreadDataCookerPath;
private static DataCookerPath LttngDmesgDataCookerPath;
private static DataCookerPath LttngModuleDataCookerPath;
private static DataCookerPath LttngDiskDataCookerPath;

public static void ProcessTrace()
{
lock (IsTraceProcessedLock)
{
if (!IsTraceProcessed)
{
// Input data
string[] lttngData = { @"..\..\..\..\TestData\LTTng\lttng-kernel-trace.ctf" };
var lttngDataPath = new FileInfo(lttngData[0]);
Assert.IsTrue(lttngDataPath.Exists);

// Approach #1 - Engine - Doesn't test tables UI but tests processing
var runtime = Engine.Create();

runtime.AddFile(lttngDataPath.FullName);

// Enable our various types of data
var lttngGenericEventDataCooker = new LttngGenericEventDataCooker();
LTTngGenericEventDataCookerPath = lttngGenericEventDataCooker.Path;
runtime.EnableCooker(LTTngGenericEventDataCookerPath);

var lttngSyscallDataCooker = new LttngSyscallDataCooker();
LTTngSyscallDataCookerPath = lttngSyscallDataCooker.Path;
runtime.EnableCooker(LTTngSyscallDataCookerPath);

var lttngThreadDataCooker = new LttngThreadDataCooker();
LTTngThreadDataCookerPath = lttngThreadDataCooker.Path;
runtime.EnableCooker(LTTngThreadDataCookerPath);

var lttngDmesgDataCooker = new LttngDmesgDataCooker();
LttngDmesgDataCookerPath = lttngDmesgDataCooker.Path;
runtime.EnableCooker(LttngDmesgDataCookerPath);

var lttngModuleDataCooker = new LttngModuleDataCooker();
LttngModuleDataCookerPath = lttngModuleDataCooker.Path;
runtime.EnableCooker(LttngModuleDataCookerPath);

var lttngDiskDataCooker = new LttngDiskDataCooker();
LttngDiskDataCookerPath = lttngDiskDataCooker.Path;
runtime.EnableCooker(LttngDiskDataCookerPath);

//
// Process our data.
//

RuntimeExecutionResults = runtime.Process();

IsTraceProcessed = true;
}
}
}

[TestMethod]
public void DiagnosticMessageTable()
{
ProcessTrace();

var eventData = RuntimeExecutionResults.QueryOutput<IReadOnlyList<IDiagnosticMessage>>(
new DataOutputPath(
LttngDmesgDataCookerPath,
nameof(LttngDmesgDataCooker.DiagnosticMessages)));

Assert.IsTrue(eventData.Count == 0); // TODO - UT - Trace has no DiagMessages
}

[TestMethod]
public void DiskTable()
{
ProcessTrace();

var eventData = RuntimeExecutionResults.QueryOutput<IReadOnlyList<DiskActivity>>(
new DataOutputPath(
LttngDiskDataCookerPath,
nameof(LttngDiskDataCooker.DiskActivity)));

Assert.IsTrue(eventData.Count > 0);
}

[TestMethod]
public void ExecutionEventTable()
{
ProcessTrace();

var eventData = RuntimeExecutionResults.QueryOutput<IReadOnlyList<IExecutionEvent>>(
new DataOutputPath(
LTTngThreadDataCookerPath,
nameof(LttngThreadDataCooker.ExecutionEvents)));

Assert.IsTrue(eventData.Count > 0);
}

[TestMethod]
public void FileEventsTable()
{
ProcessTrace();

var eventData = RuntimeExecutionResults.QueryOutput<IReadOnlyList<FileEvent>>(
new DataOutputPath(
LttngDiskDataCookerPath,
nameof(LttngDiskDataCooker.FileEvents)));

Assert.IsTrue(eventData.Count > 0);
}

[TestMethod]
public void GenericEventsTable()
{
ProcessTrace();

var eventData = RuntimeExecutionResults.QueryOutput<ProcessedEventData<LttngGenericEvent>>(
new DataOutputPath(
LTTngGenericEventDataCookerPath,
nameof(LttngGenericEventDataCooker.Events)));

Assert.IsTrue(eventData.Count > 0);
}

[TestMethod]
public void ModuleEventsTable()
{
ProcessTrace();

var eventData = RuntimeExecutionResults.QueryOutput<IReadOnlyList<ModuleEvent>>(
new DataOutputPath(
LttngModuleDataCookerPath,
nameof(LttngModuleDataCooker.ModuleEvents)));

Assert.IsTrue(eventData.Count == 0); // TODO - UT - Trace has no ModuleEvents
}

[TestMethod]
public void SyscallTable()
{
ProcessTrace();

var eventData = RuntimeExecutionResults.QueryOutput<List<ISyscall>>(
new DataOutputPath(
LTTngSyscallDataCookerPath,
nameof(LttngSyscallDataCooker.Syscalls)));

Assert.IsTrue(eventData.Count > 0);
}

[TestMethod]
public void ThreadTable()
{
ProcessTrace();

var threads = RuntimeExecutionResults.QueryOutput<IReadOnlyList<IThread>>(
new DataOutputPath(
LTTngThreadDataCookerPath,
nameof(LttngThreadDataCooker.Threads)));

Assert.IsTrue(threads.Count > 0);
}
}
}
96 changes: 96 additions & 0 deletions LinuxLogParsers/LinuxLogParsersUnitTest/LinuxLogParsersUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using CloudInitMPTAddin;
using DmesgIsoMPTAddin;
using Microsoft.Performance.SDK.Extensibility;
using Microsoft.Performance.Toolkit.Engine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using UnitTestCommon;
using WaLinuxAgentMPTAddin;

namespace LinuxLogParsersUnitTest
{
[TestClass]
public class LinuxLogParsersUnitTest
{
[TestMethod]
public void Dmesg()
{
// Input data
string[] dmesgData = { @"..\..\..\..\..\TestData\LinuxLogs\Dmesg\dmesg.iso.log" };
var dmesgDataPath = new FileInfo(dmesgData[0]);
Assert.IsTrue(dmesgDataPath.Exists);

var runtime = Engine.Create();
runtime.AddFile(dmesgDataPath.FullName);

var cooker = new DmesgIsoDataCooker().Path;
runtime.EnableCooker(cooker);

var runtimeExecutionResults = runtime.Process();

var eventData = runtimeExecutionResults.QueryOutput<DmesgIsoLogParsedResult>(
new DataOutputPath(
cooker,
nameof(DmesgIsoDataCooker.ParsedResult)));

Assert.IsTrue(eventData.LogEntries.Count >= 0);
}

[TestMethod]
public void CloudInit()
{
// Input data
string[] cloudInitData = { @"..\..\..\..\..\TestData\LinuxLogs\Cloud-Init\cloud-init.log" };
var cloutInitDataPath = new FileInfo(cloudInitData[0]);
Assert.IsTrue(cloutInitDataPath.Exists);

var runtime = Engine.Create();
runtime.AddFile(cloutInitDataPath.FullName);

var cooker = new CloudInitDataCooker().Path;
runtime.EnableCooker(cooker);

var runtimeExecutionResults = runtime.Process();

var eventData = runtimeExecutionResults.QueryOutput<CloudInitLogParsedResult>(
new DataOutputPath(
cooker,
nameof(CloudInitDataCooker.ParsedResult)));

Assert.IsTrue(eventData.LogEntries.Count >= 0);
}

[TestMethod]
public void WaLinuxAgent()
{
// Input data
string[] waLinuxAgentData = { @"..\..\..\..\..\TestData\LinuxLogs\WaLinuxAgent\waagent.log" };
var waLinuxAgentDataPath = new FileInfo(waLinuxAgentData[0]);
Assert.IsTrue(waLinuxAgentDataPath.Exists);

var runtime = Engine.Create();
runtime.AddFile(waLinuxAgentDataPath.FullName);

var cooker = new WaLinuxAgentDataCooker().Path;
runtime.EnableCooker(cooker);

var runtimeExecutionResults = runtime.Process();

var eventData = runtimeExecutionResults.QueryOutput<WaLinuxAgentLogParsedResult>(
new DataOutputPath(
cooker,
nameof(WaLinuxAgentDataCooker.ParsedResult)));

Assert.IsTrue(eventData.LogEntries.Count >= 0);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.108.2" />
<PackageReference Include="Moq" Version="4.15.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\UnitTestCommon\UnitTestCommon.csproj" />
<ProjectReference Include="..\LinuxPlugins-MicrosoftPerformanceToolkSDK\Cloud-init\Cloud-Init.csproj" />
<ProjectReference Include="..\LinuxPlugins-MicrosoftPerformanceToolkSDK\DmesgIsoLog\Dmesg.csproj" />
<ProjectReference Include="..\LinuxPlugins-MicrosoftPerformanceToolkSDK\WaLinuxAgent\WaLinuxAgent.csproj" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions LttngDataExtensions/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"profiles": {
"LTTngDataExtensions": {
"commandName": "Executable",
"executablePath": "C:\\Tools\\WPT\\latest\\wpa.exe",
"commandLineArgs": "-addsearchdir C:\\src\\Microsoft-Performance-Tools-Linux\\LttngDataExtensions\\bin\\Debug\\netstandard2.1"
}
}
}
8 changes: 8 additions & 0 deletions LttngDriver/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"LttngDriver": {
"commandName": "Project",
"commandLineArgs": "-e C:\\src\\Microsoft-Performance-Tools-Linux\\LttngDataExtensions\\bin\\Debug\\netstandard2.1 C:\\src\\Microsoft-Performance-Tools-Linux\\TestData\\LTTng\\lttng-kernel-trace.ctf"
}
}
}
Loading