Commit Graph

5 Commits

Author SHA1 Message Date
Vasily Galkin
50cb4f221c gspawn, tests: extend spawn_test, run it on win32
The spawn_test is enabled on win32 meson build, both msys and msvc.

Some modifications to make it useful for auto-testing on win32:
- use own argv0 to find helper win32-specific subprogram
- helper subprogram and conditions changed, so testing is fully
automated instead of manually checking contents of some MessageBoxes

Redirection test checks "sort" output for locale-independent string
instead of relying on "netstat" locale-dependent string.
Also with "sort" it become usable on unix, so enabled there too.
Currently this fails on win32 with coverage since
some coverage-realted error output from gpawn-win32-helper
is unexpectedly treated as executed subprocess output.


Added test checking "sort" with error-only redirection. This also fails
on win32 by now, due to a typo in gspawn-win32.c (checks for stdout
redirection instead of stderr)
2018-12-26 23:45:47 +03:00
Philip Withnall
5cddde1fb2 Consistently save errno immediately after the operation setting it
Prevent the situation where errno is set by function A, then function B
is called (which is typically _(), but could be anything else) and it
overwrites errno, then errno is checked by the caller.

errno is a horrific API, and we need to be careful to save its value as
soon as a function call (which might set it) returns. i.e. Follow the
pattern:
  int errsv, ret;
  ret = some_call_which_might_set_errno ();
  errsv = errno;

  if (ret < 0)
    puts (strerror (errsv));

This patch implements that pattern throughout GLib. There might be a few
places in the test code which still use errno directly. They should be
ported as necessary. It doesn’t modify all the call sites like this:
  if (some_call_which_might_set_errno () && errno == ESOMETHING)
since the refactoring involved is probably more harmful than beneficial
there. It does, however, refactor other call sites regardless of whether
they were originally buggy.

https://bugzilla.gnome.org/show_bug.cgi?id=785577
2017-08-03 10:21:13 +01:00
Tor Lillqvist
7f38edf367 Minor Cygwin fix. (#138405, Roger Leigh)
2004-03-31  Tor Lillqvist  <tml@iki.fi>

	* tests/spawn-test-win32-gui.c: Minor Cygwin fix. (#138405, Roger
	Leigh)
2004-03-31 02:13:52 +00:00
Tor Lillqvist
f4cb22c78d glib/gspawn-win32.c Implement G_SPAWN_FILE_AND_ARGV_ZERO. (#136792, Bruce
2004-03-10  Tor Lillqvist  <tml@iki.fi>

	* glib/gspawn-win32.c
	* glib/gspawn-win32-helper.c: Implement
	G_SPAWN_FILE_AND_ARGV_ZERO. (#136792, Bruce Hochstetler)

	* tests/spawn-test.c
	* tests/spawn-test-win32-gui.c: Test it.
2004-03-10 22:59:14 +00:00
Tor Lillqvist
1f04f2cce2 Ignore the G_SPAWN_DO_NOT_REAP_CHILD flag, can't be meaninfully
2002-11-17  Tor Lillqvist  <tml@iki.fi>

	* glib/gspawn-win32.c (g_spawn_async_with_pipes): Ignore the
	G_SPAWN_DO_NOT_REAP_CHILD flag, can't be meaninfully implemented
	on Windows, at least not now. Always pass dont_wait as TRUE to
	do_spawn_with_pipes(). The semantics of the dont_wait parameter is
	very different from the semantics of the intermediate_child
	parameter to fork_exec_with_pipes() in the Unix version. This
	fixes a serious bug, g_spawn_async() in fact behaved
	synchronously.

	(do_spawn_with_pipes, do_spawn): Rename from
	fork_exec_with_pipes() and do_exec(), those names were from the
	Unix bersion, and misleading.

	(close_and_invalidate): Don't try to close invalid fds.

	* glib/gspawn.c (g_spawn_async_with_pipes): Add warning about
	Windows behaviour. There is no fork(), so the child_setup()
	function is in fact called in the parent.

	* glib/gspawn-win32-helper.c (WinMain): Insert spaces in argv
	debugging output.

	* tests/spawn-test-win32-gui.c: New file. Test program to be
	linked as a GUI application. Behaves differently depending on how
	invoked (by spawn-test).

	* tests/spawn-test.c (run_tests): On Win32, run the
	spawn-test-win32-gui program, too, in several ways, synchronously
	and asynchronously.

	* tests/Makefile.am: Corresponding change.
2002-11-17 03:52:55 +00:00