Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SourceKit tests if building SourceKit #8485

Merged
merged 13 commits into from
Apr 24, 2017

Conversation

norio-nomura
Copy link
Contributor

Resolves SR-1676.

@norio-nomura norio-nomura changed the title Enable SourceKit tests Enable SourceKit tests if building SourceKit Apr 2, 2017
@alblue
Copy link
Contributor

alblue commented Apr 2, 2017

@swift-ci please smoke test

@norio-nomura
Copy link
Contributor Author

It seems that marker affect to location in response on macOS.

@alblue
Copy link
Contributor

alblue commented Apr 2, 2017

@swift-ci please smoke test

@norio-nomura
Copy link
Contributor Author

Sorry, it also needs to fix expecting response. 🙇

@alblue
Copy link
Contributor

alblue commented Apr 2, 2017

@swift-ci please smoke test

@slavapestov
Copy link
Contributor

Why are so many of the tests XFAILd on Linux though?

If they actually require objc_interop, you should add 'REQUIRES: objc_interop' instead.

@norio-nomura
Copy link
Contributor Author

norio-nomura commented Apr 3, 2017

@slavapestov I don't yet investigate each failing tests, but we have failing tests in SourceKitten on Swift 3.1 for Linux too. jpsim/SourceKitten#354

@norio-nomura
Copy link
Contributor Author

Those tests in SourceKitten have passed on Swift 3.0.2 for Linux.

@norio-nomura
Copy link
Contributor Author

@slavapestov Hi, I classified test results and split them into commits:

  • mark tests failing with assertion !GlibcModuleMapPath.empty()
  • mark tests failing with SOURCEKITD FATAL ERROR: sourcekitd object did not resolve to a known type
  • mark tests requiring objc_interop
  • update test with outdated response

@norio-nomura
Copy link
Contributor Author

Write two crash log patterns here:

  • Assertion `!GlibcModuleMapPath.empty()' failed:
********************
FAIL: Swift(linux-x86_64) :: SourceKit/DocSupport/doc_swift_module.swift (421 of 3375)
******************** TEST 'Swift(linux-x86_64) :: SourceKit/DocSupport/doc_swift_module.swift' FAILED ********************
Script:
--
rm -rf /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.mod
mkdir -p /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.mod
'/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/swift' -frontend -module-cache-path '/tmp/swift-testsuite-clang-module-cacheAq2cta' -disable-objc-attr-requires-foundation-module -swift-version 3 -emit-module -o /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.mod/cake.swiftmodule /Users/norio/github/swift-dev/swift/test/SourceKit/DocSupport/Inputs/cake.swift -parse-as-library
/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test -req=doc-info -module cake -- -I /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.mod > /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.response
diff -u /Users/norio/github/swift-dev/swift/test/SourceKit/DocSupport/doc_swift_module.swift.response /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.response
--
Exit Code: 134

Command Output (stderr):
--
{
  key.request: source.request.docinfo,
  key.compilerargs: [
    "-I",
    "/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.mod"
  ],
  key.modulename: "cake"
}
sourcekitd-test: /Users/norio/github/swift-dev/swift/lib/ClangImporter/ClangImporter.cpp:528: void getNormalInvocationArguments(std::vector<std::string> &, swift::ASTContext &, const swift::ClangImporterOptions &): Assertion `!GlibcModuleMapPath.empty()' failed.
#0 0x00007f0c6f415c88 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6f7c88)
#1 0x00007f0c6f4163c6 SignalHandler(int) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6f83c6)
#2 0x00007f0c73190390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#3 0x00007f0c6d64f428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
#4 0x00007f0c6d65102a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)
#5 0x00007f0c6d647bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7)
#6 0x00007f0c6d647c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#7 0x00007f0c6f8939ff swift::ClangImporter::create(swift::ASTContext&, swift::ClangImporterOptions const&, swift::DependencyTracker*) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0xb759ff)
#8 0x00007f0c6f53d71e swift::CompilerInstance::setup(swift::CompilerInvocation const&) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x81f71e)
#9 0x00007f0c6f48a1aa SourceKit::SwiftLangSupport::getDocInfo(llvm::MemoryBuffer*, llvm::StringRef, llvm::ArrayRef<char const*>, SourceKit::DocInfoConsumer&) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x76c1aa)
#10 0x00007f0c6f3d3f97 handleRequestImpl(void*, std::function<void (void*)>) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6b5f97)
#11 0x00007f0c6f3d292a sourcekitd::handleRequest(void*, std::function<void (void*)>) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6b492a)
#12 0x00007f0c6f3d239b sourcekitd_send_request_sync (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6b439b)
#13 0x0000000000406e84 handleTestInvocation(llvm::ArrayRef<char const*>, sourcekitd_test::TestOptions&) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test+0x406e84)
#14 0x0000000000404a8f __main_block_invoke (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test+0x404a8f)
#15 0x00007f0c7354f8b7 _dispatch_call_block_and_release (/Users/norio/github/swift-dev/build/buildbot_incremental/libdispatch-linux-x86_64/src/.libs/libdispatch.so+0x398b7)
#16 0x00007f0c7355df2d _dispatch_root_queue_drain (/Users/norio/github/swift-dev/build/buildbot_incremental/libdispatch-linux-x86_64/src/.libs/libdispatch.so+0x47f2d)
#17 0x00007f0c7355da1d _dispatch_worker_thread4 (/Users/norio/github/swift-dev/build/buildbot_incremental/libdispatch-linux-x86_64/src/.libs/libdispatch.so+0x47a1d)
#18 0x00007f0c73580e0f worker_main /Users/norio/github/swift-dev/swift-corelibs-libdispatch/libpwq/src/posix/manager.c:508:9
#19 0x00007f0c731866ba start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76ba)
#20 0x00007f0c6d72082d clone (/lib/x86_64-linux-gnu/libc.so.6+0x10682d)
/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.script: line 5: 31858 Aborted                 /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test -req=doc-info -module cake -- -I /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.mod > /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocSupport/Output/doc_swift_module.swift.tmp.response

--
********************
FAIL: Swift(linux-x86_64) :: SourceKit/DocumentStructure/access_parse.swift (423 of 3375)
******************** TEST 'Swift(linux-x86_64) :: SourceKit/DocumentStructure/access_parse.swift' FAILED ********************
Script:
--
'/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/swift' -frontend -module-cache-path '/tmp/swift-testsuite-clang-module-cacheAq2cta' -disable-objc-attr-requires-foundation-module -swift-version 3 -typecheck /Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift
/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test -req=structure /Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift -- -module-name Access /Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift > /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocumentStructure/Output/access_parse.swift.tmp.response
diff -u /Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/access_parse.swift.response /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocumentStructure/Output/access_parse.swift.tmp.response
--
Exit Code: 134

Command Output (stderr):
--
{
  key.request: source.request.editor.open,
  key.name: "/Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift",
  key.compilerargs: [
    "-module-name",
    "Access",
    "/Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift"
  ],
  key.sourcefile: "/Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift",
  key.enablesyntaxmap: 0,
  key.enablesubstructure: 1,
  key.syntactic_only: 1
}
SOURCEKITD FATAL ERROR: sourcekitd object did not resolve to a known type
#0 0x00007f3cb7531c88 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6f7c88)
#1 0x00007f3cb75323c6 SignalHandler(int) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6f83c6)
#2 0x00007f3cbb2ac390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#3 0x00007f3cb576b428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
#4 0x00007f3cb576d02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)
#5 0x00007f3cb74ff691 (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6c5691)
#6 0x00007f3cb750c7a8 llvm::report_fatal_error(llvm::Twine const&, bool) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6d27a8)
#7 0x00007f3cb750c684 (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6d2684)
#8 0x00007f3cb750382e (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6c982e)
#9 0x00007f3cb74fd729 (anonymous namespace)::VariantVisitor<(anonymous namespace)::VariantPrinter, void>::visit(sourcekitd_variant_t) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6c3729)
#10 0x00007f3cb74fe506 (anonymous namespace)::VariantVisitor<(anonymous namespace)::VariantPrinter, void>::visit(sourcekitd_variant_t) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6c4506)
#11 0x00007f3cb74fb56f sourcekitd::printResponse(void*, llvm::raw_ostream&) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6c156f)
#12 0x00007f3cb74fbc66 sourcekitd_response_description_dump_filedesc (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/lib/libsourcekitdInProc.so+0x6c1c66)
#13 0x0000000000407a3a handleResponse(void*, sourcekitd_test::TestOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, sourcekitd_test::TestOptions*) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test+0x407a3a)
#14 0x0000000000406ebf handleTestInvocation(llvm::ArrayRef<char const*>, sourcekitd_test::TestOptions&) (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test+0x406ebf)
#15 0x0000000000404a8f __main_block_invoke (/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test+0x404a8f)
#16 0x00007f3cbb66b8b7 _dispatch_call_block_and_release (/Users/norio/github/swift-dev/build/buildbot_incremental/libdispatch-linux-x86_64/src/.libs/libdispatch.so+0x398b7)
#17 0x00007f3cbb679f2d _dispatch_root_queue_drain (/Users/norio/github/swift-dev/build/buildbot_incremental/libdispatch-linux-x86_64/src/.libs/libdispatch.so+0x47f2d)
#18 0x00007f3cbb679a1d _dispatch_worker_thread4 (/Users/norio/github/swift-dev/build/buildbot_incremental/libdispatch-linux-x86_64/src/.libs/libdispatch.so+0x47a1d)
#19 0x00007f3cbb69ce0f worker_main /Users/norio/github/swift-dev/swift-corelibs-libdispatch/libpwq/src/posix/manager.c:508:9
#20 0x00007f3cbb2a26ba start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76ba)
#21 0x00007f3cb583c82d clone (/lib/x86_64-linux-gnu/libc.so.6+0x10682d)
/Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocumentStructure/Output/access_parse.swift.script: line 3: 31950 Aborted                 /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test -req=structure /Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift -- -module-name Access /Users/norio/github/swift-dev/swift/test/SourceKit/DocumentStructure/Inputs/access.swift > /Users/norio/github/swift-dev/build/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/DocumentStructure/Output/access_parse.swift.tmp.response

--

@norio-nomura
Copy link
Contributor Author

norio-nomura commented Apr 4, 2017

filed:

  • SR-4490 [SourceKit] tests fail with Assertion `!GlibcModuleMapPath.empty()' failed on Linux
  • SR-4491 [SourceKit] tests fail with "SOURCEKITD FATAL ERROR: sourcekitd object did not resolve to a known type" on Linux
  • SR-4492 [SourceKit] SourceKit/CodeComplete/complete_sort_order.swift fails on Linux

@alblue
Copy link
Contributor

alblue commented Apr 5, 2017

@swift-ci please smoke test

@felix91gr
Copy link
Contributor

felix91gr commented Apr 6, 2017

I want to help fixing those.
Does any of them qualify as a starter bug? (to take it in JIRA)

Also, if anyone wants to be my mentor, please do be :)

Edit

🤔 nevermind, they are not tagged as such. I think I'll go for some starters beforehand, then: https://t.co/qDTn47DBVY

@norio-nomura
Copy link
Contributor Author

norio-nomura commented Apr 6, 2017

I pushed commits that fix "Assertion `!GlibcModuleMapPath.empty()' failed".

  • Two tests pass with 278c9de.
  • Four tests are fixed assertion fail, but still fail with SOURCEKITD FATAL ERROR: sourcekitd object did not resolve to a known type with 8ca7c1d

@aschwaighofer
Copy link
Contributor

Looks like this merge is to indicate for the failures in:

https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04/2230/

I started a revert PR.

@norio-nomura
Copy link
Contributor Author

Does that failure occur with only ubuntu 14.04? 🤔

@aschwaighofer
Copy link
Contributor

It would seem so I have not seen a failure on the 16_04 bot: https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/

@felix91gr
Copy link
Contributor

This appeared on the stderr:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
pure virtual method called
terminate called recursively

Could it be a call bug that only occurs in 14.04?

@norio-nomura
Copy link
Contributor Author

I can not reproduce the test failure on local ubuntu 14.04. 😕

@alblue
Copy link
Contributor

alblue commented Apr 25, 2017

The test that failed was

******************** TEST 'Swift(linux-x86_64) :: SourceKit/ExtractComment/extract_comments.swift' FAILED ********************

Not sure if helps.

@aschwaighofer
Copy link
Contributor

It seems that the revert did fix the bot:

We have had several builds since:

https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04/2242

that were blue.

@alblue
Copy link
Contributor

alblue commented Apr 25, 2017

Right so now the issue is to find out why the build failed on 14.04 so that we can fix it and make it run again, or to disable the test from running (or from running on 14.04 specifically). The point is these tests have never run on Linux by default so it's not impossible that we're actually finding a real issue with the code on 14.04.

@norio-nomura
Copy link
Contributor Author

Looks non-deterministic

2230: SourceKit/ExtractComment/extract_comments.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

2231: SourceKit/CodeFormat/indent-switch.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

2232: PASS

2233: SourceKit/CodeFormat/indent-switch.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

2234: SourceKit/CodeFormat/indent-switch.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

2235: SourceKit/CodeFormat/indent-with-tab.swift' FAILED

pure virtual method called
terminate called without an active exception

2236: SourceKit/CodeFormat/indent-closure.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

2237: PASS
2238: PASS

2239: SourceKit/CodeFormat/indent-computed-property.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

2240: SourceKit/CodeFormat/indent-bracestmt2.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

2241: SourceKit/CodeFormat/indent-basic.swift' FAILED

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
pure virtual method called
terminate called recursively

@aschwaighofer
Copy link
Contributor

Yes, it looks like we are running out of memory. I cannot judge whether this is an existing error (that we happen to observe because of system characteristics of that bot) or due to some of the source code changes in this commit. Maybe the machine does not have enough memory? I am not familiar with SourceKit.

@akyrtzi Are you fine with just disabling the failing tests on linux (only 14_04) and taking this change?

I would say yes since these tests did not run before on linux.

@norio-nomura
Copy link
Contributor Author

I have run tests on low memory 14.04 vm, got all tests of SourceKit have passed and another tests crashed.
So, I believe that low memory condition is not related to the failure.

@akyrtzi
Copy link
Contributor

akyrtzi commented Apr 25, 2017

I'm fine with disabling for 14_04.

@alblue
Copy link
Contributor

alblue commented Apr 25, 2017

Is there a best practice way of disabling these tests for the 14.04 build only?

@aschwaighofer
Copy link
Contributor

You could add an available_feature that references the OS version.

See test/lit.config.

We don't have a available_feature for identifying the linux version as far as i can tell by quickly glancing over this file.

@norio-nomura
Copy link
Contributor Author

norio-nomura commented Apr 26, 2017

How about this?:

diff --git a/test/SourceKit/lit.local.cfg b/test/SourceKit/lit.local.cfg
index e9e550f518..42dad58ea9 100644
--- a/test/SourceKit/lit.local.cfg
+++ b/test/SourceKit/lit.local.cfg
@@ -1,6 +1,9 @@
 if 'sourcekit' not in config.available_features:
     config.unsupported = True
 
+elif 'OS=linux-gnu' in config.available_features and 'Linux=Ubuntu-14.04' in config.available_features:
+    config.unsupported = True
+
 else:
     config.sourcekitd_test = config.inferSwiftBinary('sourcekitd-test')
     config.complete_test = config.inferSwiftBinary('complete-test')
diff --git a/test/lit.cfg b/test/lit.cfg
index af64c5d665..bf7c691993 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -1085,4 +1085,24 @@ if config.lldb_build_root != "":
     python_lib_dir = get_python_lib(True, False, config.lldb_build_root)
     config.substitutions.append(('%lldb-python-path', python_lib_dir))
 
+
+# Run lsb_release on the target to be tested and return the results.
+def linux_get_lsb_release(commandPrefix=[]):
+    distributor = lit.util.executeCommand(
+        commandPrefix + ['/usr/bin/lsb_release', '-is'])[0].rstrip()
+    release = lit.util.executeCommand(
+        commandPrefix + ['/usr/bin/lsb_release', '-rs'])[0].rstrip()
+    codename = lit.util.executeCommand(
+        commandPrefix + ['/usr/bin/lsb_release', '-cs'])[0].rstrip()
+    return (distributor, release, codename)
+
+if platform.system() == 'Linux':
+    (distributor, release, codename) = linux_get_lsb_release()
+    if (distributor == '' or release == '' or codename == ''):
+        lit_config.fatal('Could not get or decode lsb_release output.')
+    config.available_features.add("Linux=" + distributor + '-' + release)
+    lit_config.note(
+        'Running tests on %s version %s (%s)' %
+        (distributor, release, codename))
+
 lit_config.note("Available features: " + ", ".join(config.available_features))

Updated: move printing "Available features: " to tail

@alblue
Copy link
Contributor

alblue commented Apr 26, 2017

Instead of fatally aborting the lit_config, I would simply not set the Linux=Ubuntu-14.04 if you can't find the values. You might also want to use LinuxDistribution or LinuxLSBRelease instead, in case a future version uses Linux for other purposes. Otherwise I think this approach will work well.

@norio-nomura
Copy link
Contributor Author

Thanks for feedback.
Opened #9025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants