## Running tests
-Before running tests the debugger should be built and installed inside `./bin` directory, `dotnet` CLI shoud be present in `PATH`.
+By default test runner looks for debugger binary in `./bin` directory and expects `dotnet` CLI to be present in `PATH`.
-From project root directory test are run through dotnet CLI:
+Test are run through dotnet CLI from the project root directory:
```
cd tests
dotnet test
```
-It is possible to override path to the debugger binary through `PIPE` environgment variable:
+It is possible to override path to the debugger binary through `PIPE` environment variable:
```
cd tests
PIPE=<path-to-debugger> dotnet test --logger "trx;LogFileName=$PWD/Results.trx"
Test results can be exported to a file with `--logger` command line option.
-By default test binaries are descovered recursively under project `tests` directory. When tests should be executed on another machine, environment variable `TESTDIR` can override the location of test binaries. In that case recursive search is not performed and all test binaries should be located directly under `TESTDIR`. So for `TESTDIR=/tmp` the test binary files layout shoud be:
+By default test binaries are discovered recursively under project `tests` directory. When tests should be executed on another machine, environment variable `TESTDIR` can override the location of test binaries. In that case recursive search is not performed and all test binaries should be located directly under `TESTDIR`. So for `TESTDIR=/tmp` the test binary files layout shoud be:
```
/tmp/Example1Test.dll
/tmp/Example1Test.pdb
The following example instructs the debugger to run test binary and verifies that the debugger stops at line with `@START@` tag with stop reason `entry-point-hit`:
```
-using System;
/*
Send("1-file-exec-and-symbols dotnet");
Send("2-exec-arguments " + TestBin);
Assert.Equal(r.FindString("reason"), "entry-point-hit");
Assert.Equal(r.Find("frame").FindInt("line"), Lines["START"]);
*/
+using System;
+
namespace ExampleTest
{
class Program
/*
-using System;
-
Send("1-file-exec-and-symbols dotnet");
Send("2-exec-arguments " + TestBin);
Send("3-exec-run");
# 3. Install netcoredbg rpm: sdb push netcoredbg-*.rpm /tmp && sdb shell rpm -i --force /tmp/netcoredbg-*.rpm
# 4. Create dotnet symlink: sdb shell ln -s /usr/share/dotnet/corerun /usr/bin/dotnet
-SDB=${SDB:=sdb}
+SDB=${SDB:-sdb}
SCRIPTDIR=$(dirname $(readlink -f $0))
find $SCRIPTDIR -name '*Test.runtimeconfig.json' | while read fname; do
base=$(echo $fname | rev | cut -f 3- -d '.' | rev)
$SDB push ${base}.dll ${base}.pdb /tmp
- #$SDB shell chsmack -a '*' /tmp/$(basename ${base}.dll) /tmp/$(basename ${base}.pdb)
+ # After push some targets set SMACK access label to System, but the debugger can not access System files.
+ # Also, prevent sdb from consuming input.
+ cat /dev/null | $SDB shell "chsmack -a '*' /tmp/$(basename ${base}).dll /tmp/$(basename ${base}).pdb"
done
# Run tests
DEBUGGER=/home/owner/share/tmp/sdk_tools/netcoredbg/netcoredbg
+# sdb always allocates a terminal for a shell command, but we do not want MI commands to be echoed.
+# So we need to delay stdin by 1 second and hope that `stty raw -echo` turns the echo off during the delay.
TESTDIR=/tmp PIPE="(sleep 1; cat) | $SDB shell stty raw -echo\\;$DEBUGGER --interpreter=mi" dotnet test $SCRIPTDIR --logger "trx;LogFileName=$SCRIPTDIR/Results.trx"
cc.Text,
ScriptOptions.Default.WithReferences(typeof(object).Assembly)
.WithReferences(typeof(Xunit.Assert).Assembly)
- .WithImports("System")
- .WithImports("Xunit"),
+ .WithReferences(typeof(MICore.MIResults).Assembly)
+ .WithImports(new string[]{"System", "Xunit", "MICore"}),
globalsType: typeof(TestCaseGlobals)
);
script.Compile();