Currently, it is unclear if a test that is skipped is either:
- Unsupported because it will never run (macosx tests should not run on
Windows).
- Skipped because it's supposed to work but does not yet.
`@expectedFailure` is not always an option because a test might be
timing out and waiting 600s for it to fail is not acceptable.
This patch introduces 2 new decorators to differentiate those tests:
- `@requireX` meaning the tests require X to run (e.g `@requireDarwin`).
- `@requireNotX` meaning the tests requires anything but `X` to run (e.g
`@requireNotDarwin`).
In the tests results summary, this introduces a new category: `skipped`
tests:
- `@requireX` -> `UNSUPPORTED`
- `@skipIfX` -> `SKIPPED`
Here is how they can and cannot be stacked:
This will never run:
```py3
@requireDarwin
@requireWindows
def test():
...
```
This will not run on Linux, because `@requireWindows` is not satisfied.
```py3
@requireNotDarwin
@requireWindows
def test():
...
```
For "require Darwin or Windows", you need:
```py3
@requirePlatform(["darwin", "windows"])
def test():
...
```
For "require Darwin on ARM64 or Windows on ARM64", you need:
```py3
@requireARM64
@requirePlatform(["darwin", "windows"])
def test():
...
```
This patch also converts the tests in
`lldb/tests/API/{macosx,linux,windows}` to use these decorators. Patches
to convert the rest of the tests will follow.
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
import lldb
|
|
import subprocess
|
|
import os
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class TestMSVCRTCException(TestBase):
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
|
|
@requireWindows
|
|
@skipUnlessMSVC
|
|
def test_msvc_runtime_checks(self):
|
|
"""Test that lldb prints MSVC's runtime checks exceptions as stop reasons."""
|
|
|
|
src = os.path.join(self.getSourceDir(), "main.c")
|
|
exe = os.path.join(self.getBuildDir(), "a.exe")
|
|
|
|
result = subprocess.run(
|
|
["cl.exe", "/nologo", "/Od", "/Zi", "/MDd", "/RTC1", "/Fe" + exe, src],
|
|
cwd=self.getBuildDir(),
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
self.assertEqual(
|
|
result.returncode,
|
|
0,
|
|
"Compilation failed:\n" + result.stdout + result.stderr,
|
|
)
|
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
self.assertTrue(target.IsValid(), "Could not create target")
|
|
|
|
process = target.LaunchSimple(None, None, self.get_process_working_directory())
|
|
self.assertTrue(process.IsValid(), "Could not launch process")
|
|
|
|
self.assertEqual(process.GetState(), lldb.eStateStopped)
|
|
|
|
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonException)
|
|
self.assertIsNotNone(thread, "No thread stopped with exception stop reason")
|
|
|
|
stop_description = thread.GetStopDescription(256)
|
|
self.assertIn(
|
|
"Run-time check failure",
|
|
stop_description,
|
|
"Stop reason does not mention run-time check failure",
|
|
)
|
|
self.assertIn(
|
|
"variable 'x' is being used without being initialized",
|
|
stop_description,
|
|
"Stop reason does not mention uninitialized variable 'x'",
|
|
)
|