Skip to content

Support running tests in out-of-tree builds & fix some warnings - #801

Closed
dfandrich wants to merge 2 commits into
masterfrom
dfandrich/opensshtests
Closed

dfandrich wants to merge 2 commits into
masterfrom
dfandrich/opensshtests

Conversation

@dfandrich

Copy link
Copy Markdown
Contributor

No description provided.

Various files are found by referencing the srcdir environment variable
in that case.
@dfandrich
dfandrich force-pushed the dfandrich/opensshtests branch from 8df0e8a to c31f924 Compare February 22, 2023 23:16
Two warnings (in tests & examples) in particular would cause problems:
bad format causing invalid data output or a bad chdir due to out of
scope buffer use.
@dfandrich
dfandrich force-pushed the dfandrich/opensshtests branch from c31f924 to 4302a28 Compare February 22, 2023 23:46
@dfandrich dfandrich closed this in 4c9ed51 Feb 24, 2023
@dfandrich
dfandrich deleted the dfandrich/opensshtests branch February 24, 2023 17:30
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 5, 2023
This should be unnecessary after 4c9ed51 libssh2#801,
that fixes up all referenced source filenames with the `srcdir` envvar.

The `srcdir` envvar was exported by autotools, and now we're also setting
it from CMake.
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 5, 2023
This should be unnecessary after 4c9ed51 libssh2#801,
that fixes up all referenced source filenames with the `srcdir` envvar.

The `srcdir` envvar was exported by autotools, and now we're also setting
it from CMake.
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 5, 2023
This should be unnecessary after 4c9ed51 libssh2#801,
that fixes up all referenced source filenames with the `srcdir` envvar.

The `srcdir` envvar was exported by autotools, and now we're also setting
it from CMake.
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 5, 2023
This should be unnecessary after
  4c9ed51 libssh2#801,
that prefixes referenced input filenames with the `srcdir` envvar.

The `srcdir` envvar was already exported by autotools, and now we're
also setting it from CMake.
vszakats added a commit that referenced this pull request May 5, 2023
Before this patch libssh2 used a variety of solutions to pass the source
directory to tests: `FIXTURE_WORKDIR` build-time macro (cmake),
`FIXTURE_WORKDIR` envvar (unused), setting `srcdir` manually
(autotools), setting current directory (cmake), and also `builddir`
envvar (autotools) for passing current working dir to `mansyntax.sh`.

This patch reduces this to using existing `srcdir` with autotools and
setting it ourselves in CMake. This was mostly enabled by this recent
patch: 4c9ed51

Details:

- cmake: replace baked-in `FIXTURE_WORKDIR` macro with env.

  Added in 54bef4c #198 (2018-03-21)

- rename `FIXTURE_WORKDIR` to `srcdir`, to match autotools.

- cmake: add missing `srcdir` for algo and sshd tests.

- session_fixture: stop `chdir()`-ing, rely on prefixing with `srcdir`.

  Changing current directory should be unnecessary after
    4c9ed51 #801 (2023-02-24),
  that prefixes referenced input filenames with the `srcdir` envvar.

  The `srcdir` envvar was already exported by autotools, and now we're
  also setting it from CMake.

- cmake: stop setting `WORKING_DIRECTORY`, rely on `srcdir` env.

  `WORKING_DIRECTORY` is no longer necessary, after passing `srcdir` to
  all tests, so they can find our source tree and keys/etc in it
  regardless of the current directory.

  Also this past commit hints that `WORKING_DIRECTORY` wasn't always
  working for this purpose as expected:
    "tests: Xcode doesn't obey CMake's test working directory"
  Ref: 10a5cbf

- autotools: delete explicit `srcdir` for test env.

  Added in 13f8add (2015-07-02)

  automake documents `srcdir` as exported to the test environment:
  https://github.com/autotools-mirror/automake/blob/c04c4e8856e3c933239959ce18e16599fcc04a8b/doc/automake.texi#L9302-L9304
  https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
  It's mentioned in the docs back in 1997 and got a regression test in
  2012. We can safely assume it to be available without setting it
  ourselves.

- autotools: delete explicit `builddir`.

  Added in 13f8add (2015-07-02)

  It seems this wasn't necessary to make the above fix work, and
  `mansyntax.sh` is able to figure out the build workdir by reading
  `$PWD`. Our out-of-tree and `make distcheck` CI builds also work
  without it.

  Let us know if there is a scenario we're missing and needs this.

Closes #1032
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Various files are found by referencing the srcdir environment variable
in that case.

Closes libssh2#801
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Before this patch libssh2 used a variety of solutions to pass the source
directory to tests: `FIXTURE_WORKDIR` build-time macro (cmake),
`FIXTURE_WORKDIR` envvar (unused), setting `srcdir` manually
(autotools), setting current directory (cmake), and also `builddir`
envvar (autotools) for passing current working dir to `mansyntax.sh`.

This patch reduces this to using existing `srcdir` with autotools and
setting it ourselves in CMake. This was mostly enabled by this recent
patch: 4c9ed51

Details:

- cmake: replace baked-in `FIXTURE_WORKDIR` macro with env.

  Added in 54bef4c libssh2#198 (2018-03-21)

- rename `FIXTURE_WORKDIR` to `srcdir`, to match autotools.

- cmake: add missing `srcdir` for algo and sshd tests.

- session_fixture: stop `chdir()`-ing, rely on prefixing with `srcdir`.

  Changing current directory should be unnecessary after
    4c9ed51 libssh2#801 (2023-02-24),
  that prefixes referenced input filenames with the `srcdir` envvar.

  The `srcdir` envvar was already exported by autotools, and now we're
  also setting it from CMake.

- cmake: stop setting `WORKING_DIRECTORY`, rely on `srcdir` env.

  `WORKING_DIRECTORY` is no longer necessary, after passing `srcdir` to
  all tests, so they can find our source tree and keys/etc in it
  regardless of the current directory.

  Also this past commit hints that `WORKING_DIRECTORY` wasn't always
  working for this purpose as expected:
    "tests: Xcode doesn't obey CMake's test working directory"
  Ref: libssh2@10a5cbf

- autotools: delete explicit `srcdir` for test env.

  Added in 13f8add (2015-07-02)

  automake documents `srcdir` as exported to the test environment:
  https://github.com/autotools-mirror/automake/blob/c04c4e8856e3c933239959ce18e16599fcc04a8b/doc/automake.texi#L9302-L9304
  https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
  It's mentioned in the docs back in 1997 and got a regression test in
  2012. We can safely assume it to be available without setting it
  ourselves.

- autotools: delete explicit `builddir`.

  Added in 13f8add (2015-07-02)

  It seems this wasn't necessary to make the above fix work, and
  `mansyntax.sh` is able to figure out the build workdir by reading
  `$PWD`. Our out-of-tree and `make distcheck` CI builds also work
  without it.

  Let us know if there is a scenario we're missing and needs this.

Closes libssh2#1032
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.

1 participant