test: Allow journal messages due to reload in check-login.

Closes #467

Reviewed-by: Stef Walter <stefw@redhat.com>
Build various components with correct log domain

We were using invalid flags here and there.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Don't close stderr in test-transport

This causes very hard to debug problems.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Make our own g_test_expect_message() work around

The g_test_expect_message() until 2.40 was pretty broken, so
build our own. This way we can start to quiet down our tests.

See: http://bugzilla.gnome.org/show_bug.cgi?id=661926
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Remove cockpit_log_null_handler

We're not using it, and should really be using our
cockpit_test_expect_message() in our tests.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Further quietening down of tests

Use our new cockpit_test_expect_xxx() funcitons to quieten down
the tests further. In addition in websocket, since we can't depend
on cockpit, use another work around.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Quieten down the expected failures in web tests

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Move repetetive test init stuff into cockpit_test_init

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Add new cockpit_assert_strmatch() function

Remove duplicate definitions of assert_matches() macro.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Consolidate into cockpit_test_skip()

Since we can't call g_test_skip() yet, it's not available in
the GLib's we target, make a single copy of our own function.

Closes #471
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Add cockpit_pipe_spawn() function to create process pipe

This is more general than cockpit_pipe_transport_spawn(). Once we
migrate to libssh then cockpit_pipe_transpown_spawn() should be
rewritten to use cockpit_pipe_spawn().

Since we'd like to use this as a cockpit_pipe_transport_spawn()
constructor, allow passing the gtype. In theory we would make all
these arguments be constructor arguments of CockpitPipe and then
pass it all in that way. But man that's tiring and less readable.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Close failed CockpitPipe in right thread context

CockpitPipe is not thread-safe, so it's close-on-fail-during-init
idle handler needs to be called in the thread main context for
the thread in which it was created.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Add cockpit_pipe_get_pid() function

We're needing to check on the pid, and whether a pipe has a pid
in a few places. So make this a real function instead of forcing
use of g_object_get (pipe, "pid", ...);

In addition guarantee that cockpit_pipe_get_pid() will still return
the pid after 'close' has fired.

Also add some testing infrastructure to test-pipe. This will be
used further in later commits.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Rename CockpitPipe 'closed' signal to 'close'

It was conflicting with CockpitTransport's 'closed' signal and
CockpitPipeTransport ended up with both overlapping.

The 'close' name matches the other method and signal names in
CockpitPipe better as well.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Split exit status handling out of CockpitPipe

The exit status handling in CockpitPipe was very specific to
the launch code in cockpit_pipe_transport_spawn(). Move this
logic into CockpitPipeTransport instead.

We want to use CockpitPipe for arbitrary processes and need
clean exit code handling.

Add cockpit_pipe_exit_status() function for retrieving the
exit status of the reaped child process.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Add cockpit_channel_get_bool_option() function

And implement it using cockpit_json_get_bool() which does the usual
checks for the correct member type.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Tweak test output a bit

For more visibility in CI. Also remove unnecessary init
from test-pipe.c

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Implement text-stream channel with spawn argument

This launches a process and connects the channel to the standard
input and standard output of the spawned process. Standard error
goes to the same output as the agent's unless redirected.

The command is not passed to the shell, it should be a full
executable path.

The doc/protocol.md documentation has some details on how
to call this.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Properly handle case where pipe closing both in/out

When pipe is asked to close output, but not a socket and the
input file descriptor is equal to the output fd, then we have
to close both. This means we stop reading input as well.

Previously this case would cause a critical warning and reading
from an invalid file descriptor.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
cockpit: Implement cockpit_pipe_pty() function

This opens up a pipe with a pty provided by forkpty() and lets
us communicate with that pty.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>