Hypaxba_
Hypaxba_
CC#
Created by Hypaxba_ on 1/26/2023 in #help
❔ Testhost process crash when throwing an Exception and reading the Console.
Hello, I'm encountering a problem using Xunit. I'm using Xunit to test untrusted student code. We implemented a Timeout mechanic that throws an exception if the student code runs for too long. This works well on tests that just checks for return values. However, when I'm testing for Console Output in this way, I encounter a System.IO.EndOfStreamException when this Timeout Exception is thrown. The code that test for this looks like this:
StringWriter swref = new StringWriter();
Console.SetOut(swref);
//Student code that timeout
string res = swref.ToString()
// Assert call
StringWriter swref = new StringWriter();
Console.SetOut(swref);
//Student code that timeout
string res = swref.ToString()
// Assert call
I'm pretty sure it comes from this comes from the Timeout exception, as the logs I get with --diag shows that this occurs before the TestHost Process crashes. I tried catching the exception but the output is still the same. The thing that I don't understand as well is that it runs fine when running the tests locally, but we use docker containers that run with 1GB ram and 1 cpu core and no access to the internet to run student code, and it is where I encounter this issue. Thanks for your help The logs I get with --diag is as follows (cut down to the relevant part):
2 replies
CC#
Created by Hypaxba_ on 11/7/2022 in #help
XUnit crashing when a stack overflow occurs.
Hello, I am using XUnit to test untrusted student code. Thing is, whenever a stack overflow occurs (very common) the testsuite crashes completely and the tests after are not run anymore. We need to run all the tests as we have to log them to display it to the students. One way I found was to check the stack within the function but we would really want to avoid touching the student code. Does anybody got a way to prevent stackoverflow from occurring and if possible throwing an exception? Thanks in advance 😄
3 replies