/* test-umockdev-record.c generated by valac 0.40.4, the Vala compiler
 * generated from test-umockdev-record.vala, do not modify */

/*
 * test-umockdev-record.vala
 *
 * Copyright (C) 2013 Canonical Ltd.
 * Author: Martin Pitt <martin.pitt@ubuntu.com>
 *
 * umockdev is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * umockdev is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; If not, see <http://www.gnu.org/licenses/>.
 */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <glib/gstdio.h>
#include <umockdev.h>
#include <unistd.h>
#include <pty.h>
#include <termios.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <gio/gio.h>
#include <gio/gunixsocketaddress.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _fclose0(var) ((var == NULL) ? NULL : (var = (fclose (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);


extern gchar* umockdev_record_path;
gchar* umockdev_record_path = NULL;
extern gchar* umockdev_run_path;
gchar* umockdev_run_path = NULL;
extern gchar* rootdir;
gchar* rootdir = NULL;

void spawn (const gchar* command,
            gchar* * sout,
            gchar* * serr,
            gint* exit);
void assert_in (const gchar* needle,
                const gchar* haystack);
gchar* file_contents (const gchar* filename);
void t_testbed_all_empty (void);
void t_testbed_one (void);
void t_testbed_multiple (void);
void t_testbed_no_ioctl_record (void);
void t_system_single (void);
void t_system_all (void);
void t_system_invalid (void);
void t_system_ioctl_log (void);
void t_system_ioctl_log_append_dev_mismatch (void);
void t_system_script_log_simple (void);
void t_system_script_log_append_same_dev (void);
void t_system_script_log_append_dev_mismatch (void);
gchar* read_line_timeout (FILE* stream);
void t_system_script_log_chatter (void);
void t_system_script_log_chatter_socket_stream (void);
void t_system_evemu_log (void);
void t_run_invalid_args (void);
void t_gphoto2_record (void);
gint _vala_main (gchar** args,
                 int args_length1);
static void _t_testbed_all_empty_gtest_func (void);
static void _t_testbed_one_gtest_func (void);
static void _t_testbed_multiple_gtest_func (void);
static void _t_testbed_no_ioctl_record_gtest_func (void);
static void _t_system_single_gtest_func (void);
static void _t_system_invalid_gtest_func (void);
static void _t_system_ioctl_log_gtest_func (void);
static void _t_system_ioctl_log_append_dev_mismatch_gtest_func (void);
static void _t_system_script_log_simple_gtest_func (void);
static void _t_system_script_log_append_same_dev_gtest_func (void);
static void _t_system_script_log_append_dev_mismatch_gtest_func (void);
static void _t_system_script_log_chatter_gtest_func (void);
static void _t_system_script_log_chatter_socket_stream_gtest_func (void);
static void _t_system_evemu_log_gtest_func (void);
static void _t_run_invalid_args_gtest_func (void);
static void _t_gphoto2_record_gtest_func (void);
static void _vala_array_destroy (gpointer array,
                          gint array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gint array_length,
                       GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


void
spawn (const gchar* command,
       gchar* * sout,
       gchar* * serr,
       gint* exit)
{
	gchar* _vala_sout = NULL;
	gchar* _vala_serr = NULL;
	gint _vala_exit = 0;
	GError * _inner_error_ = NULL;
	g_return_if_fail (command != NULL);
	{
		gboolean _tmp0_ = FALSE;
		gchar* _tmp1_ = NULL;
		gchar* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		gboolean _tmp4_;
		_tmp4_ = g_spawn_command_line_sync (command, &_tmp1_, &_tmp2_, &_tmp3_, &_inner_error_);
		_g_free0 (_vala_sout);
		_vala_sout = _tmp1_;
		_g_free0 (_vala_serr);
		_vala_serr = _tmp2_;
		_vala_exit = _tmp3_;
		_tmp0_ = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_SPAWN_ERROR) {
				goto __catch0_g_spawn_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_vala_assert (_tmp0_, "Process.spawn_command_line_sync (command, out sout, out serr, out exit)");
	}
	goto __finally0;
	__catch0_g_spawn_error:
	{
		GError* e = NULL;
		const gchar* _tmp5_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp5_ = e->message;
		g_error ("test-umockdev-record.vala:34: Cannot call '%s': %s", command, _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	if (sout) {
		*sout = _vala_sout;
	} else {
		_g_free0 (_vala_sout);
	}
	if (serr) {
		*serr = _vala_serr;
	} else {
		_g_free0 (_vala_serr);
	}
	if (exit) {
		*exit = _vala_exit;
	}
}


static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gboolean result = FALSE;
	gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}


void
assert_in (const gchar* needle,
           const gchar* haystack)
{
	g_return_if_fail (needle != NULL);
	g_return_if_fail (haystack != NULL);
	if (!string_contains (haystack, needle)) {
		FILE* _tmp0_;
		_tmp0_ = stderr;
		fprintf (_tmp0_, "'%s' not found in '%s'\n", needle, haystack);
		abort ();
	}
}


gchar*
file_contents (const gchar* filename)
{
	gchar* result = NULL;
	gchar* contents = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (filename != NULL, NULL);
	{
		gboolean _tmp0_ = FALSE;
		gchar* _tmp1_ = NULL;
		gboolean _tmp2_;
		_tmp2_ = g_file_get_contents (filename, &_tmp1_, NULL, &_inner_error_);
		_g_free0 (contents);
		contents = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_FILE_ERROR) {
				goto __catch1_g_file_error;
			}
			_g_free0 (contents);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_vala_assert (_tmp0_, "FileUtils.get_contents (filename, out contents)");
	}
	goto __finally1;
	__catch1_g_file_error:
	{
		GError* e = NULL;
		const gchar* _tmp3_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = e->message;
		g_error ("test-umockdev-record.vala:54: Cannot get contents of %s: %s", filename, _tmp3_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (contents);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	result = contents;
	return result;
}


void
t_testbed_all_empty (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	UMockdevTestbed* tb = NULL;
	UMockdevTestbed* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gint _tmp6_ = 0;
	_tmp0_ = umockdev_testbed_new ();
	tb = _tmp0_;
	_vala_assert (tb != NULL, "tb != null");
	_tmp1_ = umockdev_record_path;
	_tmp2_ = g_strconcat (_tmp1_, " --all", NULL);
	_tmp3_ = _tmp2_;
	spawn (_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	_g_free0 (sout);
	sout = _tmp4_;
	_g_free0 (serr);
	serr = _tmp5_;
	exit = _tmp6_;
	_g_free0 (_tmp3_);
	g_assert_cmpstr (serr, ==, "");
	g_assert_cmpstr (sout, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_g_object_unref0 (tb);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_testbed_one (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	UMockdevTestbed* tb = NULL;
	UMockdevTestbed* _tmp0_;
	gchar* syspath = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar** _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	gchar* _tmp13_;
	gchar* _tmp14_;
	guint8* _tmp15_;
	guint8* _tmp16_;
	gint _tmp16__length1;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_ = NULL;
	gchar* _tmp21_ = NULL;
	gint _tmp22_ = 0;
	_tmp0_ = umockdev_testbed_new ();
	tb = _tmp0_;
	_tmp1_ = g_strdup ("simple_attr");
	_tmp2_ = g_strdup ("1");
	_tmp3_ = g_strdup ("multiline_attr");
	_tmp4_ = g_strdup ("a\\b\nc\\d\nlast");
	_tmp5_ = g_strdup ("knobs/red");
	_tmp6_ = g_strdup ("off");
	_tmp7_ = g_new0 (gchar*, 6 + 1);
	_tmp7_[0] = _tmp1_;
	_tmp7_[1] = _tmp2_;
	_tmp7_[2] = _tmp3_;
	_tmp7_[3] = _tmp4_;
	_tmp7_[4] = _tmp5_;
	_tmp7_[5] = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = 6;
	_tmp9_ = g_strdup ("SIMPLE_PROP");
	_tmp10_ = g_strdup ("1");
	_tmp11_ = g_new0 (gchar*, 2 + 1);
	_tmp11_[0] = _tmp9_;
	_tmp11_[1] = _tmp10_;
	_tmp12_ = _tmp11_;
	_tmp12__length1 = 2;
	_tmp13_ = umockdev_testbed_add_devicev (tb, "pci", "dev1", NULL, _tmp8_, _tmp12_);
	_tmp14_ = _tmp13_;
	_tmp12_ = (_vala_array_free (_tmp12_, _tmp12__length1, (GDestroyNotify) g_free), NULL);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL);
	syspath = _tmp14_;
	_tmp15_ = g_new0 (guint8, 6);
	_tmp15_[0] = (guint8) 0x41;
	_tmp15_[1] = (guint8) 0xFF;
	_tmp15_[2] = (guint8) 0;
	_tmp15_[3] = (guint8) 5;
	_tmp15_[4] = (guint8) 0xFF;
	_tmp15_[5] = (guint8) 0;
	_tmp16_ = _tmp15_;
	_tmp16__length1 = 6;
	umockdev_testbed_set_attribute_binary (tb, syspath, "binary_attr", _tmp16_, 6);
	_tmp16_ = (g_free (_tmp16_), NULL);
	umockdev_testbed_set_attribute_link (tb, syspath, "driver", "../../drivers/foo");
	umockdev_testbed_set_attribute_link (tb, syspath, "power/fiddle", "../some/where");
	_tmp17_ = umockdev_record_path;
	_tmp18_ = g_strconcat (_tmp17_, " --all", NULL);
	_tmp19_ = _tmp18_;
	spawn (_tmp19_, &_tmp20_, &_tmp21_, &_tmp22_);
	_g_free0 (sout);
	sout = _tmp20_;
	_g_free0 (serr);
	serr = _tmp21_;
	exit = _tmp22_;
	_g_free0 (_tmp19_);
	g_assert_cmpstr (serr, ==, "");
	g_assert_cmpint (exit, ==, 0);
	g_assert_cmpstr (sout, ==, "P: /devices/dev1\n" \
"E: SIMPLE_PROP=1\n" \
"E: SUBSYSTEM=pci\n" \
"H: binary_attr=41FF0005FF00\n" \
"L: driver=../../drivers/foo\n" \
"A: knobs/red=off\n" \
"A: multiline_attr=a\\\\b\\nc\\\\d\\nlast\n" \
"L: power/fiddle=../some/where\n" \
"A: simple_attr=1\n" \
"\n");
	_g_free0 (syspath);
	_g_object_unref0 (tb);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_testbed_multiple (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	UMockdevTestbed* tb = NULL;
	UMockdevTestbed* _tmp0_;
	gchar* dev1 = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* subdev1 = NULL;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar** _tmp19_;
	gchar** _tmp20_;
	gint _tmp20__length1;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar** _tmp25_;
	gchar** _tmp26_;
	gint _tmp26__length1;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar** _tmp29_;
	gchar** _tmp30_;
	gint _tmp30__length1;
	gchar* _tmp31_;
	gchar* _tmp32_;
	const gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_ = NULL;
	gchar* _tmp39_ = NULL;
	gint _tmp40_ = 0;
	const gchar* _tmp41_;
	gint _tmp42_;
	const gchar* _tmp43_;
	const gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	gchar* _tmp49_ = NULL;
	gchar* _tmp50_ = NULL;
	gint _tmp51_ = 0;
	const gchar* _tmp52_;
	gint _tmp53_;
	const gchar* _tmp54_;
	const gchar* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_ = NULL;
	gchar* _tmp59_ = NULL;
	gint _tmp60_ = 0;
	const gchar* _tmp61_;
	gint _tmp62_;
	const gchar* _tmp63_;
	const gchar* _tmp64_;
	const gchar* _tmp65_;
	_tmp0_ = umockdev_testbed_new ();
	tb = _tmp0_;
	_tmp1_ = g_strdup ("dev1color");
	_tmp2_ = g_strdup ("green");
	_tmp3_ = g_strdup ("knobs/red");
	_tmp4_ = g_strdup ("off");
	_tmp5_ = g_new0 (gchar*, 4 + 1);
	_tmp5_[0] = _tmp1_;
	_tmp5_[1] = _tmp2_;
	_tmp5_[2] = _tmp3_;
	_tmp5_[3] = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp6__length1 = 4;
	_tmp7_ = g_strdup ("DEV1COLOR");
	_tmp8_ = g_strdup ("GREEN");
	_tmp9_ = g_new0 (gchar*, 2 + 1);
	_tmp9_[0] = _tmp7_;
	_tmp9_[1] = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp10__length1 = 2;
	_tmp11_ = umockdev_testbed_add_devicev (tb, "pci", "dev1", NULL, _tmp6_, _tmp10_);
	_tmp12_ = _tmp11_;
	_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_free), NULL);
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	dev1 = _tmp12_;
	_tmp13_ = g_strdup ("subdev1color");
	_tmp14_ = g_strdup ("yellow");
	_tmp15_ = g_new0 (gchar*, 2 + 1);
	_tmp15_[0] = _tmp13_;
	_tmp15_[1] = _tmp14_;
	_tmp16_ = _tmp15_;
	_tmp16__length1 = 2;
	_tmp17_ = g_strdup ("SUBDEV1COLOR");
	_tmp18_ = g_strdup ("YELLOW");
	_tmp19_ = g_new0 (gchar*, 2 + 1);
	_tmp19_[0] = _tmp17_;
	_tmp19_[1] = _tmp18_;
	_tmp20_ = _tmp19_;
	_tmp20__length1 = 2;
	_tmp21_ = umockdev_testbed_add_devicev (tb, "pci", "subdev1", dev1, _tmp16_, _tmp20_);
	_tmp22_ = _tmp21_;
	_tmp20_ = (_vala_array_free (_tmp20_, _tmp20__length1, (GDestroyNotify) g_free), NULL);
	_tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_free), NULL);
	subdev1 = _tmp22_;
	_tmp23_ = g_strdup ("dev2color");
	_tmp24_ = g_strdup ("brown");
	_tmp25_ = g_new0 (gchar*, 2 + 1);
	_tmp25_[0] = _tmp23_;
	_tmp25_[1] = _tmp24_;
	_tmp26_ = _tmp25_;
	_tmp26__length1 = 2;
	_tmp27_ = g_strdup ("DEV2COLOR");
	_tmp28_ = g_strdup ("BROWN");
	_tmp29_ = g_new0 (gchar*, 2 + 1);
	_tmp29_[0] = _tmp27_;
	_tmp29_[1] = _tmp28_;
	_tmp30_ = _tmp29_;
	_tmp30__length1 = 2;
	_tmp31_ = umockdev_testbed_add_devicev (tb, "pci", "dev2", NULL, _tmp26_, _tmp30_);
	_tmp32_ = _tmp31_;
	_g_free0 (_tmp32_);
	_tmp30_ = (_vala_array_free (_tmp30_, _tmp30__length1, (GDestroyNotify) g_free), NULL);
	_tmp26_ = (_vala_array_free (_tmp26_, _tmp26__length1, (GDestroyNotify) g_free), NULL);
	_tmp33_ = umockdev_record_path;
	_tmp34_ = g_strconcat (_tmp33_, " ", NULL);
	_tmp35_ = _tmp34_;
	_tmp36_ = g_strconcat (_tmp35_, subdev1, NULL);
	_tmp37_ = _tmp36_;
	spawn (_tmp37_, &_tmp38_, &_tmp39_, &_tmp40_);
	_g_free0 (sout);
	sout = _tmp38_;
	_g_free0 (serr);
	serr = _tmp39_;
	exit = _tmp40_;
	_g_free0 (_tmp37_);
	_g_free0 (_tmp35_);
	_tmp41_ = serr;
	g_assert_cmpstr (_tmp41_, ==, "");
	_tmp42_ = exit;
	g_assert_cmpint (_tmp42_, ==, 0);
	_tmp43_ = sout;
	g_assert_cmpstr (_tmp43_, ==, "P: /devices/dev1/subdev1\n" \
"E: SUBDEV1COLOR=YELLOW\n" \
"E: SUBSYSTEM=pci\n" \
"A: subdev1color=yellow\n" \
"\n" \
"P: /devices/dev1\n" \
"E: DEV1COLOR=GREEN\n" \
"E: SUBSYSTEM=pci\n" \
"A: dev1color=green\n" \
"A: knobs/red=off\n" \
"\n");
	_tmp44_ = umockdev_record_path;
	_tmp45_ = g_strconcat (_tmp44_, " ", NULL);
	_tmp46_ = _tmp45_;
	_tmp47_ = g_strconcat (_tmp46_, dev1, NULL);
	_tmp48_ = _tmp47_;
	spawn (_tmp48_, &_tmp49_, &_tmp50_, &_tmp51_);
	_g_free0 (sout);
	sout = _tmp49_;
	_g_free0 (serr);
	serr = _tmp50_;
	exit = _tmp51_;
	_g_free0 (_tmp48_);
	_g_free0 (_tmp46_);
	_tmp52_ = serr;
	g_assert_cmpstr (_tmp52_, ==, "");
	_tmp53_ = exit;
	g_assert_cmpint (_tmp53_, ==, 0);
	_tmp54_ = sout;
	g_assert_cmpstr (_tmp54_, ==, "P: /devices/dev1\n" \
"E: DEV1COLOR=GREEN\n" \
"E: SUBSYSTEM=pci\n" \
"A: dev1color=green\n" \
"A: knobs/red=off\n" \
"\n");
	_tmp55_ = umockdev_record_path;
	_tmp56_ = g_strconcat (_tmp55_, " --all", NULL);
	_tmp57_ = _tmp56_;
	spawn (_tmp57_, &_tmp58_, &_tmp59_, &_tmp60_);
	_g_free0 (sout);
	sout = _tmp58_;
	_g_free0 (serr);
	serr = _tmp59_;
	exit = _tmp60_;
	_g_free0 (_tmp57_);
	_tmp61_ = serr;
	g_assert_cmpstr (_tmp61_, ==, "");
	_tmp62_ = exit;
	g_assert_cmpint (_tmp62_, ==, 0);
	_tmp63_ = sout;
	_vala_assert (string_contains (_tmp63_, "P: /devices/dev1/subdev1\n"), "sout.contains (\"P: /devices/dev1/subdev1\\n\")");
	_tmp64_ = sout;
	_vala_assert (string_contains (_tmp64_, "P: /devices/dev1\n"), "sout.contains (\"P: /devices/dev1\\n\")");
	_tmp65_ = sout;
	_vala_assert (string_contains (_tmp65_, "P: /devices/dev2\n"), "sout.contains (\"P: /devices/dev2\\n\")");
	_g_free0 (subdev1);
	_g_free0 (dev1);
	_g_object_unref0 (tb);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_testbed_no_ioctl_record (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	UMockdevTestbed* tb = NULL;
	UMockdevTestbed* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	gint _tmp14_ = 0;
	_tmp0_ = umockdev_testbed_new ();
	tb = _tmp0_;
	_tmp1_ = g_strdup ("dev");
	_tmp2_ = g_strdup ("1:5");
	_tmp3_ = g_new0 (gchar*, 2 + 1);
	_tmp3_[0] = _tmp1_;
	_tmp3_[1] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 2;
	_tmp5_ = g_new0 (gchar*, 0 + 1);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = 0;
	_tmp7_ = umockdev_testbed_add_devicev (tb, "mem", "zero", NULL, _tmp4_, _tmp6_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp8_);
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	_tmp9_ = umockdev_record_path;
	_tmp10_ = g_strconcat (_tmp9_, " --ioctl /sys/devices/zero=/dev/stdout -- head -c1 /dev/zero", NULL);
	_tmp11_ = _tmp10_;
	spawn (_tmp11_, &_tmp12_, &_tmp13_, &_tmp14_);
	_g_free0 (sout);
	sout = _tmp12_;
	_g_free0 (serr);
	serr = _tmp13_;
	exit = _tmp14_;
	_g_free0 (_tmp11_);
	g_assert_cmpint (exit, !=, 0);
	g_assert_cmpstr (sout, ==, "");
	_vala_assert (string_contains (serr, "UMOCKDEV_DIR cannot be used"), "serr.contains (\"UMOCKDEV_DIR cannot be used\")");
	_g_object_unref0 (tb);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_single (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	const gchar* _tmp8_;
	gint _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	if (!g_file_test ("/sys/dev/char/1:3", G_FILE_TEST_EXISTS)) {
		FILE* _tmp0_;
		FILE* _tmp1_;
		_tmp0_ = stdout;
		fprintf (_tmp0_, "[SKIP: no real /sys on this system] ");
		_tmp1_ = stdout;
		fflush (_tmp1_);
		_g_free0 (serr);
		_g_free0 (sout);
		return;
	}
	_tmp2_ = umockdev_record_path;
	_tmp3_ = g_strconcat (_tmp2_, " /dev/null /dev/zero", NULL);
	_tmp4_ = _tmp3_;
	spawn (_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
	_g_free0 (sout);
	sout = _tmp5_;
	_g_free0 (serr);
	serr = _tmp6_;
	exit = _tmp7_;
	_g_free0 (_tmp4_);
	_tmp8_ = serr;
	g_assert_cmpstr (_tmp8_, ==, "");
	_tmp9_ = exit;
	g_assert_cmpint (_tmp9_, ==, 0);
	_tmp10_ = sout;
	assert_in ("E: DEVNAME=/dev/null", _tmp10_);
	_tmp11_ = sout;
	assert_in ("P: /devices/virtual/mem/null", _tmp11_);
	_tmp12_ = sout;
	assert_in ("E: DEVNAME=/dev/zero", _tmp12_);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_all (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	const gchar* _tmp2_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gint _tmp10_ = 0;
	const gchar* _tmp11_;
	gint _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	UMockdevTestbed* tb = NULL;
	UMockdevTestbed* _tmp17_;
	GError * _inner_error_ = NULL;
	if (!g_file_test ("/sys/dev/char", G_FILE_TEST_EXISTS)) {
		FILE* _tmp0_;
		FILE* _tmp1_;
		_tmp0_ = stdout;
		fprintf (_tmp0_, "[SKIP: no real /sys on this system] ");
		_tmp1_ = stdout;
		fflush (_tmp1_);
		_g_free0 (serr);
		_g_free0 (sout);
		return;
	}
	_tmp2_ = g_getenv ("INSTALLED_TEST");
	if (_tmp2_ != NULL) {
		FILE* _tmp3_;
		FILE* _tmp4_;
		_tmp3_ = stdout;
		fprintf (_tmp3_, "[SKIP: brittle test] ");
		_tmp4_ = stdout;
		fflush (_tmp4_);
		_g_free0 (serr);
		_g_free0 (sout);
		return;
	}
	_tmp5_ = umockdev_record_path;
	_tmp6_ = g_strconcat (_tmp5_, " --all", NULL);
	_tmp7_ = _tmp6_;
	spawn (_tmp7_, &_tmp8_, &_tmp9_, &_tmp10_);
	_g_free0 (sout);
	sout = _tmp8_;
	_g_free0 (serr);
	serr = _tmp9_;
	exit = _tmp10_;
	_g_free0 (_tmp7_);
	_tmp11_ = serr;
	g_assert_cmpstr (_tmp11_, ==, "");
	_tmp12_ = exit;
	g_assert_cmpint (_tmp12_, ==, 0);
	_tmp13_ = sout;
	_vala_assert (g_str_has_prefix (_tmp13_, "P:"), "sout.has_prefix (\"P:\")");
	_tmp14_ = sout;
	_tmp15_ = strlen (_tmp14_);
	_tmp16_ = _tmp15_;
	g_assert_cmpint (_tmp16_, >=, 100);
	_tmp17_ = umockdev_testbed_new ();
	tb = _tmp17_;
	{
		gboolean _tmp18_ = FALSE;
		UMockdevTestbed* _tmp19_;
		const gchar* _tmp20_;
		_tmp19_ = tb;
		_tmp20_ = sout;
		_tmp18_ = umockdev_testbed_add_from_string (_tmp19_, _tmp20_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == UMOCKDEV_ERROR) {
				goto __catch2_umockdev_error;
			}
			_g_object_unref0 (tb);
			_g_free0 (serr);
			_g_free0 (sout);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_vala_assert (_tmp18_, "tb.add_from_string (sout)");
	}
	goto __finally2;
	__catch2_umockdev_error:
	{
		GError* e = NULL;
		const gchar* _tmp21_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp21_ = e->message;
		g_error ("test-umockdev-record.vala:233: Error when adding system dump to testbe" \
"d: %s", _tmp21_);
		_g_error_free0 (e);
	}
	__finally2:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (tb);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_object_unref0 (tb);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_invalid (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_ = NULL;
	gchar* _tmp15_ = NULL;
	gint _tmp16_ = 0;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	gint _tmp19_;
	if (!g_file_test ("/sys/block/loop0", G_FILE_TEST_EXISTS)) {
		FILE* _tmp0_;
		FILE* _tmp1_;
		_tmp0_ = stdout;
		fprintf (_tmp0_, "[SKIP: no real /sys on this system] ");
		_tmp1_ = stdout;
		fflush (_tmp1_);
		_g_free0 (serr);
		_g_free0 (sout);
		return;
	}
	_tmp2_ = umockdev_record_path;
	_tmp3_ = g_strconcat (_tmp2_, " /sys/class", NULL);
	_tmp4_ = _tmp3_;
	spawn (_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
	_g_free0 (sout);
	sout = _tmp5_;
	_g_free0 (serr);
	serr = _tmp6_;
	exit = _tmp7_;
	_g_free0 (_tmp4_);
	_tmp8_ = serr;
	g_assert_cmpstr (_tmp8_, ==, "Invalid device /sys/class, has no uevent attribute\n");
	_tmp9_ = sout;
	g_assert_cmpstr (_tmp9_, ==, "");
	_tmp10_ = exit;
	g_assert_cmpint (_tmp10_, !=, 0);
	_tmp11_ = umockdev_record_path;
	_tmp12_ = g_strconcat (_tmp11_, " /sys/block/loop0/size", NULL);
	_tmp13_ = _tmp12_;
	spawn (_tmp13_, &_tmp14_, &_tmp15_, &_tmp16_);
	_g_free0 (sout);
	sout = _tmp14_;
	_g_free0 (serr);
	serr = _tmp15_;
	exit = _tmp16_;
	_g_free0 (_tmp13_);
	_tmp17_ = serr;
	g_assert_cmpstr (_tmp17_, ==, "Invalid device /sys/devices/virtual/block/loop0/size, has no uevent at" \
"tribute\n");
	_tmp18_ = sout;
	g_assert_cmpstr (_tmp18_, ==, "");
	_tmp19_ = exit;
	g_assert_cmpint (_tmp19_, !=, 0);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_ioctl_log (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* workdir = NULL;
	gchar* log = NULL;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_ = NULL;
	gint _tmp13_ = 0;
	const gchar* _tmp14_;
	gint _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	gint _tmp26_ = 0;
	const gchar* _tmp27_;
	gint _tmp28_;
	const gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_ = NULL;
	gchar* _tmp36_ = NULL;
	gint _tmp37_ = 0;
	gint _tmp38_;
	const gchar* _tmp39_;
	const gchar* _tmp40_;
	const gchar* _tmp41_;
	GError * _inner_error_ = NULL;
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = g_dir_make_tmp ("ioctl_log_test.XXXXXX", &_inner_error_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch3_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_free0 (workdir);
		workdir = _tmp2_;
		_g_free0 (_tmp0_);
	}
	goto __finally3;
	__catch3_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally3:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (workdir);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp3_ = g_build_filename (workdir, "log", NULL);
	log = _tmp3_;
	_tmp4_ = umockdev_record_path;
	_tmp5_ = g_strconcat (_tmp4_, " --ioctl=/dev/null=", NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strconcat (_tmp6_, log, NULL);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strconcat (_tmp8_, " -- head -c1 /dev/zero", NULL);
	_tmp10_ = _tmp9_;
	spawn (_tmp10_, &_tmp11_, &_tmp12_, &_tmp13_);
	_g_free0 (sout);
	sout = _tmp11_;
	_g_free0 (serr);
	serr = _tmp12_;
	exit = _tmp13_;
	_g_free0 (_tmp10_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_tmp14_ = serr;
	g_assert_cmpstr (_tmp14_, ==, "");
	_tmp15_ = exit;
	g_assert_cmpint (_tmp15_, ==, 0);
	_tmp16_ = sout;
	g_assert_cmpstr (_tmp16_, ==, "\0");
	_vala_assert (!g_file_test (log, G_FILE_TEST_EXISTS), "!FileUtils.test (log, FileTest.EXISTS)");
	_tmp17_ = umockdev_record_path;
	_tmp18_ = g_strconcat (_tmp17_, " --ioctl /dev/zero=", NULL);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_strconcat (_tmp19_, log, NULL);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_strconcat (_tmp21_, " -- head -c1 /dev/zero", NULL);
	_tmp23_ = _tmp22_;
	spawn (_tmp23_, &_tmp24_, &_tmp25_, &_tmp26_);
	_g_free0 (sout);
	sout = _tmp24_;
	_g_free0 (serr);
	serr = _tmp25_;
	exit = _tmp26_;
	_g_free0 (_tmp23_);
	_g_free0 (_tmp21_);
	_g_free0 (_tmp19_);
	_tmp27_ = serr;
	g_assert_cmpstr (_tmp27_, ==, "");
	_tmp28_ = exit;
	g_assert_cmpint (_tmp28_, ==, 0);
	_tmp29_ = sout;
	g_assert_cmpstr (_tmp29_, ==, "\0");
	_vala_assert (g_file_test (log, G_FILE_TEST_EXISTS), "FileUtils.test (log, FileTest.EXISTS)");
	_tmp30_ = file_contents (log);
	_tmp31_ = _tmp30_;
	g_assert_cmpstr (_tmp31_, ==, "@DEV /dev/zero\n");
	_g_free0 (_tmp31_);
	g_remove (log);
	_tmp32_ = umockdev_record_path;
	_tmp33_ = g_strconcat (_tmp32_, " --ioctl /dev/null -- head -c1 /dev/zero", NULL);
	_tmp34_ = _tmp33_;
	spawn (_tmp34_, &_tmp35_, &_tmp36_, &_tmp37_);
	_g_free0 (sout);
	sout = _tmp35_;
	_g_free0 (serr);
	serr = _tmp36_;
	exit = _tmp37_;
	_g_free0 (_tmp34_);
	_tmp38_ = exit;
	g_assert_cmpint (_tmp38_, !=, 1);
	_tmp39_ = sout;
	g_assert_cmpstr (_tmp39_, ==, "");
	_tmp40_ = serr;
	_vala_assert (string_contains (_tmp40_, "--ioctl"), "serr.contains (\"--ioctl\")");
	_tmp41_ = serr;
	_vala_assert (string_contains (_tmp41_, "="), "serr.contains (\"=\")");
	_vala_assert (!g_file_test (log, G_FILE_TEST_EXISTS), "!FileUtils.test (log, FileTest.EXISTS)");
	g_rmdir (workdir);
	_g_free0 (log);
	_g_free0 (workdir);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_ioctl_log_append_dev_mismatch (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* log = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	const gchar* _tmp13_;
	gint _tmp14_;
	const gchar* _tmp15_;
	gchar* orig_contents = NULL;
	gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	gint _tmp26_ = 0;
	const gchar* _tmp27_;
	gint _tmp28_;
	const gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	GError * _inner_error_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("ioctl_log_test.XXXXXX", &_tmp1_, &_inner_error_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch4_g_error;
		}
		close (_tmp0_);
	}
	goto __finally4;
	__catch4_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally4:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp3_ = umockdev_record_path;
	_tmp4_ = g_strconcat (_tmp3_, " -i /dev/zero=", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, log, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, " -- head -c1 /dev/zero", NULL);
	_tmp9_ = _tmp8_;
	spawn (_tmp9_, &_tmp10_, &_tmp11_, &_tmp12_);
	_g_free0 (sout);
	sout = _tmp10_;
	_g_free0 (serr);
	serr = _tmp11_;
	exit = _tmp12_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp13_ = serr;
	g_assert_cmpstr (_tmp13_, ==, "");
	_tmp14_ = exit;
	g_assert_cmpint (_tmp14_, ==, 0);
	_tmp15_ = sout;
	g_assert_cmpstr (_tmp15_, ==, "\0");
	_tmp16_ = file_contents (log);
	orig_contents = _tmp16_;
	_tmp17_ = umockdev_record_path;
	_tmp18_ = g_strconcat (_tmp17_, " -i /dev/null=", NULL);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_strconcat (_tmp19_, log, NULL);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_strconcat (_tmp21_, " -- head -c1 /dev/null", NULL);
	_tmp23_ = _tmp22_;
	spawn (_tmp23_, &_tmp24_, &_tmp25_, &_tmp26_);
	_g_free0 (sout);
	sout = _tmp24_;
	_g_free0 (serr);
	serr = _tmp25_;
	exit = _tmp26_;
	_g_free0 (_tmp23_);
	_g_free0 (_tmp21_);
	_g_free0 (_tmp19_);
	_tmp27_ = serr;
	_vala_assert (string_contains (_tmp27_, "two different devices"), "serr.contains (\"two different devices\")");
	_tmp28_ = exit;
	g_assert_cmpint (_tmp28_, ==, 256);
	_tmp29_ = sout;
	g_assert_cmpstr (_tmp29_, ==, "\0");
	_tmp30_ = file_contents (log);
	_tmp31_ = _tmp30_;
	g_assert_cmpstr (_tmp31_, ==, orig_contents);
	_g_free0 (_tmp31_);
	g_remove (log);
	_g_free0 (orig_contents);
	_g_free0 (log);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_script_log_simple (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* log = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	const gchar* _tmp13_;
	gint _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_ = NULL;
	gchar* _tmp26_ = NULL;
	gint _tmp27_ = 0;
	const gchar* _tmp28_;
	gint _tmp29_;
	const gchar* _tmp30_;
	gchar** loglines = NULL;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar** _tmp33_;
	gchar** _tmp34_;
	gchar** _tmp35_;
	gint _tmp35__length1;
	gint loglines_length1;
	gint _loglines_size_;
	const gchar* _tmp36_;
	gchar** logwords = NULL;
	const gchar* _tmp37_;
	gchar** _tmp38_;
	gchar** _tmp39_;
	gint logwords_length1;
	gint _logwords_size_;
	const gchar* _tmp40_;
	const gchar* _tmp41_;
	const gchar* _tmp42_;
	GError * _inner_error_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch5_g_error;
		}
		close (_tmp0_);
	}
	goto __finally5;
	__catch5_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally5:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp3_ = umockdev_record_path;
	_tmp4_ = g_strconcat (_tmp3_, " --script=/dev/null=", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, log, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, " -- head -c1 /dev/zero", NULL);
	_tmp9_ = _tmp8_;
	spawn (_tmp9_, &_tmp10_, &_tmp11_, &_tmp12_);
	_g_free0 (sout);
	sout = _tmp10_;
	_g_free0 (serr);
	serr = _tmp11_;
	exit = _tmp12_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp13_ = serr;
	g_assert_cmpstr (_tmp13_, ==, "");
	_tmp14_ = exit;
	g_assert_cmpint (_tmp14_, ==, 0);
	_tmp15_ = sout;
	g_assert_cmpstr (_tmp15_, ==, "\0");
	_tmp16_ = file_contents (log);
	_tmp17_ = _tmp16_;
	g_assert_cmpstr (_tmp17_, ==, "");
	_g_free0 (_tmp17_);
	_tmp18_ = umockdev_record_path;
	_tmp19_ = g_strconcat (_tmp18_, " --script=/dev/zero=", NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_strconcat (_tmp20_, log, NULL);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_strconcat (_tmp22_, " -- head -c1 /dev/zero", NULL);
	_tmp24_ = _tmp23_;
	spawn (_tmp24_, &_tmp25_, &_tmp26_, &_tmp27_);
	_g_free0 (sout);
	sout = _tmp25_;
	_g_free0 (serr);
	serr = _tmp26_;
	exit = _tmp27_;
	_g_free0 (_tmp24_);
	_g_free0 (_tmp22_);
	_g_free0 (_tmp20_);
	_tmp28_ = serr;
	g_assert_cmpstr (_tmp28_, ==, "");
	_tmp29_ = exit;
	g_assert_cmpint (_tmp29_, ==, 0);
	_tmp30_ = sout;
	g_assert_cmpstr (_tmp30_, ==, "\0");
	_tmp31_ = file_contents (log);
	_tmp32_ = _tmp31_;
	_tmp34_ = _tmp33_ = g_strsplit (_tmp32_, "\n", 0);
	_tmp35_ = _tmp34_;
	_tmp35__length1 = _vala_array_length (_tmp33_);
	_g_free0 (_tmp32_);
	loglines = _tmp35_;
	loglines_length1 = _tmp35__length1;
	_loglines_size_ = loglines_length1;
	g_assert_cmpuint ((guint) loglines_length1, ==, (guint) 2);
	_tmp36_ = loglines[0];
	g_assert_cmpstr (_tmp36_, ==, "d 0 /dev/zero");
	_tmp37_ = loglines[1];
	_tmp39_ = _tmp38_ = g_strsplit (_tmp37_, " ", 0);
	logwords = _tmp39_;
	logwords_length1 = _vala_array_length (_tmp38_);
	_logwords_size_ = logwords_length1;
	g_assert_cmpuint ((guint) logwords_length1, ==, (guint) 3);
	_tmp40_ = logwords[0];
	g_assert_cmpstr (_tmp40_, ==, "r");
	_tmp41_ = logwords[1];
	g_assert_cmpint (atoi (_tmp41_), <=, 5);
	_tmp42_ = logwords[2];
	g_assert_cmpstr (_tmp42_, ==, "^@");
	g_remove (log);
	logwords = (_vala_array_free (logwords, logwords_length1, (GDestroyNotify) g_free), NULL);
	loglines = (_vala_array_free (loglines, loglines_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (log);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_script_log_append_same_dev (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* log = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	const gchar* _tmp13_;
	gint _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	gint _tmp25_ = 0;
	const gchar* _tmp26_;
	gint _tmp27_;
	const gchar* _tmp28_;
	gchar** loglines = NULL;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar** _tmp31_;
	gchar** _tmp32_;
	gchar** _tmp33_;
	gint _tmp33__length1;
	gint loglines_length1;
	gint _loglines_size_;
	const gchar* _tmp34_;
	gchar** logwords = NULL;
	const gchar* _tmp35_;
	gchar** _tmp36_;
	gchar** _tmp37_;
	gint logwords_length1;
	gint _logwords_size_;
	gchar** _tmp38_;
	gint _tmp38__length1;
	gchar** _tmp39_;
	gint _tmp39__length1;
	const gchar* _tmp40_;
	gchar** _tmp41_;
	gint _tmp41__length1;
	const gchar* _tmp42_;
	gchar** _tmp43_;
	gint _tmp43__length1;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	gchar** _tmp46_;
	gchar** _tmp47_;
	gchar** _tmp48_;
	gint _tmp48__length1;
	gchar** _tmp49_;
	gint _tmp49__length1;
	const gchar* _tmp50_;
	gchar** _tmp51_;
	gint _tmp51__length1;
	const gchar* _tmp52_;
	gchar** _tmp53_;
	gint _tmp53__length1;
	const gchar* _tmp54_;
	GError * _inner_error_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch6_g_error;
		}
		close (_tmp0_);
	}
	goto __finally6;
	__catch6_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally6:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp3_ = umockdev_record_path;
	_tmp4_ = g_strconcat (_tmp3_, " --script=/dev/zero=", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, log, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, " -- head -c1 /dev/zero", NULL);
	_tmp9_ = _tmp8_;
	spawn (_tmp9_, &_tmp10_, &_tmp11_, &_tmp12_);
	_g_free0 (sout);
	sout = _tmp10_;
	_g_free0 (serr);
	serr = _tmp11_;
	exit = _tmp12_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp13_ = serr;
	g_assert_cmpstr (_tmp13_, ==, "");
	_tmp14_ = exit;
	g_assert_cmpint (_tmp14_, ==, 0);
	_tmp15_ = sout;
	g_assert_cmpstr (_tmp15_, ==, "\0");
	_tmp16_ = umockdev_record_path;
	_tmp17_ = g_strconcat (_tmp16_, " --script=/dev/zero=", NULL);
	_tmp18_ = _tmp17_;
	_tmp19_ = g_strconcat (_tmp18_, log, NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_strconcat (_tmp20_, " -- head -c1 /dev/zero", NULL);
	_tmp22_ = _tmp21_;
	spawn (_tmp22_, &_tmp23_, &_tmp24_, &_tmp25_);
	_g_free0 (sout);
	sout = _tmp23_;
	_g_free0 (serr);
	serr = _tmp24_;
	exit = _tmp25_;
	_g_free0 (_tmp22_);
	_g_free0 (_tmp20_);
	_g_free0 (_tmp18_);
	_tmp26_ = serr;
	g_assert_cmpstr (_tmp26_, ==, "");
	_tmp27_ = exit;
	g_assert_cmpint (_tmp27_, ==, 0);
	_tmp28_ = sout;
	g_assert_cmpstr (_tmp28_, ==, "\0");
	_tmp29_ = file_contents (log);
	_tmp30_ = _tmp29_;
	_tmp32_ = _tmp31_ = g_strsplit (_tmp30_, "\n", 0);
	_tmp33_ = _tmp32_;
	_tmp33__length1 = _vala_array_length (_tmp31_);
	_g_free0 (_tmp30_);
	loglines = _tmp33_;
	loglines_length1 = _tmp33__length1;
	_loglines_size_ = loglines_length1;
	g_assert_cmpuint ((guint) loglines_length1, ==, (guint) 3);
	_tmp34_ = loglines[0];
	g_assert_cmpstr (_tmp34_, ==, "d 0 /dev/zero");
	_tmp35_ = loglines[1];
	_tmp37_ = _tmp36_ = g_strsplit (_tmp35_, " ", 0);
	logwords = _tmp37_;
	logwords_length1 = _vala_array_length (_tmp36_);
	_logwords_size_ = logwords_length1;
	_tmp38_ = logwords;
	_tmp38__length1 = logwords_length1;
	g_assert_cmpuint ((guint) _tmp38__length1, ==, (guint) 3);
	_tmp39_ = logwords;
	_tmp39__length1 = logwords_length1;
	_tmp40_ = _tmp39_[0];
	g_assert_cmpstr (_tmp40_, ==, "r");
	_tmp41_ = logwords;
	_tmp41__length1 = logwords_length1;
	_tmp42_ = _tmp41_[1];
	g_assert_cmpint (atoi (_tmp42_), <=, 5);
	_tmp43_ = logwords;
	_tmp43__length1 = logwords_length1;
	_tmp44_ = _tmp43_[2];
	g_assert_cmpstr (_tmp44_, ==, "^@");
	_tmp45_ = loglines[2];
	_tmp47_ = _tmp46_ = g_strsplit (_tmp45_, " ", 0);
	logwords = (_vala_array_free (logwords, logwords_length1, (GDestroyNotify) g_free), NULL);
	logwords = _tmp47_;
	logwords_length1 = _vala_array_length (_tmp46_);
	_logwords_size_ = logwords_length1;
	_tmp48_ = logwords;
	_tmp48__length1 = logwords_length1;
	g_assert_cmpuint ((guint) _tmp48__length1, ==, (guint) 3);
	_tmp49_ = logwords;
	_tmp49__length1 = logwords_length1;
	_tmp50_ = _tmp49_[0];
	g_assert_cmpstr (_tmp50_, ==, "r");
	_tmp51_ = logwords;
	_tmp51__length1 = logwords_length1;
	_tmp52_ = _tmp51_[1];
	g_assert_cmpint (atoi (_tmp52_), <=, 5);
	_tmp53_ = logwords;
	_tmp53__length1 = logwords_length1;
	_tmp54_ = _tmp53_[2];
	g_assert_cmpstr (_tmp54_, ==, "^@");
	g_remove (log);
	logwords = (_vala_array_free (logwords, logwords_length1, (GDestroyNotify) g_free), NULL);
	loglines = (_vala_array_free (loglines, loglines_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (log);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_system_script_log_append_dev_mismatch (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* log = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	const gchar* _tmp13_;
	gint _tmp14_;
	const gchar* _tmp15_;
	gchar* orig_contents = NULL;
	gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	gint _tmp26_ = 0;
	const gchar* _tmp27_;
	gint _tmp28_;
	const gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	GError * _inner_error_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch7_g_error;
		}
		close (_tmp0_);
	}
	goto __finally7;
	__catch7_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally7:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp3_ = umockdev_record_path;
	_tmp4_ = g_strconcat (_tmp3_, " --script=/dev/zero=", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, log, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, " -- head -c1 /dev/zero", NULL);
	_tmp9_ = _tmp8_;
	spawn (_tmp9_, &_tmp10_, &_tmp11_, &_tmp12_);
	_g_free0 (sout);
	sout = _tmp10_;
	_g_free0 (serr);
	serr = _tmp11_;
	exit = _tmp12_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp13_ = serr;
	g_assert_cmpstr (_tmp13_, ==, "");
	_tmp14_ = exit;
	g_assert_cmpint (_tmp14_, ==, 0);
	_tmp15_ = sout;
	g_assert_cmpstr (_tmp15_, ==, "\0");
	_tmp16_ = file_contents (log);
	orig_contents = _tmp16_;
	_tmp17_ = umockdev_record_path;
	_tmp18_ = g_strconcat (_tmp17_, " --script=/dev/null=", NULL);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_strconcat (_tmp19_, log, NULL);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_strconcat (_tmp21_, " -- head -c1 /dev/null", NULL);
	_tmp23_ = _tmp22_;
	spawn (_tmp23_, &_tmp24_, &_tmp25_, &_tmp26_);
	_g_free0 (sout);
	sout = _tmp24_;
	_g_free0 (serr);
	serr = _tmp25_;
	exit = _tmp26_;
	_g_free0 (_tmp23_);
	_g_free0 (_tmp21_);
	_g_free0 (_tmp19_);
	_tmp27_ = serr;
	_vala_assert (string_contains (_tmp27_, "two different devices"), "serr.contains (\"two different devices\")");
	_tmp28_ = exit;
	g_assert_cmpint (_tmp28_, ==, 256);
	_tmp29_ = sout;
	g_assert_cmpstr (_tmp29_, ==, "\0");
	_tmp30_ = file_contents (log);
	_tmp31_ = _tmp30_;
	g_assert_cmpstr (_tmp31_, ==, orig_contents);
	_g_free0 (_tmp31_);
	g_remove (log);
	_g_free0 (orig_contents);
	_g_free0 (log);
	_g_free0 (serr);
	_g_free0 (sout);
}


gchar*
read_line_timeout (FILE* stream)
{
	gchar* result = NULL;
	gchar* line = NULL;
	gchar buffer[1000] = {0};
	gint timeout = 0;
	gint _tmp5_;
	gchar* _tmp6_;
	g_return_val_if_fail (stream != NULL, NULL);
	line = NULL;
	timeout = 50;
	while (TRUE) {
		gint _tmp0_;
		const gchar* _tmp1_;
		gchar* _tmp2_;
		const gchar* _tmp3_;
		gint _tmp4_;
		_tmp0_ = timeout;
		if (!(_tmp0_ > 0)) {
			break;
		}
		_tmp1_ = fgets (buffer, 1000, stream);
		_tmp2_ = g_strdup (_tmp1_);
		_g_free0 (line);
		line = _tmp2_;
		_tmp3_ = line;
		if (_tmp3_ != NULL) {
			result = line;
			return result;
		}
		g_usleep ((gulong) 100000);
		_tmp4_ = timeout;
		timeout = _tmp4_ - 1;
	}
	_tmp5_ = timeout;
	_vala_assert (_tmp5_ > 0, "timeout > 0");
	_tmp6_ = g_strdup ("<timeout>");
	result = _tmp6_;
	_g_free0 (line);
	return result;
}


void
t_system_script_log_chatter (void)
{
	gchar* log = NULL;
	gchar* ptyname = NULL;
	gchar* _tmp3_;
	gint ptyname_length1;
	gint _ptyname_size_;
	gint ptym = 0;
	gint ptys = 0;
	gint _tmp4_ = 0;
	gint _tmp5_ = 0;
	gint _tmp6_;
	struct termios ios = {0};
	struct termios _tmp7_ = {0};
	gint _tmp8_;
	tcflag_t _tmp9_;
	tcflag_t _tmp10_;
	tcflag_t _tmp11_;
	struct termios _tmp12_;
	GPid chatter_pid = 0;
	FILE* chatter_stream = NULL;
	FILE* _tmp30_;
	FILE* _tmp31_;
	FILE* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	FILE* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	FILE* _tmp38_;
	FILE* _tmp43_;
	FILE* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gint status = 0;
	gint _tmp47_ = 0;
	pid_t _tmp48_;
	FILE* log_stream = NULL;
	FILE* _tmp49_;
	gchar* buf = NULL;
	gchar* _tmp50_;
	gint buf_length1;
	gint _buf_size_;
	gint time = 0;
	GError * _inner_error_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch8_g_error;
		}
		close (_tmp0_);
	}
	goto __finally8;
	__catch8_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally8:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (log);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp3_ = g_new0 (gchar, 8192);
	ptyname = _tmp3_;
	ptyname_length1 = 8192;
	_ptyname_size_ = ptyname_length1;
	_tmp6_ = openpty (&_tmp4_, &_tmp5_, ptyname, NULL, NULL);
	ptym = _tmp4_;
	ptys = _tmp5_;
	_vala_assert (_tmp6_ == 0, "Linux.openpty (out ptym, out ptys, ptyname, null, null) == 0");
	close (ptys);
	_tmp8_ = tcgetattr (ptym, &_tmp7_);
	ios = _tmp7_;
	_vala_assert (_tmp8_ == 0, "Posix.tcgetattr (ptym, out ios) == 0");
	_tmp9_ = ios.c_iflag;
	ios.c_iflag = _tmp9_ & (~((IGNCR | INLCR) | ICRNL));
	_tmp10_ = ios.c_oflag;
	ios.c_oflag = _tmp10_ & (~(ONLCR | OCRNL));
	_tmp11_ = ios.c_lflag;
	ios.c_lflag = _tmp11_ & (~(ICANON | ECHO));
	_tmp12_ = ios;
	_vala_assert (tcsetattr (ptym, TCSANOW, &_tmp12_) == 0, "Posix.tcsetattr (ptym, Posix.TCSANOW, ios) == 0");
	{
		gboolean _tmp13_ = FALSE;
		const gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		const gchar* _tmp21_;
		gchar* _tmp22_;
		gchar* _tmp23_;
		gchar** _tmp24_;
		gchar** _tmp25_;
		gint _tmp25__length1;
		GPid _tmp26_ = 0;
		gboolean _tmp27_;
		gboolean _tmp28_;
		_tmp14_ = umockdev_record_path;
		_tmp15_ = g_strdup (_tmp14_);
		_tmp16_ = g_strdup ("--script");
		_tmp17_ = g_strconcat ((const gchar*) ptyname, "=", NULL);
		_tmp18_ = _tmp17_;
		_tmp19_ = g_strconcat (_tmp18_, log, NULL);
		_tmp20_ = g_strdup ("--");
		_tmp21_ = rootdir;
		_tmp22_ = g_build_filename (_tmp21_, "tests", "chatter", NULL);
		_tmp23_ = g_strdup ((const gchar*) ptyname);
		_tmp24_ = g_new0 (gchar*, 6 + 1);
		_tmp24_[0] = _tmp15_;
		_tmp24_[1] = _tmp16_;
		_tmp24_[2] = _tmp19_;
		_tmp24_[3] = _tmp20_;
		_tmp24_[4] = _tmp22_;
		_tmp24_[5] = _tmp23_;
		_tmp25_ = _tmp24_;
		_tmp25__length1 = 6;
		_tmp27_ = g_spawn_async_with_pipes (NULL, _tmp25_, NULL, (G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD) | G_SPAWN_STDOUT_TO_DEV_NULL, NULL, NULL, &_tmp26_, NULL, NULL, NULL, &_inner_error_);
		chatter_pid = _tmp26_;
		_tmp28_ = _tmp27_;
		_tmp25_ = (_vala_array_free (_tmp25_, _tmp25__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp18_);
		_tmp13_ = _tmp28_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_SPAWN_ERROR) {
				goto __catch9_g_spawn_error;
			}
			ptyname = (g_free (ptyname), NULL);
			_g_free0 (log);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_vala_assert (_tmp13_, "Process.spawn_async_with_pipes (null,             {umockdev_record_path, \"--script\", (string) ptyname + \"=\" + log, \"--\",              Path.build_filename (rootdir, \"tests\", \"chatter\"), (string) ptyname},             null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD | SpawnFlags.STDOUT_TO_DEV_NULL,             null, out chatter_pid, null, null, null)");
	}
	goto __finally9;
	__catch9_g_spawn_error:
	{
		GError* e = NULL;
		const gchar* _tmp29_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp29_ = e->message;
		g_error ("test-umockdev-record.vala:525: Cannot call umockdev-record: %s", _tmp29_);
		_g_error_free0 (e);
	}
	__finally9:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		ptyname = (g_free (ptyname), NULL);
		_g_free0 (log);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp30_ = fdopen (ptym, "r+");
	chatter_stream = _tmp30_;
	_tmp31_ = chatter_stream;
	_vala_assert (_tmp31_ != NULL, "chatter_stream != null");
	_tmp32_ = chatter_stream;
	_tmp33_ = read_line_timeout (_tmp32_);
	_tmp34_ = _tmp33_;
	g_assert_cmpstr (_tmp34_, ==, "Hello world!\n");
	_g_free0 (_tmp34_);
	_tmp35_ = chatter_stream;
	_tmp36_ = read_line_timeout (_tmp35_);
	_tmp37_ = _tmp36_;
	g_assert_cmpstr (_tmp37_, ==, "What is your name?\n");
	_g_free0 (_tmp37_);
	g_usleep ((gulong) 500000);
	_tmp38_ = chatter_stream;
	fputs ("John\n", _tmp38_);
	while (TRUE) {
		FILE* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_;
		gboolean _tmp42_;
		_tmp39_ = chatter_stream;
		_tmp40_ = read_line_timeout (_tmp39_);
		_tmp41_ = _tmp40_;
		_tmp42_ = !(!string_contains (_tmp41_, "line break in one write"));
		_g_free0 (_tmp41_);
		if (_tmp42_) {
			break;
		}
	}
	g_usleep ((gulong) 300000);
	_tmp43_ = chatter_stream;
	fputs ("foo ☹ bar ^!\n", _tmp43_);
	_tmp44_ = chatter_stream;
	_tmp45_ = read_line_timeout (_tmp44_);
	_tmp46_ = _tmp45_;
	g_assert_cmpstr (_tmp46_, ==, "bye!\n");
	_g_free0 (_tmp46_);
	_tmp48_ = waitpid ((pid_t) chatter_pid, &_tmp47_, 0);
	status = _tmp47_;
	g_assert_cmpint ((gint) _tmp48_, ==, (gint) chatter_pid);
	g_assert_cmpint (status, ==, 0);
	_tmp49_ = g_fopen (log, "r");
	log_stream = _tmp49_;
	_tmp50_ = g_new0 (gchar, 8192);
	buf = _tmp50_;
	buf_length1 = 8192;
	_buf_size_ = buf_length1;
	time = 0;
	g_assert_cmpint (fscanf (log_stream, "d 0 %s\n", buf), ==, 1);
	g_assert_cmpstr ((const gchar*) buf, ==, (const gchar*) ptyname);
	g_assert_cmpint (fscanf (log_stream, "w %d Hello world!^JWhat is your name?^J\n", &time), ==, 1);
	g_assert_cmpint (time, <=, 20);
	g_assert_cmpint (fscanf (log_stream, "r %d John^J\n", &time), ==, 1);
	g_assert_cmpint (time, >=, 450);
	g_assert_cmpint (time, <=, 800);
	g_assert_cmpint (fscanf (log_stream, "w %d I ♥ John^Ja^I tab and a^J line break in one write^J\n", &time), ==, 1);
	g_assert_cmpint (time, <=, 20);
	g_assert_cmpint (fscanf (log_stream, "r %d foo ☹ bar ^`!^J\n", &time), ==, 1);
	g_assert_cmpint (time, >=, 250);
	g_assert_cmpint (time, <=, 450);
	g_assert_cmpint (fscanf (log_stream, "w %d bye!^J\n", &time), ==, 1);
	g_assert_cmpint (time, <=, 20);
	g_assert_cmpint (fscanf (log_stream, "%*c"), ==, -1);
	g_remove (log);
	buf = (g_free (buf), NULL);
	_fclose0 (log_stream);
	_fclose0 (chatter_stream);
	ptyname = (g_free (ptyname), NULL);
	_g_free0 (log);
}


static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}


static guint8*
string_get_data (const gchar* self,
                 int* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	guint8* _tmp3_;
	gint _tmp3__length1;
	guint8* _tmp4_;
	gint _tmp4__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res_length1;
	_tmp3_ = res;
	_tmp3__length1 = res_length1;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp3__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}


void
t_system_script_log_chatter_socket_stream (void)
{
	gchar* log = NULL;
	gchar* spath = NULL;
	gchar* _tmp0_;
	GPid chatter_pid = 0;
	const gchar* _tmp77_;
	gint status = 0;
	GPid _tmp78_;
	gint _tmp79_ = 0;
	pid_t _tmp80_;
	GPid _tmp81_;
	FILE* log_stream = NULL;
	const gchar* _tmp82_;
	FILE* _tmp83_;
	gint time = 0;
	const gchar* _tmp84_;
	GError * _inner_error_ = NULL;
	_tmp0_ = g_strdup ("/tmp/umockdev_test");
	spath = _tmp0_;
	{
		gint _tmp1_ = 0;
		gchar* _tmp2_ = NULL;
		gint _tmp3_;
		GSocket* s = NULL;
		GSocket* _tmp4_;
		GSocket* _tmp5_;
		GSocket* _tmp6_;
		gboolean _tmp7_ = FALSE;
		GSocket* _tmp8_;
		const gchar* _tmp9_;
		GUnixSocketAddress* _tmp10_;
		GUnixSocketAddress* _tmp11_;
		gboolean _tmp12_;
		gboolean _tmp13_ = FALSE;
		GSocket* _tmp14_;
		gint timeout = 0;
		GSocket* conn = NULL;
		GSocket* _tmp44_;
		guint8* buf = NULL;
		guint8* _tmp45_;
		gint buf_length1;
		gint _buf_size_;
		gssize len = 0L;
		GSocket* _tmp46_;
		guint8* _tmp47_;
		gint _tmp47__length1;
		gssize _tmp48_;
		guint8* _tmp49_;
		gint _tmp49__length1;
		gssize _tmp50_;
		guint8 _tmp51_;
		guint8* _tmp52_;
		gint _tmp52__length1;
		GSocket* _tmp53_;
		guint8* _tmp54_;
		gint _tmp54__length1;
		guint8* _tmp55_;
		gint _tmp55__length1;
		gssize _tmp56_ = 0L;
		GSocket* _tmp57_;
		guint8* _tmp58_;
		gint _tmp58__length1;
		gssize _tmp59_;
		guint8* _tmp60_;
		gint _tmp60__length1;
		gssize _tmp61_;
		guint8 _tmp62_;
		guint8* _tmp63_;
		gint _tmp63__length1;
		gssize _tmp64_ = 0L;
		GSocket* _tmp65_;
		guint8* _tmp66_;
		gint _tmp66__length1;
		gssize _tmp67_;
		guint8* _tmp68_;
		gint _tmp68__length1;
		gssize _tmp69_;
		guint8 _tmp70_;
		guint8* _tmp71_;
		gint _tmp71__length1;
		GSocket* _tmp72_;
		guint8* _tmp73_;
		gint _tmp73__length1;
		guint8* _tmp74_;
		gint _tmp74__length1;
		_tmp3_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp2_, &_inner_error_);
		_g_free0 (log);
		log = _tmp2_;
		_tmp1_ = _tmp3_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch10_g_error;
		}
		close (_tmp1_);
		_tmp4_ = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &_inner_error_);
		s = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch10_g_error;
		}
		_tmp5_ = s;
		_vala_assert (_tmp5_ != NULL, "s != null");
		_tmp6_ = s;
		g_socket_set_blocking (_tmp6_, FALSE);
		_tmp8_ = s;
		_tmp9_ = spath;
		_tmp10_ = (GUnixSocketAddress*) g_unix_socket_address_new (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = g_socket_bind (_tmp8_, (GSocketAddress*) _tmp11_, TRUE, &_inner_error_);
		_g_object_unref0 (_tmp11_);
		_tmp7_ = _tmp12_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		_vala_assert (_tmp7_, "s.bind (new UnixSocketAddress (spath), true)");
		_tmp14_ = s;
		_tmp13_ = g_socket_listen (_tmp14_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		_vala_assert (_tmp13_, "s.listen ()");
		{
			gboolean _tmp15_ = FALSE;
			const gchar* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			const gchar* _tmp19_;
			gchar* _tmp20_;
			gchar* _tmp21_;
			const gchar* _tmp22_;
			gchar* _tmp23_;
			gchar* _tmp24_;
			const gchar* _tmp25_;
			gchar* _tmp26_;
			const gchar* _tmp27_;
			gchar* _tmp28_;
			gchar** _tmp29_;
			gchar** _tmp30_;
			gint _tmp30__length1;
			GPid _tmp31_ = 0;
			gboolean _tmp32_;
			gboolean _tmp33_;
			_tmp16_ = umockdev_record_path;
			_tmp17_ = g_strdup (_tmp16_);
			_tmp18_ = g_strdup ("--script");
			_tmp19_ = spath;
			_tmp20_ = g_strconcat (_tmp19_, "=", NULL);
			_tmp21_ = _tmp20_;
			_tmp22_ = log;
			_tmp23_ = g_strconcat (_tmp21_, _tmp22_, NULL);
			_tmp24_ = g_strdup ("--");
			_tmp25_ = rootdir;
			_tmp26_ = g_build_filename (_tmp25_, "tests", "chatter-socket-stream", NULL);
			_tmp27_ = spath;
			_tmp28_ = g_strdup (_tmp27_);
			_tmp29_ = g_new0 (gchar*, 6 + 1);
			_tmp29_[0] = _tmp17_;
			_tmp29_[1] = _tmp18_;
			_tmp29_[2] = _tmp23_;
			_tmp29_[3] = _tmp24_;
			_tmp29_[4] = _tmp26_;
			_tmp29_[5] = _tmp28_;
			_tmp30_ = _tmp29_;
			_tmp30__length1 = 6;
			_tmp32_ = g_spawn_async_with_pipes (NULL, _tmp30_, NULL, (G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD) | G_SPAWN_STDOUT_TO_DEV_NULL, NULL, NULL, &_tmp31_, NULL, NULL, NULL, &_inner_error_);
			chatter_pid = _tmp31_;
			_tmp33_ = _tmp32_;
			_tmp30_ = (_vala_array_free (_tmp30_, _tmp30__length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (_tmp21_);
			_tmp15_ = _tmp33_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				if (_inner_error_->domain == G_SPAWN_ERROR) {
					goto __catch11_g_spawn_error;
				}
				_g_object_unref0 (s);
				_g_free0 (spath);
				_g_free0 (log);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
			_vala_assert (_tmp15_, "Process.spawn_async_with_pipes (null,                 {umockdev_record_path, \"--script\", spath + \"=\" + log, \"--\",                  Path.build_filename (rootdir, \"tests\", \"chatter-socket-stream\"), spath},                 null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD | SpawnFlags.STDOUT_TO_DEV_NULL,                 null, out chatter_pid, null, null, null)");
		}
		goto __finally11;
		__catch11_g_spawn_error:
		{
			GError* e = NULL;
			const gchar* _tmp34_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp34_ = e->message;
			g_error ("test-umockdev-record.vala:604: Cannot call umockdev-record: %s", _tmp34_);
			_g_error_free0 (e);
		}
		__finally11:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		timeout = 20;
		conn = NULL;
		while (TRUE) {
			gint _tmp35_;
			_tmp35_ = timeout;
			if (!(_tmp35_ > 0)) {
				break;
			}
			{
				GSocket* _tmp36_ = NULL;
				GSocket* _tmp37_;
				GSocket* _tmp38_;
				GSocket* _tmp39_;
				_tmp37_ = s;
				_tmp38_ = g_socket_accept (_tmp37_, NULL, &_inner_error_);
				_tmp36_ = _tmp38_;
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					if (_inner_error_->domain == G_IO_ERROR) {
						goto __catch12_g_io_error;
					}
					goto __finally12;
				}
				_tmp39_ = _tmp36_;
				_tmp36_ = NULL;
				_g_object_unref0 (conn);
				conn = _tmp39_;
				_g_object_unref0 (_tmp36_);
				break;
			}
			goto __finally12;
			__catch12_g_io_error:
			{
				GError* e = NULL;
				GError* _tmp40_;
				e = _inner_error_;
				_inner_error_ = NULL;
				_tmp40_ = e;
				if (g_error_matches (_tmp40_, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
					gint _tmp41_;
					_tmp41_ = timeout;
					timeout = _tmp41_ - 1;
					g_usleep ((gulong) 10000);
				} else {
					GError* _tmp42_;
					GError* _tmp43_;
					_tmp42_ = e;
					_tmp43_ = _g_error_copy0 (_tmp42_);
					_inner_error_ = _tmp43_;
					_g_error_free0 (e);
					goto __finally12;
				}
				_g_error_free0 (e);
			}
			__finally12:
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_object_unref0 (conn);
				_g_object_unref0 (s);
				goto __catch10_g_error;
			}
		}
		_tmp44_ = conn;
		_vala_assert (_tmp44_ != NULL, "conn != null");
		_tmp45_ = g_new0 (guint8, 1000);
		buf = _tmp45_;
		buf_length1 = 1000;
		_buf_size_ = buf_length1;
		_tmp46_ = conn;
		_tmp47_ = buf;
		_tmp47__length1 = buf_length1;
		len = g_socket_receive (_tmp46_, _tmp47_, (gsize) _tmp47__length1, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		_tmp48_ = len;
		_vala_assert (_tmp48_ > ((gssize) 0), "len > 0");
		_tmp49_ = buf;
		_tmp49__length1 = buf_length1;
		_tmp50_ = len;
		_tmp49_[_tmp50_] = (guint8) 0;
		_tmp51_ = _tmp49_[_tmp50_];
		_tmp52_ = buf;
		_tmp52__length1 = buf_length1;
		g_assert_cmpstr ((const gchar*) _tmp52_, ==, "What is your name?\n");
		g_usleep ((gulong) 300000);
		_tmp53_ = conn;
		_tmp54_ = string_get_data ("John\n", &_tmp54__length1);
		_tmp55_ = _tmp54_;
		_tmp55__length1 = _tmp54__length1;
		g_socket_send (_tmp53_, _tmp55_, (gsize) _tmp55__length1, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		g_usleep ((gulong) 10000);
		_tmp57_ = conn;
		_tmp58_ = buf;
		_tmp58__length1 = buf_length1;
		_tmp56_ = g_socket_receive (_tmp57_, _tmp58_, (gsize) _tmp58__length1, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		len = _tmp56_;
		_tmp59_ = len;
		_vala_assert (_tmp59_ > ((gssize) 0), "len > 0");
		_tmp60_ = buf;
		_tmp60__length1 = buf_length1;
		_tmp61_ = len;
		_tmp60_[_tmp61_] = (guint8) 0;
		_tmp62_ = _tmp60_[_tmp61_];
		_tmp63_ = buf;
		_tmp63__length1 = buf_length1;
		g_assert_cmpstr ((const gchar*) _tmp63_, ==, "hello John\n");
		g_usleep ((gulong) 20000);
		_tmp65_ = conn;
		_tmp66_ = buf;
		_tmp66__length1 = buf_length1;
		_tmp64_ = g_socket_receive (_tmp65_, _tmp66_, (gsize) _tmp66__length1, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		len = _tmp64_;
		_tmp67_ = len;
		_vala_assert (_tmp67_ > ((gssize) 0), "len > 0");
		_tmp68_ = buf;
		_tmp68__length1 = buf_length1;
		_tmp69_ = len;
		_tmp68_[_tmp69_] = (guint8) 0;
		_tmp70_ = _tmp68_[_tmp69_];
		_tmp71_ = buf;
		_tmp71__length1 = buf_length1;
		g_assert_cmpstr ((const gchar*) _tmp71_, ==, "send()");
		g_usleep ((gulong) 20000);
		_tmp72_ = conn;
		_tmp73_ = string_get_data ("recv()", &_tmp73__length1);
		_tmp74_ = _tmp73_;
		_tmp74__length1 = _tmp73__length1;
		g_socket_send (_tmp72_, _tmp74_, (gsize) _tmp74__length1, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch10_g_error;
		}
		buf = (g_free (buf), NULL);
		_g_object_unref0 (conn);
		_g_object_unref0 (s);
	}
	goto __finally10;
	__catch10_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp75_;
		const gchar* _tmp76_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp75_ = spath;
		g_remove (_tmp75_);
		_tmp76_ = e->message;
		g_error ("test-umockdev-record.vala:655: Error: %s", _tmp76_);
		_g_error_free0 (e);
	}
	__finally10:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (spath);
		_g_free0 (log);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp77_ = spath;
	g_remove (_tmp77_);
	_tmp78_ = chatter_pid;
	_tmp80_ = waitpid ((pid_t) _tmp78_, &_tmp79_, 0);
	status = _tmp79_;
	_tmp81_ = chatter_pid;
	g_assert_cmpint ((gint) _tmp80_, ==, (gint) _tmp81_);
	g_assert_cmpint (status, ==, 0);
	_tmp82_ = log;
	_tmp83_ = g_fopen (_tmp82_, "r");
	log_stream = _tmp83_;
	time = 0;
	g_assert_cmpint (fscanf (log_stream, "w %d What is your name?^J\n", &time), ==, 1);
	g_assert_cmpint (time, <=, 20);
	g_assert_cmpint (fscanf (log_stream, "r %d John^J\n", &time), ==, 1);
	g_assert_cmpint (time, >=, 250);
	g_assert_cmpint (time, <=, 400);
	g_assert_cmpint (fscanf (log_stream, "w %d hello John^J\n", &time), ==, 1);
	g_assert_cmpint (time, <=, 20);
	g_assert_cmpint (fscanf (log_stream, "w %d send()\n", &time), ==, 1);
	g_assert_cmpint (time, >=, 10);
	g_assert_cmpint (fscanf (log_stream, "r %d recv()\n", &time), ==, 1);
	g_assert_cmpint (time, >=, 20);
	g_assert_cmpint (time, <=, 60);
	_tmp84_ = log;
	g_remove (_tmp84_);
	_fclose0 (log_stream);
	_g_free0 (spath);
	_g_free0 (log);
}


void
t_system_evemu_log (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* workdir = NULL;
	gchar* log = NULL;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_ = NULL;
	gint _tmp13_ = 0;
	const gchar* _tmp14_;
	gint _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_ = NULL;
	gchar* _tmp27_ = NULL;
	gint _tmp28_ = 0;
	const gchar* _tmp29_;
	gint _tmp30_;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	const gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_ = NULL;
	gchar* _tmp42_ = NULL;
	gint _tmp43_ = 0;
	const gchar* _tmp44_;
	gint _tmp45_;
	const gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	const gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_ = NULL;
	gchar* _tmp53_ = NULL;
	gint _tmp54_ = 0;
	gint _tmp55_;
	const gchar* _tmp56_;
	const gchar* _tmp57_;
	const gchar* _tmp58_;
	GError * _inner_error_ = NULL;
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = g_dir_make_tmp ("evemu_log_test.XXXXXX", &_inner_error_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch13_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_free0 (workdir);
		workdir = _tmp2_;
		_g_free0 (_tmp0_);
	}
	goto __finally13;
	__catch13_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally13:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (workdir);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp3_ = g_build_filename (workdir, "log", NULL);
	log = _tmp3_;
	_tmp4_ = umockdev_record_path;
	_tmp5_ = g_strconcat (_tmp4_, " --evemu-events=/dev/null=", NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strconcat (_tmp6_, log, NULL);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strconcat (_tmp8_, " -- head -c1 /dev/null", NULL);
	_tmp10_ = _tmp9_;
	spawn (_tmp10_, &_tmp11_, &_tmp12_, &_tmp13_);
	_g_free0 (sout);
	sout = _tmp11_;
	_g_free0 (serr);
	serr = _tmp12_;
	exit = _tmp13_;
	_g_free0 (_tmp10_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_tmp14_ = serr;
	g_assert_cmpstr (_tmp14_, ==, "");
	_tmp15_ = exit;
	g_assert_cmpint (_tmp15_, ==, 0);
	_tmp16_ = sout;
	g_assert_cmpstr (_tmp16_, ==, "\0");
	_tmp17_ = file_contents (log);
	_tmp18_ = _tmp17_;
	g_assert_cmpstr (_tmp18_, ==, "# EVEMU 1.2\n# device /dev/null\n");
	_g_free0 (_tmp18_);
	_tmp19_ = umockdev_record_path;
	_tmp20_ = g_strconcat (_tmp19_, " --evemu-events=/dev/null=", NULL);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_strconcat (_tmp21_, log, NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strconcat (_tmp23_, " -- head -c1 /dev/null", NULL);
	_tmp25_ = _tmp24_;
	spawn (_tmp25_, &_tmp26_, &_tmp27_, &_tmp28_);
	_g_free0 (sout);
	sout = _tmp26_;
	_g_free0 (serr);
	serr = _tmp27_;
	exit = _tmp28_;
	_g_free0 (_tmp25_);
	_g_free0 (_tmp23_);
	_g_free0 (_tmp21_);
	_tmp29_ = serr;
	g_assert_cmpstr (_tmp29_, ==, "");
	_tmp30_ = exit;
	g_assert_cmpint (_tmp30_, ==, 0);
	_tmp31_ = sout;
	g_assert_cmpstr (_tmp31_, ==, "\0");
	_tmp32_ = file_contents (log);
	_tmp33_ = _tmp32_;
	g_assert_cmpstr (_tmp33_, ==, "# EVEMU 1.2\n# device /dev/null\n\n");
	_g_free0 (_tmp33_);
	_tmp34_ = umockdev_record_path;
	_tmp35_ = g_strconcat (_tmp34_, " --evemu-events=/dev/zero=", NULL);
	_tmp36_ = _tmp35_;
	_tmp37_ = g_strconcat (_tmp36_, log, NULL);
	_tmp38_ = _tmp37_;
	_tmp39_ = g_strconcat (_tmp38_, " -- head -c1 /dev/zero", NULL);
	_tmp40_ = _tmp39_;
	spawn (_tmp40_, &_tmp41_, &_tmp42_, &_tmp43_);
	_g_free0 (sout);
	sout = _tmp41_;
	_g_free0 (serr);
	serr = _tmp42_;
	exit = _tmp43_;
	_g_free0 (_tmp40_);
	_g_free0 (_tmp38_);
	_g_free0 (_tmp36_);
	_tmp44_ = serr;
	_vala_assert (string_contains (_tmp44_, "two different devices"), "serr.contains (\"two different devices\")");
	_tmp45_ = exit;
	g_assert_cmpint (_tmp45_, ==, 256);
	_tmp46_ = sout;
	g_assert_cmpstr (_tmp46_, ==, "\0");
	_tmp47_ = file_contents (log);
	_tmp48_ = _tmp47_;
	g_assert_cmpstr (_tmp48_, ==, "# EVEMU 1.2\n# device /dev/null\n\n");
	_g_free0 (_tmp48_);
	g_remove (log);
	_tmp49_ = umockdev_record_path;
	_tmp50_ = g_strconcat (_tmp49_, " --evemu-events /dev/null -- true", NULL);
	_tmp51_ = _tmp50_;
	spawn (_tmp51_, &_tmp52_, &_tmp53_, &_tmp54_);
	_g_free0 (sout);
	sout = _tmp52_;
	_g_free0 (serr);
	serr = _tmp53_;
	exit = _tmp54_;
	_g_free0 (_tmp51_);
	_tmp55_ = exit;
	g_assert_cmpint (_tmp55_, !=, 1);
	_tmp56_ = sout;
	g_assert_cmpstr (_tmp56_, ==, "");
	_tmp57_ = serr;
	_vala_assert (string_contains (_tmp57_, "--ioctl"), "serr.contains (\"--ioctl\")");
	_tmp58_ = serr;
	_vala_assert (string_contains (_tmp58_, "="), "serr.contains (\"=\")");
	_vala_assert (!g_file_test (log, G_FILE_TEST_EXISTS), "!FileUtils.test (log, FileTest.EXISTS)");
	g_rmdir (workdir);
	_g_free0 (log);
	_g_free0 (workdir);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_run_invalid_args (void)
{
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gint _tmp5_ = 0;
	_tmp0_ = umockdev_record_path;
	_tmp1_ = g_strconcat (_tmp0_, " /dev/no/such/device", NULL);
	_tmp2_ = _tmp1_;
	spawn (_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_);
	_g_free0 (sout);
	sout = _tmp3_;
	_g_free0 (serr);
	serr = _tmp4_;
	exit = _tmp5_;
	_g_free0 (_tmp2_);
	assert_in ("Cannot access device /dev/no/such/device: No such file", serr);
	g_assert_cmpstr (sout, ==, "");
	g_assert_cmpint (exit, !=, 0);
	_g_free0 (serr);
	_g_free0 (sout);
}


void
t_gphoto2_record (void)
{
	gchar* sout = NULL;
	gchar* sout_record = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gint _tmp3_;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gint _tmp8_ = 0;
	gint _tmp9_;
	GRegex* port_re = NULL;
	GMatchInfo* match = NULL;
	GRegex* _tmp19_;
	const gchar* _tmp20_;
	GMatchInfo* _tmp21_ = NULL;
	gboolean _tmp22_;
	gchar* busnum = NULL;
	GMatchInfo* _tmp24_;
	gchar* _tmp25_;
	gchar* devnum = NULL;
	GMatchInfo* _tmp26_;
	gchar* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_ = NULL;
	gchar* _tmp34_ = NULL;
	gint _tmp35_ = 0;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	gint _tmp38_;
	gchar* cmd = NULL;
	gchar* _tmp39_;
	const gchar* _tmp40_;
	const gchar* _tmp41_;
	const gchar* _tmp42_;
	const gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_ = NULL;
	gchar* _tmp47_ = NULL;
	gint _tmp48_ = 0;
	const gchar* _tmp49_;
	gint _tmp50_;
	const gchar* _tmp51_;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	const gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_ = NULL;
	gchar* _tmp58_ = NULL;
	gint _tmp59_ = 0;
	const gchar* _tmp60_;
	gint _tmp61_;
	const gchar* _tmp62_;
	const gchar* _tmp63_;
	GError * _inner_error_ = NULL;
	spawn ("which gphoto2", &_tmp0_, &_tmp1_, &_tmp2_);
	_g_free0 (sout);
	sout = _tmp0_;
	_g_free0 (serr);
	serr = _tmp1_;
	exit = _tmp2_;
	_tmp3_ = exit;
	if (_tmp3_ != 0) {
		FILE* _tmp4_;
		FILE* _tmp5_;
		_tmp4_ = stdout;
		fprintf (_tmp4_, "[SKIP: gphoto2 not installed] ");
		_tmp5_ = stdout;
		fflush (_tmp5_);
		_g_free0 (serr);
		_g_free0 (sout_record);
		_g_free0 (sout);
		return;
	}
	spawn ("gphoto2 --auto-detect", &_tmp6_, &_tmp7_, &_tmp8_);
	_g_free0 (sout);
	sout = _tmp6_;
	_g_free0 (serr);
	serr = _tmp7_;
	exit = _tmp8_;
	_tmp9_ = exit;
	if (_tmp9_ != 0) {
		FILE* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		_tmp10_ = stdout;
		_tmp11_ = sout;
		_tmp12_ = serr;
		_tmp13_ = g_strconcat (_tmp11_, _tmp12_, NULL);
		_tmp14_ = _tmp13_;
		fprintf (_tmp10_, "[SKIP: gphoto2 --auto-detect failed: %s] ", _tmp14_);
		_g_free0 (_tmp14_);
		_g_free0 (serr);
		_g_free0 (sout_record);
		_g_free0 (sout);
		return;
	}
	{
		GRegex* _tmp15_ = NULL;
		GRegex* _tmp16_;
		GRegex* _tmp17_;
		_tmp16_ = g_regex_new ("usb:([0-9]+),([0-9]+)", 0, 0, &_inner_error_);
		_tmp15_ = _tmp16_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch14_g_regex_error;
			}
			_g_regex_unref0 (port_re);
			_g_free0 (serr);
			_g_free0 (sout_record);
			_g_free0 (sout);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_tmp17_ = _tmp15_;
		_tmp15_ = NULL;
		_g_regex_unref0 (port_re);
		port_re = _tmp17_;
		_g_regex_unref0 (_tmp15_);
	}
	goto __finally14;
	__catch14_g_regex_error:
	{
		GError* e = NULL;
		const gchar* _tmp18_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp18_ = e->message;
		g_error ("test-umockdev-record.vala:780: Internal error building regex: %s", _tmp18_);
		_g_error_free0 (e);
	}
	__finally14:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_regex_unref0 (port_re);
		_g_free0 (serr);
		_g_free0 (sout_record);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp19_ = port_re;
	_tmp20_ = sout;
	_tmp22_ = g_regex_match (_tmp19_, _tmp20_, 0, &_tmp21_);
	_g_match_info_unref0 (match);
	match = _tmp21_;
	if (!_tmp22_) {
		FILE* _tmp23_;
		_tmp23_ = stdout;
		fprintf (_tmp23_, "[SKIP: no gphoto2 compatible camera attached] ");
		_g_match_info_unref0 (match);
		_g_regex_unref0 (port_re);
		_g_free0 (serr);
		_g_free0 (sout_record);
		_g_free0 (sout);
		return;
	}
	_tmp24_ = match;
	_tmp25_ = g_match_info_fetch (_tmp24_, 1);
	busnum = _tmp25_;
	_tmp26_ = match;
	_tmp27_ = g_match_info_fetch (_tmp26_, 2);
	devnum = _tmp27_;
	_tmp28_ = umockdev_record_path;
	_tmp29_ = busnum;
	_tmp30_ = devnum;
	_tmp31_ = g_strdup_printf ("sh -c '%s /dev/bus/usb/%s/%s > gphoto-test.umockdev'", _tmp28_, _tmp29_, _tmp30_);
	_tmp32_ = _tmp31_;
	spawn (_tmp32_, &_tmp33_, &_tmp34_, &_tmp35_);
	_g_free0 (sout);
	sout = _tmp33_;
	_g_free0 (serr);
	serr = _tmp34_;
	exit = _tmp35_;
	_g_free0 (_tmp32_);
	_tmp36_ = serr;
	g_assert_cmpstr (_tmp36_, ==, "");
	_tmp37_ = sout;
	g_assert_cmpstr (_tmp37_, ==, "");
	_tmp38_ = exit;
	g_assert_cmpint (_tmp38_, ==, 0);
	_tmp39_ = g_strdup ("sh -c 'gphoto2 -l; gphoto2 -L'");
	cmd = _tmp39_;
	_tmp40_ = umockdev_record_path;
	_tmp41_ = busnum;
	_tmp42_ = devnum;
	_tmp43_ = cmd;
	_tmp44_ = g_strdup_printf ("%s -i /dev/bus/usb/%s/%s=gphoto-test.ioctl -- %s", _tmp40_, _tmp41_, _tmp42_, _tmp43_);
	_tmp45_ = _tmp44_;
	spawn (_tmp45_, &_tmp46_, &_tmp47_, &_tmp48_);
	_g_free0 (sout_record);
	sout_record = _tmp46_;
	_g_free0 (serr);
	serr = _tmp47_;
	exit = _tmp48_;
	_g_free0 (_tmp45_);
	_tmp49_ = serr;
	g_assert_cmpstr (_tmp49_, ==, "");
	_tmp50_ = exit;
	g_assert_cmpint (_tmp50_, ==, 0);
	_tmp51_ = umockdev_run_path;
	_tmp52_ = busnum;
	_tmp53_ = devnum;
	_tmp54_ = cmd;
	_tmp55_ = g_strdup_printf ("%s -d gphoto-test.umockdev -i /dev/bus/usb/%s/%s=gphoto-test.ioctl -- " \
"%s", _tmp51_, _tmp52_, _tmp53_, _tmp54_);
	_tmp56_ = _tmp55_;
	spawn (_tmp56_, &_tmp57_, &_tmp58_, &_tmp59_);
	_g_free0 (sout);
	sout = _tmp57_;
	_g_free0 (serr);
	serr = _tmp58_;
	exit = _tmp59_;
	_g_free0 (_tmp56_);
	_tmp60_ = serr;
	g_assert_cmpstr (_tmp60_, ==, "");
	_tmp61_ = exit;
	g_assert_cmpint (_tmp61_, ==, 0);
	_tmp62_ = sout;
	_tmp63_ = sout_record;
	g_assert_cmpstr (_tmp62_, ==, _tmp63_);
	g_remove ("gphoto-test.umockdev");
	g_remove ("gphoto-test.ioctl");
	_g_free0 (cmd);
	_g_free0 (devnum);
	_g_free0 (busnum);
	_g_match_info_unref0 (match);
	_g_regex_unref0 (port_re);
	_g_free0 (serr);
	_g_free0 (sout_record);
	_g_free0 (sout);
}


static void
_t_testbed_all_empty_gtest_func (void)
{
	t_testbed_all_empty ();
}


static void
_t_testbed_one_gtest_func (void)
{
	t_testbed_one ();
}


static void
_t_testbed_multiple_gtest_func (void)
{
	t_testbed_multiple ();
}


static void
_t_testbed_no_ioctl_record_gtest_func (void)
{
	t_testbed_no_ioctl_record ();
}


static void
_t_system_single_gtest_func (void)
{
	t_system_single ();
}


static void
_t_system_invalid_gtest_func (void)
{
	t_system_invalid ();
}


static void
_t_system_ioctl_log_gtest_func (void)
{
	t_system_ioctl_log ();
}


static void
_t_system_ioctl_log_append_dev_mismatch_gtest_func (void)
{
	t_system_ioctl_log_append_dev_mismatch ();
}


static void
_t_system_script_log_simple_gtest_func (void)
{
	t_system_script_log_simple ();
}


static void
_t_system_script_log_append_same_dev_gtest_func (void)
{
	t_system_script_log_append_same_dev ();
}


static void
_t_system_script_log_append_dev_mismatch_gtest_func (void)
{
	t_system_script_log_append_dev_mismatch ();
}


static void
_t_system_script_log_chatter_gtest_func (void)
{
	t_system_script_log_chatter ();
}


static void
_t_system_script_log_chatter_socket_stream_gtest_func (void)
{
	t_system_script_log_chatter_socket_stream ();
}


static void
_t_system_evemu_log_gtest_func (void)
{
	t_system_evemu_log ();
}


static void
_t_run_invalid_args_gtest_func (void)
{
	t_run_invalid_args ();
}


static void
_t_gphoto2_record_gtest_func (void)
{
	t_gphoto2_record ();
}


gint
_vala_main (gchar** args,
            int args_length1)
{
	gint result = 0;
	gchar* r = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_getenv ("TOP_BUILDDIR");
	_tmp1_ = g_strdup (_tmp0_);
	r = _tmp1_;
	_tmp2_ = r;
	if (_tmp2_ == NULL) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = args[0];
		_tmp4_ = realpath (_tmp3_, NULL);
		_tmp5_ = _tmp4_;
		_tmp6_ = g_path_get_dirname (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_path_get_dirname (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_path_get_dirname (_tmp9_);
		_g_free0 (rootdir);
		rootdir = _tmp10_;
		_g_free0 (_tmp9_);
		_g_free0 (_tmp7_);
		_g_free0 (_tmp5_);
	} else {
		const gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp11_ = r;
		_tmp12_ = g_strdup (_tmp11_);
		_g_free0 (rootdir);
		rootdir = _tmp12_;
	}
	_tmp13_ = rootdir;
	_tmp14_ = g_build_filename (_tmp13_, "src", "umockdev-record", NULL);
	_g_free0 (umockdev_record_path);
	umockdev_record_path = _tmp14_;
	_tmp15_ = rootdir;
	_tmp16_ = g_build_filename (_tmp15_, "src", "umockdev-run", NULL);
	_g_free0 (umockdev_run_path);
	umockdev_run_path = _tmp16_;
	g_test_add_func ("/umockdev-record/testbed-all-empty", _t_testbed_all_empty_gtest_func);
	g_test_add_func ("/umockdev-record/testbed-one", _t_testbed_one_gtest_func);
	g_test_add_func ("/umockdev-record/testbed-multiple", _t_testbed_multiple_gtest_func);
	g_test_add_func ("/umockdev-record/testbed-no-ioctl-record", _t_testbed_no_ioctl_record_gtest_func);
	g_test_add_func ("/umockdev-record/system-single", _t_system_single_gtest_func);
	g_test_add_func ("/umockdev-record/system-invalid", _t_system_invalid_gtest_func);
	g_test_add_func ("/umockdev-record/ioctl-log", _t_system_ioctl_log_gtest_func);
	g_test_add_func ("/umockdev-record/ioctl-log-append-dev-mismatch", _t_system_ioctl_log_append_dev_mismatch_gtest_func);
	g_test_add_func ("/umockdev-record/script-log-simple", _t_system_script_log_simple_gtest_func);
	g_test_add_func ("/umockdev-record/script-log-append-same-dev", _t_system_script_log_append_same_dev_gtest_func);
	g_test_add_func ("/umockdev-record/script-log-append-dev-mismatch", _t_system_script_log_append_dev_mismatch_gtest_func);
	g_test_add_func ("/umockdev-record/script-log-chatter", _t_system_script_log_chatter_gtest_func);
	g_test_add_func ("/umockdev-record/script-log-socket", _t_system_script_log_chatter_socket_stream_gtest_func);
	g_test_add_func ("/umockdev-record/evemu-log", _t_system_evemu_log_gtest_func);
	g_test_add_func ("/umockdev-record/invalid-args", _t_run_invalid_args_gtest_func);
	g_test_add_func ("/umockdev-record/gphoto2-record", _t_gphoto2_record_gtest_func);
	result = g_test_run ();
	_g_free0 (r);
	return result;
}


int
main (int argc,
      char ** argv)
{
	return _vala_main (argv, argc);
}


static void
_vala_array_destroy (gpointer array,
                     gint array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void
_vala_array_free (gpointer array,
                  gint array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint
_vala_array_length (gpointer array)
{
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



