Commit Graph

10 Commits

Author SHA1 Message Date
Pleuvens
011a1ac1a3
test: switch to new-style ASSERT_EQ macros (#4159)
Switch from old-style ASSERT macro to new-style ASSERT_EQ,... macros.

Using new-style macros makes it easier to debug test failures

Fixes: https://github.com/libuv/libuv/issues/2974
2023-10-06 19:50:15 +02:00
Ben Noordhuis
fa1da18549 test: canonicalize argv[0] in exepath test
Commit ff29322b ("test: canonicalize test runner path") from 2014
changed the test runner to call `realpath(3)` on `argv[0]` in order
to fix the `get_currentexe` test failing with the autotools build when
the executable path contained symbolic links but that is now causing
the `spawn_reads_child_path` test to fail on z/os with the cmake build.

Fix that by only doing path canonicalization in the `get_currentexe`
test, not always.

An auxiliary fix is applied to the `process_title_threadsafe` test
because it assumed that setting the process title to a long string,
then reading it back produces in the original string.

On some platforms however the maximum size of the process title is
limited to the size of the `argv` vector.

Because the test runner used absolute paths until now, the argv vector
was bigger than it is with relative paths, big enough to let this bad
assumption go unnoticed until now.

Minor fixes are applied to tests that assumed 1024 for the maximum
path size because this commit makes visible that some of the CI matrix
systems support much longer paths.

PR-URL: https://github.com/libuv/libuv/pull/2755
Refs: https://github.com/libuv/libuv/pull/2737#issuecomment-602800431
Refs: https://github.com/libuv/libuv/pull/2754#issuecomment-604015785
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-27 23:51:22 +01:00
Ben Noordhuis
87cbf546d8 test: remove unused extern declaration
PR-URL: https://github.com/libuv/libuv/pull/2755
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-27 23:50:44 +01:00
Ben Noordhuis
6e18112127 unix: make uv_cwd() report UV_ENOBUFS
Make uv_cwd() do what the documentation says it did when the destination
buffer is too small: report UV_ENOBUFS and set the `size` in/out param
to the size of the path including the trailing nul byte.

Fixes: https://github.com/libuv/libuv/issues/2333
PR-URL: https://github.com/libuv/libuv/pull/2335
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-06-20 12:04:16 +02:00
Saúl Ibarra Corretgé
37daffaccb test: fix cwd_and_chdir test on Unix
There is no need to check for a trailing slash, uv_cwd ensures it.

PR-URL: https://github.com/libuv/libuv/pull/63
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-16 08:12:46 +01:00
Bert Belder
e8c4c329e6 test: fix test-cwd-and-chdir
The test used to call uv_cwd() twice, in this fashion:

  char buf[PATH_MAX];
  size_t size = sizeof buf;

  uv_cwd(buf, &size);
  uv_cwd(buf, &size);

The `size` variable is supposed to contain the buffer size (including
terminating null) on input, and it is also used as an out parameter for
returning the actual length of the working directory (not including the
terminating null). This makes the second uv_cwd() call fail with
UV_ENOBUFS.

PR-URL: https://github.com/libuv/libuv/pull/54
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-11 17:12:04 +01:00
Saúl Ibarra Corretgé
422d2810b3 unix, windows: make uv_cwd be consistent with uv_exepath
Fixes #446
2014-02-27 09:44:28 +01:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Bert Belder
09a0d61e7b Test cwd_and_chdir: don't chdir to "" or "c:"
It should not strip the trailing (back)slash from a root directory.
2012-03-09 16:31:02 +01:00
Igor Zinkovsky
dceb3e65ca uv_cwd + uv_chdir 2011-12-01 12:27:12 -08:00