Skip to content

Test sanitizers with build plans. #2720

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

Merged
merged 1 commit into from
May 7, 2020

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Apr 30, 2020

The current tests for sanitizers in SwiftPM are essentially "live": they
build a package that will do something to trigger a sanitizer, and then
run it and confirm it fails. This is a pretty fragile way to test, and
it exposes SwiftPM to a number of possible test failures that don't
have anything to do with the core mission (exposing the sanitizer).

This patch replaces those tests with build plan tests that validate that
SwiftPM correctly invokes swiftc and clang. These tests are acceptable
because for now SwiftPM doesn't have any smarts with the sanitizers: it
just passes them all through to swiftc and clang.

This patch also deletes the current live tests, as they are no longer
necessary.

@Lukasa
Copy link
Contributor Author

Lukasa commented Apr 30, 2020

@swift-ci please smoke test

@Lukasa Lukasa force-pushed the cb-move-scudo-testing branch from b7813eb to 0649a0d Compare April 30, 2020 09:24
@Lukasa
Copy link
Contributor Author

Lukasa commented Apr 30, 2020

@swift-ci please smoke test

@Lukasa Lukasa force-pushed the cb-move-scudo-testing branch from 0649a0d to 3950d7b Compare April 30, 2020 09:36
@Lukasa
Copy link
Contributor Author

Lukasa commented Apr 30, 2020

@swift-ci please smoke test

@Lukasa Lukasa force-pushed the cb-move-scudo-testing branch from 3950d7b to 3d99db2 Compare April 30, 2020 09:47
@Lukasa
Copy link
Contributor Author

Lukasa commented Apr 30, 2020

@swift-ci please smoke test

@Lukasa Lukasa force-pushed the cb-move-scudo-testing branch from 3d99db2 to 3a27afd Compare April 30, 2020 09:55
@Lukasa
Copy link
Contributor Author

Lukasa commented Apr 30, 2020

@swift-ci please smoke test

@Lukasa
Copy link
Contributor Author

Lukasa commented Apr 30, 2020

@swift-ci please test

@abertelrud
Copy link
Contributor

abertelrud commented May 1, 2020

Thanks for reworking these tests, Cory! In general, this (checking that SwiftPM is passing along the right sanitizer flag to the compiler) is definitely the right approach.

One thing I'm slightly worried about is that the test seems to capture a lot of the current flags being passed to the compiler and linker, and I'm wondering if this test will frequently end up having to be modified when the generated command lines evolve over time. On one hand, because the tests specify a specific version of a manifest (v4 in this case), the semantics should stay the same even if there are changes to newer versions... but on the other hand, those semantics might in future versions be achieved through other combinations of flags.

So I guess I'm wondering if there's a way to be less specific about the various flags that are getting passed (e.g. the -fobjc-arc on macOS) that would still test that the right sanitizer flags are being passed?

@Lukasa
Copy link
Contributor Author

Lukasa commented May 4, 2020

Yeah, we can use a Swift contains operation instead if you'd like. Would that be preferable?

@abertelrud
Copy link
Contributor

I think so, since that seems a bit more robust in the face of future changes. Otherwise I suspect that there will need to be repeated fixes to this test over time as unrelated things change. Thanks!

The current tests for sanitizers in SwiftPM are essentially "live": they
build a package that will do something to trigger a sanitizer, and then
run it and confirm it fails. This is a pretty fragile way to test, and
it exposes SwiftPM to a number of possible test failures that don't
have anything to do with the core mission (exposing the sanitizer).

This patch replaces those tests with build plan tests that validate that
SwiftPM correctly invokes swiftc and clang. These tests are acceptable
because for now SwiftPM doesn't have any smarts with the sanitizers: it
just passes them all through to swiftc and clang.

This patch also deletes the current live tests, as they are no longer
necessary.
@Lukasa Lukasa force-pushed the cb-move-scudo-testing branch from 3a27afd to d37a5c5 Compare May 5, 2020 09:26
@Lukasa
Copy link
Contributor Author

Lukasa commented May 5, 2020

@swift-ci please smoke test

Copy link
Contributor

@abertelrud abertelrud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for modifying the tests!

@neonichu neonichu merged commit 984618b into swiftlang:master May 7, 2020
Lukasa added a commit to Lukasa/swift-package-manager that referenced this pull request May 15, 2020
The current tests for sanitizers in SwiftPM are essentially "live": they
build a package that will do something to trigger a sanitizer, and then
run it and confirm it fails. This is a pretty fragile way to test, and
it exposes SwiftPM to a number of possible test failures that don't
have anything to do with the core mission (exposing the sanitizer).

This patch replaces those tests with build plan tests that validate that
SwiftPM correctly invokes swiftc and clang. These tests are acceptable
because for now SwiftPM doesn't have any smarts with the sanitizers: it
just passes them all through to swiftc and clang.

This patch also deletes the current live tests, as they are no longer
necessary.

(cherry picked from commit 984618b)
rballard pushed a commit that referenced this pull request May 15, 2020
* Add support for the Scudo sanitizer. + Test sanitizers with build plans

The Swift PR swiftlang/swift#28538 adds support for the Scudo hardened
allocator to swiftc. This patch adds support for it to Swift Package
Manager, allowing the Package Manager to correctly plumb Scudo through
the entire build pipeline.

See the aforementioned PR for more discussion on the value of supporting
Scudo.

(cherry picked from commit 594ccaa)

* Test sanitizers with build plans. (#2720)

The current tests for sanitizers in SwiftPM are essentially "live": they
build a package that will do something to trigger a sanitizer, and then
run it and confirm it fails. This is a pretty fragile way to test, and
it exposes SwiftPM to a number of possible test failures that don't
have anything to do with the core mission (exposing the sanitizer).

This patch replaces those tests with build plan tests that validate that
SwiftPM correctly invokes swiftc and clang. These tests are acceptable
because for now SwiftPM doesn't have any smarts with the sanitizers: it
just passes them all through to swiftc and clang.

This patch also deletes the current live tests, as they are no longer
necessary.

(cherry picked from commit 984618b)
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.

3 participants