C# Example

An example C# project is included that demonstrates how to open a log file and extract some information from it. The project is installed in \Log File Examples\C#.

The program is a simple command-line application that takes the filename of a log file as an argument and prints some information about the test runs contained inside it.

The example program uses the built-in ZipFile class from the System.IO.Compression.FileSystem.dll assembly that is part of the .NET Framework:

using (var archive = ZipFile.OpenRead(args[0]))
{
    var infoEntry = archive.GetEntry("Info.xml");
    // ...
}

It then uses LINQ to XML to parse the XML from the file inside the zip file. This snippet of code demonstrates parsing the contents of Info.xml that was opened above and then extracting the number of test runs that are in the log file:

var infoXml = XDocument.Load(infoEntry.Open());
int testRunCount = Int32.Parse(infoXml.Descendants("TestRunCount").Single().Value);

The test run XML is parsed in a similar way.

Sample Output

This is some sample output from the program with a log file from the XJDemo board that contains three test runs:

Test Run 1: Passed

Tests passed: 22
NEW_SERIAL_NUMBER, CheckChain, CONNTEST, IC5.Test, ProgrammedFlashCheck, IC3.TestDestructive, IC7.Test, EEPROM_PIO_Test, Y1.TestOscillator, Y1FrequencyTest, IC6.IIC_CheckPresent, ADC_Test,
SW1.Test, D1.Test, D2.Test, D3.Test, D4.Test, EraseIC3, ProgramIC3, VerifyIC3 (Post programming), RunStaplFile, WriteSerialNumber

Tests failed: 0

Tests skipped: 2


Test Run 2: Failed

Tests passed: 0

Tests failed: 1
NEW_SERIAL_NUMBER (388ms)

Tests skipped: 0


Test Run 3: Stopped

Tests passed: 7
NEW_SERIAL_NUMBER, CheckChain, CONNTEST, IC5.Test, ProgrammedFlashCheck, IC3.TestNonDestructive, IC7.Test

Tests failed: 0

Tests skipped: 1

Testing was interrupted during the test EEPROM_PIO_Test