Skip to content

Commit

Permalink
Fix runInTerminal failures on Windows
Browse files Browse the repository at this point in the history
stella.stemenova mentioned in https://reviews.llvm.org/D93951 failures on Windows for this test.

I'm fixing the macro definitions and disabling the tests for python
versions lower than 3.7. I'll figure out that actual issue with
python3.6 after the buildbots are fine again.

(cherry picked from commit ab5591e)
  • Loading branch information
walter-erquinigo authored and mstorsjo committed Feb 8, 2021
1 parent 251f329 commit d7d818c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
Expand Up @@ -33,20 +33,30 @@ def readErrorMessage(self, fifo_file):
with open(fifo_file, "r") as file:
return file.readline()

def isTestSupported(self):
# For some strange reason, this test fails on python3.6
if not (sys.version_info.major == 3 and sys.version_info.minor >= 7):
return False
try:
# We skip this test for debug builds because it takes too long parsing lldb's own
# debug info. Release builds are fine.
# Checking the size of the lldb-vscode binary seems to be a decent proxy for a quick
# detection. It should be far less than 1 MB in Release builds.
if os.path.getsize(os.environ["LLDBVSCODE_EXEC"]) < 1000000:
return True
except:
return False

@skipIfWindows
@skipIfRemote
@skipIf(archs=no_match(['x86_64']))
def test_runInTerminal(self):
if not self.isTestSupported():
return
'''
Tests the "runInTerminal" reverse request. It makes sure that the IDE can
launch the inferior with the correct environment variables and arguments.
'''
if "debug" in str(os.environ["LLDBVSCODE_EXEC"]).lower():
# We skip this test for debug builds because it takes too long parsing lldb's own
# debug info. Release builds are fine.
# Checking this environment variable seems to be a decent proxy for a quick
# detection
return
program = self.getBuildArtifact("a.out")
source = 'main.c'
self.build_and_launch(
Expand Down Expand Up @@ -77,6 +87,8 @@ def test_runInTerminal(self):
@skipIfRemote
@skipIf(archs=no_match(['x86_64']))
def test_runInTerminalInvalidTarget(self):
if not self.isTestSupported():
return
self.build_and_create_debug_adaptor()
response = self.launch(
"INVALIDPROGRAM", stopOnEntry=True, runInTerminal=True, args=["foobar"], env=["FOO=bar"], expectFailure=True)
Expand All @@ -88,6 +100,8 @@ def test_runInTerminalInvalidTarget(self):
@skipIfRemote
@skipIf(archs=no_match(['x86_64']))
def test_missingArgInRunInTerminalLauncher(self):
if not self.isTestSupported():
return
proc = subprocess.run([self.lldbVSCodeExec, "--launch-target", "INVALIDPROGRAM"],
capture_output=True, universal_newlines=True)
self.assertTrue(proc.returncode != 0)
Expand All @@ -97,6 +111,8 @@ def test_missingArgInRunInTerminalLauncher(self):
@skipIfRemote
@skipIf(archs=no_match(['x86_64']))
def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)

Expand All @@ -115,6 +131,8 @@ def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
@skipIfRemote
@skipIf(archs=no_match(['x86_64']))
def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)

Expand All @@ -132,6 +150,8 @@ def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
@skipIfRemote
@skipIf(archs=no_match(['x86_64']))
def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)

Expand All @@ -150,6 +170,8 @@ def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
@skipIfRemote
@skipIf(archs=no_match(['x86_64']))
def test_NonAttachedRunInTerminalLauncher(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)

Expand Down
10 changes: 5 additions & 5 deletions lldb/tools/lldb-vscode/FifoFiles.cpp
Expand Up @@ -6,7 +6,9 @@
//
//===----------------------------------------------------------------------===//

#if !defined(WIN32)
#include "FifoFiles.h"

#if LLVM_ON_UNIX
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Expand All @@ -21,22 +23,20 @@

#include "lldb/lldb-defines.h"

#include "FifoFiles.h"

using namespace llvm;

namespace lldb_vscode {

FifoFile::FifoFile(StringRef path) : m_path(path) {}

FifoFile::~FifoFile() {
#if !defined(WIN32)
#if LLVM_ON_UNIX
unlink(m_path.c_str());
#endif
};

Expected<std::shared_ptr<FifoFile>> CreateFifoFile(StringRef path) {
#if defined(WIN32)
#if !LLVM_ON_UNIX
return createStringError(inconvertibleErrorCode(), "Unimplemented");
#else
if (int err = mkfifo(path.data(), 0600))
Expand Down
1 change: 1 addition & 0 deletions lldb/tools/lldb-vscode/FifoFiles.h
Expand Up @@ -9,6 +9,7 @@
#ifndef LLDB_TOOLS_LLDB_VSCODE_FIFOFILES_H
#define LLDB_TOOLS_LLDB_VSCODE_FIFOFILES_H

#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
#include "llvm/Support/Error.h"

#include "JSONUtils.h"
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-vscode/lldb-vscode.cpp
Expand Up @@ -3002,8 +3002,8 @@ static void printHelp(LLDBVSCodeOptTable &table, llvm::StringRef tool_name) {
// emitted to the debug adaptor.
void LaunchRunInTerminalTarget(llvm::opt::Arg &target_arg,
llvm::StringRef comm_file, char *argv[]) {
#if defined(WIN_32)
llvm::errs() << "runInTerminal is not supported on Windows\n";
#if !LLVM_ON_UNIX
llvm::errs() << "runInTerminal is only supported on POSIX systems\n";
exit(EXIT_FAILURE);
#else
RunInTerminalLauncherCommChannel comm_channel(comm_file);
Expand Down

0 comments on commit d7d818c

Please sign in to comment.