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

Fix Windows compilation of test sources #10822

Merged
merged 13 commits into from
Apr 21, 2020
Merged

Fix Windows compilation of test sources #10822

merged 13 commits into from
Apr 21, 2020

Conversation

wrowe
Copy link
Contributor

@wrowe wrowe commented Apr 17, 2020

Description:

This patch is extracted from #10542 and must be preceded by that merge in order for all enabled tests to compile successfully on Windows.

This patch should still be correct in the interim, and should effectively be a no-op on Linux.

  • Remove erroneous test from PR http2: support custom SETTINGS parameters #9964
    • Test macro missing the second argument (for test name),
      causing compilation on Windows to fail. It appears to
      have no purpose, copy-paste error?
  • more involved compilation failures in test sources are
    excluded with skip_on_windows tag
    • involving tests to do with features that don't exist for
      windows (signals, etc.)
    • sh_test rules do not currently work on Windows, waiting on a Bazel
      fix
  • Individually exclude tests in non-compiling extensions
    with skip_on_windows
  • subset of failing tests tagged with fails_on_windows
    • tests that time out
    • tests that are known to fail
    • non-exhaustive list, additional failing tests will be
      fixed/tagged in subsequent efforts
  • various fixes for Windows compilation
    • fix os_fd_t type in mocks
    • ensure consistent integer types
    • proliferate use of OsSysCalls in tests
    • exclude signals tests
    • add _set_invalid_parameter_handler to test main to ensure runtime
      does not abort when functions are called with invalid parameters
    • print warning about tcpdump not currently being enabled on Windows
    • matchers_test.cc: do not return address of literal
    • test/extensions/filters/network/direct_response/BUILD: skip test with
      constructor+lambda that does not compile on Windows
    • codec_impl_test.cc: MSVC pre-processing does not like the multline
      string passed to EXPECT_EQ macro, pull into intermediate variable

Co-authored-by: Sunjay Bhatia [email protected]
Co-authored-by: William A Rowe Jr [email protected]
Signed-off-by: Sunjay Bhatia [email protected]
Signed-off-by: William A Rowe Jr [email protected]

Risk Level: Low
Testing: Local on msvc-cl, linux-gcc
Docs Changes: n/a
Release Notes: n/a
[Optional Fixes #Issue]
[Optional Deprecated:]

- Remove erroneous test from PR #9964
  - Test macro missing the second argument (for test name),
    causing compilation on Windows to fail. It appears to
    have no purpose, copy-paste error?
- more involved compilation failures in test sources are
  excluded with skip_on_windows tag
  - involving tests to do with features that don't exist for
    windows (signals, etc.)
  - sh_test rules do not currently work on Windows, waiting on a Bazel
    fix
- Individually exclude tests in non-compiling extensions
  with skip_on_windows
- subset of failing tests tagged with fails_on_windows
  - tests that time out
  - tests that are known to fail
  - non-exhaustive list, additional failing tests will be
    fixed/tagged in subsequent efforts
- various fixes for Windows compilation
  - fix os_fd_t type in mocks
  - ensure consistent integer types
  - proliferate use of OsSysCalls in tests
  - exclude signals tests
  - add _set_invalid_parameter_handler to test main to ensure runtime
    does not abort when functions are called with invalid parameters
  - print warning about tcpdump not currently being enabled on Windows
  - matchers_test.cc: do not return address of literal
  - test/extensions/filters/network/direct_response/BUILD: skip test with
    constructor+lambda that does not compile on Windows
  - codec_impl_test.cc: MSVC pre-processing does not like the multline
    string passed to EXPECT_EQ macro, pull into intermediate variable

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
This did not belong to the test/... changes for Windows and breaks
the unix build, because 10542 introduced WINDOWS_SKIP_TARGETS.

This logic applies to the build schema for Windows, not specific
windows test fixes and exclusions.

Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
@wrowe
Copy link
Contributor Author

wrowe commented Apr 17, 2020

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #10822 (comment) was created by @wrowe.

see: more, trace.

Signed-off-by: William A Rowe Jr <[email protected]>
@wrowe
Copy link
Contributor Author

wrowe commented Apr 17, 2020

Ready for review and merge. As we noted in PR 10542;

Before removing test/* changes from this PR, all tests passing, except for coverage (known to be unstable.)

Any coverage and macos regressions indicate new problems on master or issues with the CI build environments themselves, not this specific patch.

@wrowe
Copy link
Contributor Author

wrowe commented Apr 18, 2020

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #10822 (comment) was created by @wrowe.

see: more, trace.

wrowe added 2 commits April 17, 2020 21:21
Signed-off-by: William A Rowe Jr <[email protected]>
…lation

Pick up possible fixes to coverage

Signed-off-by: William A Rowe Jr <[email protected]>
@mattklein123 mattklein123 self-assigned this Apr 18, 2020
os_fd_t pipe_fds[2] = {0, 0};
auto& os_sys_calls = Api::OsSysCallsSingleton::get();
#ifdef WIN32
ASSERT_EQ(os_sys_calls.socketpair(AF_INET, SOCK_STREAM, 0, pipe_fds).rc_, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use socketpair for linux tests as well and avoid ifdefing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a question of whether we are trying to test tcp or unix domain sockets in the linux implementation. Even though we have resolved that we can have AF_UNIX sockets on windows, a nameless pipe still isn't available. We can stub that in later, but this is the shortest-path to a working test compilation.

So if there are a couple +1's to switching this to os_sys_calls.socketpair, we are fine with that, or we can leave it as-is. A very final step of this integration will be revisiting all of the ifdef/defined() WIN32 to evaluate whether or not they should remain (some of them predate our involvement.)

Copy link
Member

Choose a reason for hiding this comment

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

I think as all of these tests are buffer tests and not network tests, having them all use socket pair seems fine to me so let's just do that?

Copy link
Contributor Author

@wrowe wrowe Apr 21, 2020

Choose a reason for hiding this comment

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

Tracking this suggestion in issue #10871, which you can assign back to myself and @sunjayBhatia.

We would appreciate accepting this PR as-is, and we will revisit this after resolving the rest of the Windows CI //test/... RBE changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I had forgotten that socketpair on Linux fails with AF_INET, so the Windows logic can't be used until we support AF_UNIX on Windows.)

Copy link
Member

Choose a reason for hiding this comment

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

Sure SGTM

@yanavlasov yanavlasov self-assigned this Apr 20, 2020
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM modulo some small comments. Thank you!

/wait

@@ -1,5 +1,8 @@
#ifndef WIN32
#include <pthread.h>
Copy link
Member

Choose a reason for hiding this comment

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

Is this actually needed on linux? I kind of doubt it. Can it just be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed on gcc.

test/main.cc Outdated

_set_invalid_parameter_handler(noop_invalid_parameter_handler);

WORD wVersionRequested;
Copy link
Member

Choose a reason for hiding this comment

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

nit: snake case var names here and below.

os_fd_t pipe_fds[2] = {0, 0};
auto& os_sys_calls = Api::OsSysCallsSingleton::get();
#ifdef WIN32
ASSERT_EQ(os_sys_calls.socketpair(AF_INET, SOCK_STREAM, 0, pipe_fds).rc_, 0);
Copy link
Member

Choose a reason for hiding this comment

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

I think as all of these tests are buffer tests and not network tests, having them all use socket pair seems fine to me so let's just do that?

as suggested by mattklein123.

Signed-off-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
@wrowe
Copy link
Contributor Author

wrowe commented Apr 21, 2020

/retest

... likely won't retest for github 500's overload on the envoy-presubmit pipeline

@repokitteh-read-only
Copy link

🤷‍♀️ nothing to rebuild.

🐱

Caused by: a #10822 (comment) was created by @wrowe.

see: more, trace.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 4c29cd5 into envoyproxy:master Apr 21, 2020
@sunjayBhatia sunjayBhatia deleted the windows-tests-compilation branch April 21, 2020 20:17
penguingao pushed a commit to penguingao/envoy that referenced this pull request Apr 22, 2020
Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
Signed-off-by: pengg <[email protected]>
@sunjayBhatia sunjayBhatia mentioned this pull request Apr 24, 2020
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.

4 participants