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

/*
 * test-umockdev-record.vala
 *
 * Copyright (C) 2013 Canonical Ltd.
 * Copyright (C) 2018 Martin Pitt
 * 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 <stdlib.h>
#include <string.h>
#include <glib.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* readbyte_path;
gchar* readbyte_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_simple_fopen (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,
                 gint 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_simple_fopen_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_error0_ = 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_error0_);
		_g_free0 (_vala_sout);
		_vala_sout = _tmp1_;
		_g_free0 (_vala_serr);
		_vala_serr = _tmp2_;
		_vala_exit = _tmp3_;
		_tmp0_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_SPAWN_ERROR) {
				goto __catch0_g_spawn_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			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_error0_;
		_inner_error0_ = NULL;
		_tmp5_ = e->message;
		g_error ("test-umockdev-record.vala:36: Cannot call '%s': %s", command, _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_error0_ = 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_error0_);
		_g_free0 (contents);
		contents = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			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_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e->message;
		g_error ("test-umockdev-record.vala:56: Cannot get contents of %s: %s", filename, _tmp3_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (contents);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, (gint) 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_;
	const gchar* _tmp42_;
	const gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_ = NULL;
	gchar* _tmp49_ = NULL;
	gint _tmp50_ = 0;
	const gchar* _tmp51_;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_ = NULL;
	gchar* _tmp57_ = NULL;
	gint _tmp58_ = 0;
	const gchar* _tmp59_;
	const gchar* _tmp60_;
	const gchar* _tmp61_;
	const gchar* _tmp62_;
	_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_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp42_ = sout;
	g_assert_cmpstr (_tmp42_, ==, "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");
	_tmp43_ = umockdev_record_path;
	_tmp44_ = g_strconcat (_tmp43_, " ", NULL);
	_tmp45_ = _tmp44_;
	_tmp46_ = g_strconcat (_tmp45_, dev1, NULL);
	_tmp47_ = _tmp46_;
	spawn (_tmp47_, &_tmp48_, &_tmp49_, &_tmp50_);
	_g_free0 (sout);
	sout = _tmp48_;
	_g_free0 (serr);
	serr = _tmp49_;
	exit = _tmp50_;
	_g_free0 (_tmp47_);
	_g_free0 (_tmp45_);
	_tmp51_ = serr;
	g_assert_cmpstr (_tmp51_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp52_ = sout;
	g_assert_cmpstr (_tmp52_, ==, "P: /devices/dev1\n" \
"E: DEV1COLOR=GREEN\n" \
"E: SUBSYSTEM=pci\n" \
"A: dev1color=green\n" \
"A: knobs/red=off\n" \
"\n");
	_tmp53_ = umockdev_record_path;
	_tmp54_ = g_strconcat (_tmp53_, " --all", NULL);
	_tmp55_ = _tmp54_;
	spawn (_tmp55_, &_tmp56_, &_tmp57_, &_tmp58_);
	_g_free0 (sout);
	sout = _tmp56_;
	_g_free0 (serr);
	serr = _tmp57_;
	exit = _tmp58_;
	_g_free0 (_tmp55_);
	_tmp59_ = serr;
	g_assert_cmpstr (_tmp59_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp60_ = sout;
	_vala_assert (string_contains (_tmp60_, "P: /devices/dev1/subdev1\n"), "sout.contains (\"P: /devices/dev1/subdev1\\n\")");
	_tmp61_ = sout;
	_vala_assert (string_contains (_tmp61_, "P: /devices/dev1\n"), "sout.contains (\"P: /devices/dev1\\n\")");
	_tmp62_ = sout;
	_vala_assert (string_contains (_tmp62_, "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_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_ = NULL;
	gchar* _tmp18_ = NULL;
	gint _tmp19_ = 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 -- ", NULL);
	_tmp11_ = _tmp10_;
	_tmp12_ = readbyte_path;
	_tmp13_ = g_strconcat (_tmp11_, _tmp12_, NULL);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_strconcat (_tmp14_, " /dev/zero", NULL);
	_tmp16_ = _tmp15_;
	spawn (_tmp16_, &_tmp17_, &_tmp18_, &_tmp19_);
	_g_free0 (sout);
	sout = _tmp17_;
	_g_free0 (serr);
	serr = _tmp18_;
	exit = _tmp19_;
	_g_free0 (_tmp16_);
	_g_free0 (_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_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	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_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp9_ = sout;
	assert_in ("E: DEVNAME=/dev/null", _tmp9_);
	_tmp10_ = sout;
	assert_in ("P: /devices/virtual/mem/null", _tmp10_);
	_tmp11_ = sout;
	assert_in ("E: DEVNAME=/dev/zero", _tmp11_);
	_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_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	UMockdevTestbed* tb = NULL;
	UMockdevTestbed* _tmp16_;
	GError* _inner_error0_ = 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_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp12_ = sout;
	_vala_assert (g_str_has_prefix (_tmp12_, "P:"), "sout.has_prefix (\"P:\")");
	_tmp13_ = sout;
	_tmp14_ = strlen (_tmp13_);
	_tmp15_ = _tmp14_;
	g_assert_cmpint (_tmp15_, >=, 100);
	_tmp16_ = umockdev_testbed_new ();
	tb = _tmp16_;
	{
		gboolean _tmp17_ = FALSE;
		UMockdevTestbed* _tmp18_;
		const gchar* _tmp19_;
		_tmp18_ = tb;
		_tmp19_ = sout;
		_tmp17_ = umockdev_testbed_add_from_string (_tmp18_, _tmp19_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
		_vala_assert (_tmp17_, "tb.add_from_string (sout)");
	}
	goto __finally2;
	__catch2_umockdev_error:
	{
		GError* e = NULL;
		const gchar* _tmp20_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp20_ = e->message;
		g_error ("test-umockdev-record.vala:235: Error when adding system dump to testbe" \
"d: %s", _tmp20_);
		_g_error_free0 (e);
	}
	__finally2:
	if (G_UNLIKELY (_inner_error0_ != 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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	gint _tmp15_ = 0;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _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_, ==, "");
	g_assert_cmpint (exit, !=, 0);
	_tmp10_ = umockdev_record_path;
	_tmp11_ = g_strconcat (_tmp10_, " /sys/block/loop0/size", NULL);
	_tmp12_ = _tmp11_;
	spawn (_tmp12_, &_tmp13_, &_tmp14_, &_tmp15_);
	_g_free0 (sout);
	sout = _tmp13_;
	_g_free0 (serr);
	serr = _tmp14_;
	exit = _tmp15_;
	_g_free0 (_tmp12_);
	_tmp16_ = serr;
	_vala_assert (string_contains (_tmp16_, "Invalid device"), "serr.contains (\"Invalid device\")");
	_tmp17_ = serr;
	_vala_assert (string_contains (_tmp17_, "/block/loop0/size"), "serr.contains (\"/block/loop0/size\")");
	_tmp18_ = serr;
	_vala_assert (string_contains (_tmp18_, "has no uevent attribute"), "serr.contains (\"has no uevent attribute\")");
	_tmp19_ = sout;
	g_assert_cmpstr (_tmp19_, ==, "");
	g_assert_cmpint (exit, !=, 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_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_ = NULL;
	gchar* _tmp17_ = NULL;
	gint _tmp18_ = 0;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_ = NULL;
	gchar* _tmp34_ = NULL;
	gint _tmp35_ = 0;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	const gchar* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	const gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_ = NULL;
	gchar* _tmp49_ = NULL;
	gint _tmp50_ = 0;
	const gchar* _tmp51_;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	GError* _inner_error0_ = NULL;
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = g_dir_make_tmp ("ioctl_log_test.XXXXXX", &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != 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_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally3:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (workdir);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, " -- ", NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = readbyte_path;
	_tmp12_ = g_strconcat (_tmp10_, _tmp11_, NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat (_tmp13_, " /dev/zero", NULL);
	_tmp15_ = _tmp14_;
	spawn (_tmp15_, &_tmp16_, &_tmp17_, &_tmp18_);
	_g_free0 (sout);
	sout = _tmp16_;
	_g_free0 (serr);
	serr = _tmp17_;
	exit = _tmp18_;
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_g_free0 (_tmp10_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_tmp19_ = serr;
	g_assert_cmpstr (_tmp19_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp20_ = sout;
	g_assert_cmpstr (_tmp20_, ==, "\0");
	_vala_assert (!g_file_test (log, G_FILE_TEST_EXISTS), "!FileUtils.test (log, FileTest.EXISTS)");
	_tmp21_ = umockdev_record_path;
	_tmp22_ = g_strconcat (_tmp21_, " --ioctl /dev/zero=", NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strconcat (_tmp23_, log, NULL);
	_tmp25_ = _tmp24_;
	_tmp26_ = g_strconcat (_tmp25_, " -- ", NULL);
	_tmp27_ = _tmp26_;
	_tmp28_ = readbyte_path;
	_tmp29_ = g_strconcat (_tmp27_, _tmp28_, NULL);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strconcat (_tmp30_, " /dev/zero", NULL);
	_tmp32_ = _tmp31_;
	spawn (_tmp32_, &_tmp33_, &_tmp34_, &_tmp35_);
	_g_free0 (sout);
	sout = _tmp33_;
	_g_free0 (serr);
	serr = _tmp34_;
	exit = _tmp35_;
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_g_free0 (_tmp27_);
	_g_free0 (_tmp25_);
	_g_free0 (_tmp23_);
	_tmp36_ = serr;
	g_assert_cmpstr (_tmp36_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp37_ = sout;
	g_assert_cmpstr (_tmp37_, ==, "\0");
	_vala_assert (g_file_test (log, G_FILE_TEST_EXISTS), "FileUtils.test (log, FileTest.EXISTS)");
	_tmp38_ = file_contents (log);
	_tmp39_ = _tmp38_;
	g_assert_cmpstr (_tmp39_, ==, "@DEV /dev/zero\n");
	_g_free0 (_tmp39_);
	g_remove (log);
	_tmp40_ = umockdev_record_path;
	_tmp41_ = g_strconcat (_tmp40_, " --ioctl /dev/null -- ", NULL);
	_tmp42_ = _tmp41_;
	_tmp43_ = readbyte_path;
	_tmp44_ = g_strconcat (_tmp42_, _tmp43_, NULL);
	_tmp45_ = _tmp44_;
	_tmp46_ = g_strconcat (_tmp45_, " /dev/zero", NULL);
	_tmp47_ = _tmp46_;
	spawn (_tmp47_, &_tmp48_, &_tmp49_, &_tmp50_);
	_g_free0 (sout);
	sout = _tmp48_;
	_g_free0 (serr);
	serr = _tmp49_;
	exit = _tmp50_;
	_g_free0 (_tmp47_);
	_g_free0 (_tmp45_);
	_g_free0 (_tmp42_);
	g_assert_cmpint (exit, !=, 1);
	_tmp51_ = sout;
	g_assert_cmpstr (_tmp51_, ==, "");
	_tmp52_ = serr;
	_vala_assert (string_contains (_tmp52_, "--ioctl"), "serr.contains (\"--ioctl\")");
	_tmp53_ = serr;
	_vala_assert (string_contains (_tmp53_, "="), "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_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	gint _tmp17_ = 0;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* orig_contents = NULL;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_ = NULL;
	gchar* _tmp34_ = NULL;
	gint _tmp35_ = 0;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	GError* _inner_error0_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("ioctl_log_test.XXXXXX", &_tmp1_, &_inner_error0_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch4_g_error;
		}
		close (_tmp0_);
	}
	goto __finally4;
	__catch4_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally4:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, " -- ", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = readbyte_path;
	_tmp11_ = g_strconcat (_tmp9_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, " /dev/zero", NULL);
	_tmp14_ = _tmp13_;
	spawn (_tmp14_, &_tmp15_, &_tmp16_, &_tmp17_);
	_g_free0 (sout);
	sout = _tmp15_;
	_g_free0 (serr);
	serr = _tmp16_;
	exit = _tmp17_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp18_ = serr;
	g_assert_cmpstr (_tmp18_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp19_ = sout;
	g_assert_cmpstr (_tmp19_, ==, "\0");
	_tmp20_ = file_contents (log);
	orig_contents = _tmp20_;
	_tmp21_ = umockdev_record_path;
	_tmp22_ = g_strconcat (_tmp21_, " -i /dev/null=", NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strconcat (_tmp23_, log, NULL);
	_tmp25_ = _tmp24_;
	_tmp26_ = g_strconcat (_tmp25_, " -- ", NULL);
	_tmp27_ = _tmp26_;
	_tmp28_ = readbyte_path;
	_tmp29_ = g_strconcat (_tmp27_, _tmp28_, NULL);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strconcat (_tmp30_, " /dev/null", NULL);
	_tmp32_ = _tmp31_;
	spawn (_tmp32_, &_tmp33_, &_tmp34_, &_tmp35_);
	_g_free0 (sout);
	sout = _tmp33_;
	_g_free0 (serr);
	serr = _tmp34_;
	exit = _tmp35_;
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_g_free0 (_tmp27_);
	_g_free0 (_tmp25_);
	_g_free0 (_tmp23_);
	_tmp36_ = serr;
	_vala_assert (string_contains (_tmp36_, "two different devices"), "serr.contains (\"two different devices\")");
	g_assert_cmpint (exit, ==, 256);
	_tmp37_ = sout;
	g_assert_cmpstr (_tmp37_, ==, "\0");
	_tmp38_ = file_contents (log);
	_tmp39_ = _tmp38_;
	g_assert_cmpstr (_tmp39_, ==, orig_contents);
	_g_free0 (_tmp39_);
	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_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	gint _tmp17_ = 0;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	const gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_ = NULL;
	gchar* _tmp35_ = NULL;
	gint _tmp36_ = 0;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	gchar** loglines = NULL;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar** _tmp41_;
	gchar** _tmp42_;
	gchar** _tmp43_;
	gint _tmp43__length1;
	gint loglines_length1;
	gint _loglines_size_;
	const gchar* _tmp44_;
	gchar** logwords = NULL;
	const gchar* _tmp45_;
	gchar** _tmp46_;
	gchar** _tmp47_;
	gint logwords_length1;
	gint _logwords_size_;
	const gchar* _tmp48_;
	const gchar* _tmp49_;
	const gchar* _tmp50_;
	GError* _inner_error0_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error0_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch5_g_error;
		}
		close (_tmp0_);
	}
	goto __finally5;
	__catch5_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally5:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, " -- ", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = readbyte_path;
	_tmp11_ = g_strconcat (_tmp9_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, " /dev/zero", NULL);
	_tmp14_ = _tmp13_;
	spawn (_tmp14_, &_tmp15_, &_tmp16_, &_tmp17_);
	_g_free0 (sout);
	sout = _tmp15_;
	_g_free0 (serr);
	serr = _tmp16_;
	exit = _tmp17_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp18_ = serr;
	g_assert_cmpstr (_tmp18_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp19_ = sout;
	g_assert_cmpstr (_tmp19_, ==, "\0");
	_tmp20_ = file_contents (log);
	_tmp21_ = _tmp20_;
	g_assert_cmpstr (_tmp21_, ==, "");
	_g_free0 (_tmp21_);
	_tmp22_ = umockdev_record_path;
	_tmp23_ = g_strconcat (_tmp22_, " --script=/dev/zero=", NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, log, NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = g_strconcat (_tmp26_, " -- ", NULL);
	_tmp28_ = _tmp27_;
	_tmp29_ = readbyte_path;
	_tmp30_ = g_strconcat (_tmp28_, _tmp29_, NULL);
	_tmp31_ = _tmp30_;
	_tmp32_ = g_strconcat (_tmp31_, " /dev/zero", NULL);
	_tmp33_ = _tmp32_;
	spawn (_tmp33_, &_tmp34_, &_tmp35_, &_tmp36_);
	_g_free0 (sout);
	sout = _tmp34_;
	_g_free0 (serr);
	serr = _tmp35_;
	exit = _tmp36_;
	_g_free0 (_tmp33_);
	_g_free0 (_tmp31_);
	_g_free0 (_tmp28_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	_tmp37_ = serr;
	g_assert_cmpstr (_tmp37_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp38_ = sout;
	g_assert_cmpstr (_tmp38_, ==, "\0");
	_tmp39_ = file_contents (log);
	_tmp40_ = _tmp39_;
	_tmp42_ = _tmp41_ = g_strsplit (_tmp40_, "\n", 0);
	_tmp43_ = _tmp42_;
	_tmp43__length1 = _vala_array_length (_tmp41_);
	_g_free0 (_tmp40_);
	loglines = _tmp43_;
	loglines_length1 = _tmp43__length1;
	_loglines_size_ = loglines_length1;
	g_assert_cmpuint ((guint) loglines_length1, ==, (guint) 2);
	_tmp44_ = loglines[0];
	g_assert_cmpstr (_tmp44_, ==, "d 0 /dev/zero");
	_tmp45_ = loglines[1];
	_tmp47_ = _tmp46_ = g_strsplit (_tmp45_, " ", 0);
	logwords = _tmp47_;
	logwords_length1 = _vala_array_length (_tmp46_);
	_logwords_size_ = logwords_length1;
	g_assert_cmpuint ((guint) logwords_length1, ==, (guint) 3);
	_tmp48_ = logwords[0];
	g_assert_cmpstr (_tmp48_, ==, "r");
	_tmp49_ = logwords[1];
	g_assert_cmpint (atoi (_tmp49_), <=, 5);
	_tmp50_ = logwords[2];
	g_assert_cmpstr (_tmp50_, ==, "^@");
	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_simple_fopen (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_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	gint _tmp17_ = 0;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	const gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_ = NULL;
	gchar* _tmp35_ = NULL;
	gint _tmp36_ = 0;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	gchar** loglines = NULL;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar** _tmp41_;
	gchar** _tmp42_;
	gchar** _tmp43_;
	gint _tmp43__length1;
	gint loglines_length1;
	gint _loglines_size_;
	const gchar* _tmp44_;
	gchar** logwords = NULL;
	const gchar* _tmp45_;
	gchar** _tmp46_;
	gchar** _tmp47_;
	gint logwords_length1;
	gint _logwords_size_;
	const gchar* _tmp48_;
	const gchar* _tmp49_;
	const gchar* _tmp50_;
	GError* _inner_error0_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error0_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch6_g_error;
		}
		close (_tmp0_);
	}
	goto __finally6;
	__catch6_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally6:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, " -- ", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = readbyte_path;
	_tmp11_ = g_strconcat (_tmp9_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, " /dev/zero fopen", NULL);
	_tmp14_ = _tmp13_;
	spawn (_tmp14_, &_tmp15_, &_tmp16_, &_tmp17_);
	_g_free0 (sout);
	sout = _tmp15_;
	_g_free0 (serr);
	serr = _tmp16_;
	exit = _tmp17_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp18_ = serr;
	g_assert_cmpstr (_tmp18_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp19_ = sout;
	g_assert_cmpstr (_tmp19_, ==, "\0");
	_tmp20_ = file_contents (log);
	_tmp21_ = _tmp20_;
	g_assert_cmpstr (_tmp21_, ==, "");
	_g_free0 (_tmp21_);
	_tmp22_ = umockdev_record_path;
	_tmp23_ = g_strconcat (_tmp22_, " --script=/dev/zero=", NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, log, NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = g_strconcat (_tmp26_, " -- ", NULL);
	_tmp28_ = _tmp27_;
	_tmp29_ = readbyte_path;
	_tmp30_ = g_strconcat (_tmp28_, _tmp29_, NULL);
	_tmp31_ = _tmp30_;
	_tmp32_ = g_strconcat (_tmp31_, " /dev/zero fopen", NULL);
	_tmp33_ = _tmp32_;
	spawn (_tmp33_, &_tmp34_, &_tmp35_, &_tmp36_);
	_g_free0 (sout);
	sout = _tmp34_;
	_g_free0 (serr);
	serr = _tmp35_;
	exit = _tmp36_;
	_g_free0 (_tmp33_);
	_g_free0 (_tmp31_);
	_g_free0 (_tmp28_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	_tmp37_ = serr;
	g_assert_cmpstr (_tmp37_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp38_ = sout;
	g_assert_cmpstr (_tmp38_, ==, "\0");
	_tmp39_ = file_contents (log);
	_tmp40_ = _tmp39_;
	_tmp42_ = _tmp41_ = g_strsplit (_tmp40_, "\n", 0);
	_tmp43_ = _tmp42_;
	_tmp43__length1 = _vala_array_length (_tmp41_);
	_g_free0 (_tmp40_);
	loglines = _tmp43_;
	loglines_length1 = _tmp43__length1;
	_loglines_size_ = loglines_length1;
	g_assert_cmpuint ((guint) loglines_length1, ==, (guint) 2);
	_tmp44_ = loglines[0];
	g_assert_cmpstr (_tmp44_, ==, "d 0 /dev/zero");
	_tmp45_ = loglines[1];
	_tmp47_ = _tmp46_ = g_strsplit (_tmp45_, " ", 0);
	logwords = _tmp47_;
	logwords_length1 = _vala_array_length (_tmp46_);
	_logwords_size_ = logwords_length1;
	g_assert_cmpuint ((guint) logwords_length1, ==, (guint) 3);
	_tmp48_ = logwords[0];
	g_assert_cmpstr (_tmp48_, ==, "r");
	_tmp49_ = logwords[1];
	g_assert_cmpint (atoi (_tmp49_), <=, 5);
	_tmp50_ = logwords[2];
	g_assert_cmpstr (_tmp50_, ==, "^@");
	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_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	gint _tmp17_ = 0;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_ = NULL;
	gchar* _tmp33_ = NULL;
	gint _tmp34_ = 0;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	gchar** loglines = NULL;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar** _tmp39_;
	gchar** _tmp40_;
	gchar** _tmp41_;
	gint _tmp41__length1;
	gint loglines_length1;
	gint _loglines_size_;
	const gchar* _tmp42_;
	gchar** logwords = NULL;
	const gchar* _tmp43_;
	gchar** _tmp44_;
	gchar** _tmp45_;
	gint logwords_length1;
	gint _logwords_size_;
	gchar** _tmp46_;
	gint _tmp46__length1;
	gchar** _tmp47_;
	gint _tmp47__length1;
	const gchar* _tmp48_;
	gchar** _tmp49_;
	gint _tmp49__length1;
	const gchar* _tmp50_;
	gchar** _tmp51_;
	gint _tmp51__length1;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	gchar** _tmp54_;
	gchar** _tmp55_;
	gchar** _tmp56_;
	gint _tmp56__length1;
	gchar** _tmp57_;
	gint _tmp57__length1;
	const gchar* _tmp58_;
	gchar** _tmp59_;
	gint _tmp59__length1;
	const gchar* _tmp60_;
	gchar** _tmp61_;
	gint _tmp61__length1;
	const gchar* _tmp62_;
	GError* _inner_error0_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error0_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch7_g_error;
		}
		close (_tmp0_);
	}
	goto __finally7;
	__catch7_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally7:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, " -- ", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = readbyte_path;
	_tmp11_ = g_strconcat (_tmp9_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, " /dev/zero", NULL);
	_tmp14_ = _tmp13_;
	spawn (_tmp14_, &_tmp15_, &_tmp16_, &_tmp17_);
	_g_free0 (sout);
	sout = _tmp15_;
	_g_free0 (serr);
	serr = _tmp16_;
	exit = _tmp17_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp18_ = serr;
	g_assert_cmpstr (_tmp18_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp19_ = sout;
	g_assert_cmpstr (_tmp19_, ==, "\0");
	_tmp20_ = umockdev_record_path;
	_tmp21_ = g_strconcat (_tmp20_, " --script=/dev/zero=", NULL);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_strconcat (_tmp22_, log, NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, " -- ", NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = readbyte_path;
	_tmp28_ = g_strconcat (_tmp26_, _tmp27_, NULL);
	_tmp29_ = _tmp28_;
	_tmp30_ = g_strconcat (_tmp29_, " /dev/zero", NULL);
	_tmp31_ = _tmp30_;
	spawn (_tmp31_, &_tmp32_, &_tmp33_, &_tmp34_);
	_g_free0 (sout);
	sout = _tmp32_;
	_g_free0 (serr);
	serr = _tmp33_;
	exit = _tmp34_;
	_g_free0 (_tmp31_);
	_g_free0 (_tmp29_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	_g_free0 (_tmp22_);
	_tmp35_ = serr;
	g_assert_cmpstr (_tmp35_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp36_ = sout;
	g_assert_cmpstr (_tmp36_, ==, "\0");
	_tmp37_ = file_contents (log);
	_tmp38_ = _tmp37_;
	_tmp40_ = _tmp39_ = g_strsplit (_tmp38_, "\n", 0);
	_tmp41_ = _tmp40_;
	_tmp41__length1 = _vala_array_length (_tmp39_);
	_g_free0 (_tmp38_);
	loglines = _tmp41_;
	loglines_length1 = _tmp41__length1;
	_loglines_size_ = loglines_length1;
	g_assert_cmpuint ((guint) loglines_length1, ==, (guint) 3);
	_tmp42_ = loglines[0];
	g_assert_cmpstr (_tmp42_, ==, "d 0 /dev/zero");
	_tmp43_ = loglines[1];
	_tmp45_ = _tmp44_ = g_strsplit (_tmp43_, " ", 0);
	logwords = _tmp45_;
	logwords_length1 = _vala_array_length (_tmp44_);
	_logwords_size_ = logwords_length1;
	_tmp46_ = logwords;
	_tmp46__length1 = logwords_length1;
	g_assert_cmpuint ((guint) _tmp46__length1, ==, (guint) 3);
	_tmp47_ = logwords;
	_tmp47__length1 = logwords_length1;
	_tmp48_ = _tmp47_[0];
	g_assert_cmpstr (_tmp48_, ==, "r");
	_tmp49_ = logwords;
	_tmp49__length1 = logwords_length1;
	_tmp50_ = _tmp49_[1];
	g_assert_cmpint (atoi (_tmp50_), <=, 5);
	_tmp51_ = logwords;
	_tmp51__length1 = logwords_length1;
	_tmp52_ = _tmp51_[2];
	g_assert_cmpstr (_tmp52_, ==, "^@");
	_tmp53_ = loglines[2];
	_tmp55_ = _tmp54_ = g_strsplit (_tmp53_, " ", 0);
	logwords = (_vala_array_free (logwords, logwords_length1, (GDestroyNotify) g_free), NULL);
	logwords = _tmp55_;
	logwords_length1 = _vala_array_length (_tmp54_);
	_logwords_size_ = logwords_length1;
	_tmp56_ = logwords;
	_tmp56__length1 = logwords_length1;
	g_assert_cmpuint ((guint) _tmp56__length1, ==, (guint) 3);
	_tmp57_ = logwords;
	_tmp57__length1 = logwords_length1;
	_tmp58_ = _tmp57_[0];
	g_assert_cmpstr (_tmp58_, ==, "r");
	_tmp59_ = logwords;
	_tmp59__length1 = logwords_length1;
	_tmp60_ = _tmp59_[1];
	g_assert_cmpint (atoi (_tmp60_), <=, 5);
	_tmp61_ = logwords;
	_tmp61__length1 = logwords_length1;
	_tmp62_ = _tmp61_[2];
	g_assert_cmpstr (_tmp62_, ==, "^@");
	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_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	gint _tmp17_ = 0;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* orig_contents = NULL;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_ = NULL;
	gchar* _tmp34_ = NULL;
	gint _tmp35_ = 0;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	GError* _inner_error0_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error0_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch8_g_error;
		}
		close (_tmp0_);
	}
	goto __finally8;
	__catch8_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally8:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (log);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, " -- ", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = readbyte_path;
	_tmp11_ = g_strconcat (_tmp9_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, " /dev/zero", NULL);
	_tmp14_ = _tmp13_;
	spawn (_tmp14_, &_tmp15_, &_tmp16_, &_tmp17_);
	_g_free0 (sout);
	sout = _tmp15_;
	_g_free0 (serr);
	serr = _tmp16_;
	exit = _tmp17_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp18_ = serr;
	g_assert_cmpstr (_tmp18_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp19_ = sout;
	g_assert_cmpstr (_tmp19_, ==, "\0");
	_tmp20_ = file_contents (log);
	orig_contents = _tmp20_;
	_tmp21_ = umockdev_record_path;
	_tmp22_ = g_strconcat (_tmp21_, " --script=/dev/null=", NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strconcat (_tmp23_, log, NULL);
	_tmp25_ = _tmp24_;
	_tmp26_ = g_strconcat (_tmp25_, " -- ", NULL);
	_tmp27_ = _tmp26_;
	_tmp28_ = readbyte_path;
	_tmp29_ = g_strconcat (_tmp27_, _tmp28_, NULL);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strconcat (_tmp30_, " /dev/null", NULL);
	_tmp32_ = _tmp31_;
	spawn (_tmp32_, &_tmp33_, &_tmp34_, &_tmp35_);
	_g_free0 (sout);
	sout = _tmp33_;
	_g_free0 (serr);
	serr = _tmp34_;
	exit = _tmp35_;
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_g_free0 (_tmp27_);
	_g_free0 (_tmp25_);
	_g_free0 (_tmp23_);
	_tmp36_ = serr;
	_vala_assert (string_contains (_tmp36_, "two different devices"), "serr.contains (\"two different devices\")");
	g_assert_cmpint (exit, ==, 256);
	_tmp37_ = sout;
	g_assert_cmpstr (_tmp37_, ==, "\0");
	_tmp38_ = file_contents (log);
	_tmp39_ = _tmp38_;
	g_assert_cmpstr (_tmp39_, ==, orig_contents);
	_g_free0 (_tmp39_);
	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;
	gchar* _tmp4_;
	g_return_val_if_fail (stream != NULL, NULL);
	line = NULL;
	timeout = 50;
	while (TRUE) {
		const gchar* _tmp0_;
		gchar* _tmp1_;
		const gchar* _tmp2_;
		gint _tmp3_;
		if (!(timeout > 0)) {
			break;
		}
		_tmp0_ = fgets (buffer, (gint) 1000, stream);
		_tmp1_ = g_strdup (_tmp0_);
		_g_free0 (line);
		line = _tmp1_;
		_tmp2_ = line;
		if (_tmp2_ != NULL) {
			result = line;
			return result;
		}
		g_usleep ((gulong) 100000);
		_tmp3_ = timeout;
		timeout = _tmp3_ - 1;
	}
	_vala_assert (timeout > 0, "timeout > 0");
	_tmp4_ = g_strdup ("<timeout>");
	result = _tmp4_;
	_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_;
	struct termios _tmp9_;
	GPid chatter_pid = 0;
	FILE* chatter_stream = NULL;
	FILE* _tmp27_;
	FILE* _tmp28_;
	FILE* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	FILE* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	FILE* _tmp35_;
	FILE* _tmp40_;
	FILE* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	gint status = 0;
	gint _tmp44_ = 0;
	pid_t _tmp45_;
	FILE* log_stream = NULL;
	FILE* _tmp46_;
	gchar* buf = NULL;
	gchar* _tmp47_;
	gint buf_length1;
	gint _buf_size_;
	gint time = 0;
	GError* _inner_error0_ = NULL;
	{
		gint _tmp0_ = 0;
		gchar* _tmp1_ = NULL;
		gint _tmp2_;
		_tmp2_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp1_, &_inner_error0_);
		_g_free0 (log);
		log = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch9_g_error;
		}
		close (_tmp0_);
	}
	goto __finally9;
	__catch9_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally9:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (log);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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");
	ios.c_iflag = ios.c_iflag & (~((IGNCR | INLCR) | ICRNL));
	ios.c_oflag = ios.c_oflag & (~(ONLCR | OCRNL));
	ios.c_lflag = ios.c_lflag & (~(ICANON | ECHO));
	_tmp9_ = ios;
	_vala_assert (tcsetattr (ptym, TCSANOW, &_tmp9_) == 0, "Posix.tcsetattr (ptym, Posix.TCSANOW, ios) == 0");
	{
		gboolean _tmp10_ = FALSE;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gchar** _tmp21_;
		gchar** _tmp22_;
		gint _tmp22__length1;
		GPid _tmp23_ = 0;
		gboolean _tmp24_;
		gboolean _tmp25_;
		_tmp11_ = umockdev_record_path;
		_tmp12_ = g_strdup (_tmp11_);
		_tmp13_ = g_strdup ("--script");
		_tmp14_ = g_strconcat ((const gchar*) ptyname, "=", NULL);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_strconcat (_tmp15_, log, NULL);
		_tmp17_ = g_strdup ("--");
		_tmp18_ = rootdir;
		_tmp19_ = g_build_filename (_tmp18_, "tests", "chatter", NULL);
		_tmp20_ = g_strdup ((const gchar*) ptyname);
		_tmp21_ = g_new0 (gchar*, 6 + 1);
		_tmp21_[0] = _tmp12_;
		_tmp21_[1] = _tmp13_;
		_tmp21_[2] = _tmp16_;
		_tmp21_[3] = _tmp17_;
		_tmp21_[4] = _tmp19_;
		_tmp21_[5] = _tmp20_;
		_tmp22_ = _tmp21_;
		_tmp22__length1 = 6;
		_tmp24_ = g_spawn_async_with_pipes (NULL, _tmp22_, NULL, (G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD) | G_SPAWN_STDOUT_TO_DEV_NULL, NULL, NULL, &_tmp23_, NULL, NULL, NULL, &_inner_error0_);
		chatter_pid = _tmp23_;
		_tmp25_ = _tmp24_;
		_tmp22_ = (_vala_array_free (_tmp22_, _tmp22__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp15_);
		_tmp10_ = _tmp25_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_SPAWN_ERROR) {
				goto __catch10_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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
		_vala_assert (_tmp10_, "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 __finally10;
	__catch10_g_spawn_error:
	{
		GError* e = NULL;
		const gchar* _tmp26_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp26_ = e->message;
		g_error ("test-umockdev-record.vala:575: Cannot call umockdev-record: %s", _tmp26_);
		_g_error_free0 (e);
	}
	__finally10:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		ptyname = (g_free (ptyname), NULL);
		_g_free0 (log);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp27_ = fdopen (ptym, "r+");
	chatter_stream = _tmp27_;
	_tmp28_ = chatter_stream;
	_vala_assert (_tmp28_ != NULL, "chatter_stream != null");
	_tmp29_ = chatter_stream;
	_tmp30_ = read_line_timeout (_tmp29_);
	_tmp31_ = _tmp30_;
	g_assert_cmpstr (_tmp31_, ==, "Hello world!\n");
	_g_free0 (_tmp31_);
	_tmp32_ = chatter_stream;
	_tmp33_ = read_line_timeout (_tmp32_);
	_tmp34_ = _tmp33_;
	g_assert_cmpstr (_tmp34_, ==, "What is your name?\n");
	_g_free0 (_tmp34_);
	g_usleep ((gulong) 500000);
	_tmp35_ = chatter_stream;
	fputs ("John\n", _tmp35_);
	while (TRUE) {
		FILE* _tmp36_;
		gchar* _tmp37_;
		gchar* _tmp38_;
		gboolean _tmp39_;
		_tmp36_ = chatter_stream;
		_tmp37_ = read_line_timeout (_tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = !(!string_contains (_tmp38_, "line break in one write"));
		_g_free0 (_tmp38_);
		if (_tmp39_) {
			break;
		}
	}
	g_usleep ((gulong) 300000);
	_tmp40_ = chatter_stream;
	fputs ("foo ☹ bar ^!\n", _tmp40_);
	_tmp41_ = chatter_stream;
	_tmp42_ = read_line_timeout (_tmp41_);
	_tmp43_ = _tmp42_;
	g_assert_cmpstr (_tmp43_, ==, "bye!\n");
	_g_free0 (_tmp43_);
	_tmp45_ = waitpid ((pid_t) chatter_pid, &_tmp44_, 0);
	status = _tmp44_;
	g_assert_cmpint ((gint) _tmp45_, ==, (gint) chatter_pid);
	g_assert_cmpint (status, ==, 0);
	_tmp46_ = g_fopen (log, "r");
	log_stream = _tmp46_;
	_tmp47_ = g_new0 (gchar, 8192);
	buf = _tmp47_;
	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,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	guint8* _tmp3_;
	gint _tmp3__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;
	_tmp2__length1 = res_length1;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp2__length1;
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	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* _tmp67_;
	gint status = 0;
	gint _tmp68_ = 0;
	pid_t _tmp69_;
	FILE* log_stream = NULL;
	const gchar* _tmp70_;
	FILE* _tmp71_;
	gint time = 0;
	const gchar* _tmp72_;
	GError* _inner_error0_ = 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* _tmp43_;
		guint8* buf = NULL;
		guint8* _tmp44_;
		gint buf_length1;
		gint _buf_size_;
		gssize len = 0L;
		GSocket* _tmp45_;
		guint8* _tmp46_;
		gint _tmp46__length1;
		guint8* _tmp47_;
		gint _tmp47__length1;
		guint8* _tmp48_;
		gint _tmp48__length1;
		GSocket* _tmp49_;
		guint8* _tmp50_;
		gint _tmp50__length1;
		guint8* _tmp51_;
		gint _tmp51__length1;
		gssize _tmp52_ = 0L;
		GSocket* _tmp53_;
		guint8* _tmp54_;
		gint _tmp54__length1;
		guint8* _tmp55_;
		gint _tmp55__length1;
		guint8* _tmp56_;
		gint _tmp56__length1;
		gssize _tmp57_ = 0L;
		GSocket* _tmp58_;
		guint8* _tmp59_;
		gint _tmp59__length1;
		guint8* _tmp60_;
		gint _tmp60__length1;
		guint8* _tmp61_;
		gint _tmp61__length1;
		GSocket* _tmp62_;
		guint8* _tmp63_;
		gint _tmp63__length1;
		guint8* _tmp64_;
		gint _tmp64__length1;
		_tmp3_ = g_file_open_tmp ("test_script_log.XXXXXX", &_tmp2_, &_inner_error0_);
		_g_free0 (log);
		log = _tmp2_;
		_tmp1_ = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch11_g_error;
		}
		close (_tmp1_);
		_tmp4_ = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &_inner_error0_);
		s = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch11_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_error0_);
		_g_object_unref0 (_tmp11_);
		_tmp7_ = _tmp12_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (s);
			goto __catch11_g_error;
		}
		_vala_assert (_tmp7_, "s.bind (new UnixSocketAddress (spath), true)");
		_tmp14_ = s;
		_tmp13_ = g_socket_listen (_tmp14_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (s);
			goto __catch11_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_error0_);
			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_error0_ != NULL)) {
				if (_inner_error0_->domain == G_SPAWN_ERROR) {
					goto __catch12_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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				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 __finally12;
		__catch12_g_spawn_error:
		{
			GError* e = NULL;
			const gchar* _tmp34_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp34_ = e->message;
			g_error ("test-umockdev-record.vala:654: Cannot call umockdev-record: %s", _tmp34_);
			_g_error_free0 (e);
		}
		__finally12:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (s);
			goto __catch11_g_error;
		}
		timeout = 20;
		conn = NULL;
		while (TRUE) {
			if (!(timeout > 0)) {
				break;
			}
			{
				GSocket* _tmp35_ = NULL;
				GSocket* _tmp36_;
				GSocket* _tmp37_;
				GSocket* _tmp38_;
				_tmp36_ = s;
				_tmp37_ = g_socket_accept (_tmp36_, NULL, &_inner_error0_);
				_tmp35_ = _tmp37_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					if (_inner_error0_->domain == G_IO_ERROR) {
						goto __catch13_g_io_error;
					}
					goto __finally13;
				}
				_tmp38_ = _tmp35_;
				_tmp35_ = NULL;
				_g_object_unref0 (conn);
				conn = _tmp38_;
				_g_object_unref0 (_tmp35_);
				break;
			}
			goto __finally13;
			__catch13_g_io_error:
			{
				GError* e = NULL;
				GError* _tmp39_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp39_ = e;
				if (g_error_matches (_tmp39_, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
					gint _tmp40_;
					_tmp40_ = timeout;
					timeout = _tmp40_ - 1;
					g_usleep ((gulong) 10000);
				} else {
					GError* _tmp41_;
					GError* _tmp42_;
					_tmp41_ = e;
					_tmp42_ = _g_error_copy0 (_tmp41_);
					_inner_error0_ = _tmp42_;
					_g_error_free0 (e);
					goto __finally13;
				}
				_g_error_free0 (e);
			}
			__finally13:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (conn);
				_g_object_unref0 (s);
				goto __catch11_g_error;
			}
		}
		_tmp43_ = conn;
		_vala_assert (_tmp43_ != NULL, "conn != null");
		_tmp44_ = g_new0 (guint8, 1000);
		buf = _tmp44_;
		buf_length1 = 1000;
		_buf_size_ = buf_length1;
		_tmp45_ = conn;
		_tmp46_ = buf;
		_tmp46__length1 = buf_length1;
		len = g_socket_receive (_tmp45_, _tmp46_, (gsize) _tmp46__length1, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch11_g_error;
		}
		_vala_assert (len > ((gssize) 0), "len > 0");
		_tmp47_ = buf;
		_tmp47__length1 = buf_length1;
		_tmp47_[len] = (guint8) 0;
		_tmp48_ = buf;
		_tmp48__length1 = buf_length1;
		g_assert_cmpstr ((const gchar*) _tmp48_, ==, "What is your name?\n");
		g_usleep ((gulong) 300000);
		_tmp49_ = conn;
		_tmp50_ = string_get_data ("John\n", &_tmp50__length1);
		_tmp51_ = _tmp50_;
		_tmp51__length1 = _tmp50__length1;
		g_socket_send (_tmp49_, _tmp51_, (gsize) _tmp51__length1, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch11_g_error;
		}
		g_usleep ((gulong) 10000);
		_tmp53_ = conn;
		_tmp54_ = buf;
		_tmp54__length1 = buf_length1;
		_tmp52_ = g_socket_receive (_tmp53_, _tmp54_, (gsize) _tmp54__length1, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch11_g_error;
		}
		len = _tmp52_;
		_vala_assert (len > ((gssize) 0), "len > 0");
		_tmp55_ = buf;
		_tmp55__length1 = buf_length1;
		_tmp55_[len] = (guint8) 0;
		_tmp56_ = buf;
		_tmp56__length1 = buf_length1;
		g_assert_cmpstr ((const gchar*) _tmp56_, ==, "hello John\n");
		g_usleep ((gulong) 20000);
		_tmp58_ = conn;
		_tmp59_ = buf;
		_tmp59__length1 = buf_length1;
		_tmp57_ = g_socket_receive (_tmp58_, _tmp59_, (gsize) _tmp59__length1, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch11_g_error;
		}
		len = _tmp57_;
		_vala_assert (len > ((gssize) 0), "len > 0");
		_tmp60_ = buf;
		_tmp60__length1 = buf_length1;
		_tmp60_[len] = (guint8) 0;
		_tmp61_ = buf;
		_tmp61__length1 = buf_length1;
		g_assert_cmpstr ((const gchar*) _tmp61_, ==, "send()");
		g_usleep ((gulong) 20000);
		_tmp62_ = conn;
		_tmp63_ = string_get_data ("recv()", &_tmp63__length1);
		_tmp64_ = _tmp63_;
		_tmp64__length1 = _tmp63__length1;
		g_socket_send (_tmp62_, _tmp64_, (gsize) _tmp64__length1, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			buf = (g_free (buf), NULL);
			_g_object_unref0 (conn);
			_g_object_unref0 (s);
			goto __catch11_g_error;
		}
		buf = (g_free (buf), NULL);
		_g_object_unref0 (conn);
		_g_object_unref0 (s);
	}
	goto __finally11;
	__catch11_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp65_;
		const gchar* _tmp66_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp65_ = spath;
		g_remove (_tmp65_);
		_tmp66_ = e->message;
		g_error ("test-umockdev-record.vala:705: Error: %s", _tmp66_);
		_g_error_free0 (e);
	}
	__finally11:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (spath);
		_g_free0 (log);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp67_ = spath;
	g_remove (_tmp67_);
	_tmp69_ = waitpid ((pid_t) chatter_pid, &_tmp68_, 0);
	status = _tmp68_;
	g_assert_cmpint ((gint) _tmp69_, ==, (gint) chatter_pid);
	g_assert_cmpint (status, ==, 0);
	_tmp70_ = log;
	_tmp71_ = g_fopen (_tmp70_, "r");
	log_stream = _tmp71_;
	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);
	_tmp72_ = log;
	g_remove (_tmp72_);
	_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_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_ = NULL;
	gchar* _tmp17_ = NULL;
	gint _tmp18_ = 0;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_ = NULL;
	gchar* _tmp36_ = NULL;
	gint _tmp37_ = 0;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	const gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	const gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_ = NULL;
	gchar* _tmp55_ = NULL;
	gint _tmp56_ = 0;
	const gchar* _tmp57_;
	const gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	const gchar* _tmp61_;
	gchar* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_ = NULL;
	gchar* _tmp65_ = NULL;
	gint _tmp66_ = 0;
	const gchar* _tmp67_;
	const gchar* _tmp68_;
	const gchar* _tmp69_;
	GError* _inner_error0_ = NULL;
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = g_dir_make_tmp ("evemu_log_test.XXXXXX", &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch14_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_free0 (workdir);
		workdir = _tmp2_;
		_g_free0 (_tmp0_);
	}
	goto __finally14;
	__catch14_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		abort ();
		_g_error_free0 (e);
	}
	__finally14:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (workdir);
		_g_free0 (serr);
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		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_, " -- ", NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = readbyte_path;
	_tmp12_ = g_strconcat (_tmp10_, _tmp11_, NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat (_tmp13_, " /dev/null", NULL);
	_tmp15_ = _tmp14_;
	spawn (_tmp15_, &_tmp16_, &_tmp17_, &_tmp18_);
	_g_free0 (sout);
	sout = _tmp16_;
	_g_free0 (serr);
	serr = _tmp17_;
	exit = _tmp18_;
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_g_free0 (_tmp10_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_tmp19_ = serr;
	g_assert_cmpstr (_tmp19_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp20_ = sout;
	g_assert_cmpstr (_tmp20_, ==, "\0");
	_tmp21_ = file_contents (log);
	_tmp22_ = _tmp21_;
	g_assert_cmpstr (_tmp22_, ==, "# EVEMU 1.2\n# device /dev/null\n");
	_g_free0 (_tmp22_);
	_tmp23_ = umockdev_record_path;
	_tmp24_ = g_strconcat (_tmp23_, " --evemu-events=/dev/null=", NULL);
	_tmp25_ = _tmp24_;
	_tmp26_ = g_strconcat (_tmp25_, log, NULL);
	_tmp27_ = _tmp26_;
	_tmp28_ = g_strconcat (_tmp27_, " -- ", NULL);
	_tmp29_ = _tmp28_;
	_tmp30_ = readbyte_path;
	_tmp31_ = g_strconcat (_tmp29_, _tmp30_, NULL);
	_tmp32_ = _tmp31_;
	_tmp33_ = g_strconcat (_tmp32_, " /dev/null", NULL);
	_tmp34_ = _tmp33_;
	spawn (_tmp34_, &_tmp35_, &_tmp36_, &_tmp37_);
	_g_free0 (sout);
	sout = _tmp35_;
	_g_free0 (serr);
	serr = _tmp36_;
	exit = _tmp37_;
	_g_free0 (_tmp34_);
	_g_free0 (_tmp32_);
	_g_free0 (_tmp29_);
	_g_free0 (_tmp27_);
	_g_free0 (_tmp25_);
	_tmp38_ = serr;
	g_assert_cmpstr (_tmp38_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp39_ = sout;
	g_assert_cmpstr (_tmp39_, ==, "\0");
	_tmp40_ = file_contents (log);
	_tmp41_ = _tmp40_;
	g_assert_cmpstr (_tmp41_, ==, "# EVEMU 1.2\n# device /dev/null\n\n");
	_g_free0 (_tmp41_);
	_tmp42_ = umockdev_record_path;
	_tmp43_ = g_strconcat (_tmp42_, " --evemu-events=/dev/zero=", NULL);
	_tmp44_ = _tmp43_;
	_tmp45_ = g_strconcat (_tmp44_, log, NULL);
	_tmp46_ = _tmp45_;
	_tmp47_ = g_strconcat (_tmp46_, " -- ", NULL);
	_tmp48_ = _tmp47_;
	_tmp49_ = readbyte_path;
	_tmp50_ = g_strconcat (_tmp48_, _tmp49_, NULL);
	_tmp51_ = _tmp50_;
	_tmp52_ = g_strconcat (_tmp51_, " /dev/zero", NULL);
	_tmp53_ = _tmp52_;
	spawn (_tmp53_, &_tmp54_, &_tmp55_, &_tmp56_);
	_g_free0 (sout);
	sout = _tmp54_;
	_g_free0 (serr);
	serr = _tmp55_;
	exit = _tmp56_;
	_g_free0 (_tmp53_);
	_g_free0 (_tmp51_);
	_g_free0 (_tmp48_);
	_g_free0 (_tmp46_);
	_g_free0 (_tmp44_);
	_tmp57_ = serr;
	_vala_assert (string_contains (_tmp57_, "two different devices"), "serr.contains (\"two different devices\")");
	g_assert_cmpint (exit, ==, 256);
	_tmp58_ = sout;
	g_assert_cmpstr (_tmp58_, ==, "\0");
	_tmp59_ = file_contents (log);
	_tmp60_ = _tmp59_;
	g_assert_cmpstr (_tmp60_, ==, "# EVEMU 1.2\n# device /dev/null\n\n");
	_g_free0 (_tmp60_);
	g_remove (log);
	_tmp61_ = umockdev_record_path;
	_tmp62_ = g_strconcat (_tmp61_, " --evemu-events /dev/null -- true", NULL);
	_tmp63_ = _tmp62_;
	spawn (_tmp63_, &_tmp64_, &_tmp65_, &_tmp66_);
	_g_free0 (sout);
	sout = _tmp64_;
	_g_free0 (serr);
	serr = _tmp65_;
	exit = _tmp66_;
	_g_free0 (_tmp63_);
	g_assert_cmpint (exit, !=, 1);
	_tmp67_ = sout;
	g_assert_cmpstr (_tmp67_, ==, "");
	_tmp68_ = serr;
	_vala_assert (string_contains (_tmp68_, "--ioctl"), "serr.contains (\"--ioctl\")");
	_tmp69_ = serr;
	_vala_assert (string_contains (_tmp69_, "="), "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;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	GRegex* port_re = NULL;
	GMatchInfo* match = NULL;
	GRegex* _tmp17_;
	const gchar* _tmp18_;
	GMatchInfo* _tmp19_ = NULL;
	gboolean _tmp20_;
	gchar* busnum = NULL;
	GMatchInfo* _tmp22_;
	gchar* _tmp23_;
	gchar* devnum = NULL;
	GMatchInfo* _tmp24_;
	gchar* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_ = NULL;
	gchar* _tmp32_ = NULL;
	gint _tmp33_ = 0;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	gchar* cmd = NULL;
	gchar* _tmp36_;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	const gchar* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_ = NULL;
	gchar* _tmp44_ = NULL;
	gint _tmp45_ = 0;
	const gchar* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	const gchar* _tmp49_;
	const gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_ = NULL;
	gchar* _tmp54_ = NULL;
	gint _tmp55_ = 0;
	const gchar* _tmp56_;
	const gchar* _tmp57_;
	const gchar* _tmp58_;
	GError* _inner_error0_ = NULL;
	spawn ("which gphoto2", &_tmp0_, &_tmp1_, &_tmp2_);
	_g_free0 (sout);
	sout = _tmp0_;
	_g_free0 (serr);
	serr = _tmp1_;
	exit = _tmp2_;
	if (exit != 0) {
		FILE* _tmp3_;
		FILE* _tmp4_;
		_tmp3_ = stdout;
		fprintf (_tmp3_, "[SKIP: gphoto2 not installed] ");
		_tmp4_ = stdout;
		fflush (_tmp4_);
		_g_free0 (serr);
		_g_free0 (sout_record);
		_g_free0 (sout);
		return;
	}
	spawn ("gphoto2 --auto-detect", &_tmp5_, &_tmp6_, &_tmp7_);
	_g_free0 (sout);
	sout = _tmp5_;
	_g_free0 (serr);
	serr = _tmp6_;
	exit = _tmp7_;
	if (exit != 0) {
		FILE* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp8_ = stdout;
		_tmp9_ = sout;
		_tmp10_ = serr;
		_tmp11_ = g_strconcat (_tmp9_, _tmp10_, NULL);
		_tmp12_ = _tmp11_;
		fprintf (_tmp8_, "[SKIP: gphoto2 --auto-detect failed: %s] ", _tmp12_);
		_g_free0 (_tmp12_);
		_g_free0 (serr);
		_g_free0 (sout_record);
		_g_free0 (sout);
		return;
	}
	{
		GRegex* _tmp13_ = NULL;
		GRegex* _tmp14_;
		GRegex* _tmp15_;
		_tmp14_ = g_regex_new ("usb:([0-9]+),([0-9]+)", 0, 0, &_inner_error0_);
		_tmp13_ = _tmp14_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch15_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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
		_tmp15_ = _tmp13_;
		_tmp13_ = NULL;
		_g_regex_unref0 (port_re);
		port_re = _tmp15_;
		_g_regex_unref0 (_tmp13_);
	}
	goto __finally15;
	__catch15_g_regex_error:
	{
		GError* e = NULL;
		const gchar* _tmp16_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp16_ = e->message;
		g_error ("test-umockdev-record.vala:830: Internal error building regex: %s", _tmp16_);
		_g_error_free0 (e);
	}
	__finally15:
	if (G_UNLIKELY (_inner_error0_ != 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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp17_ = port_re;
	_tmp18_ = sout;
	_tmp20_ = g_regex_match (_tmp17_, _tmp18_, 0, &_tmp19_);
	_g_match_info_unref0 (match);
	match = _tmp19_;
	if (!_tmp20_) {
		FILE* _tmp21_;
		_tmp21_ = stdout;
		fprintf (_tmp21_, "[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;
	}
	_tmp22_ = match;
	_tmp23_ = g_match_info_fetch (_tmp22_, 1);
	busnum = _tmp23_;
	_tmp24_ = match;
	_tmp25_ = g_match_info_fetch (_tmp24_, 2);
	devnum = _tmp25_;
	_tmp26_ = umockdev_record_path;
	_tmp27_ = busnum;
	_tmp28_ = devnum;
	_tmp29_ = g_strdup_printf ("sh -c '%s /dev/bus/usb/%s/%s > gphoto-test.umockdev'", _tmp26_, _tmp27_, _tmp28_);
	_tmp30_ = _tmp29_;
	spawn (_tmp30_, &_tmp31_, &_tmp32_, &_tmp33_);
	_g_free0 (sout);
	sout = _tmp31_;
	_g_free0 (serr);
	serr = _tmp32_;
	exit = _tmp33_;
	_g_free0 (_tmp30_);
	_tmp34_ = serr;
	g_assert_cmpstr (_tmp34_, ==, "");
	_tmp35_ = sout;
	g_assert_cmpstr (_tmp35_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp36_ = g_strdup ("sh -c 'gphoto2 -l; gphoto2 -L'");
	cmd = _tmp36_;
	_tmp37_ = umockdev_record_path;
	_tmp38_ = busnum;
	_tmp39_ = devnum;
	_tmp40_ = cmd;
	_tmp41_ = g_strdup_printf ("%s -i /dev/bus/usb/%s/%s=gphoto-test.ioctl -- %s", _tmp37_, _tmp38_, _tmp39_, _tmp40_);
	_tmp42_ = _tmp41_;
	spawn (_tmp42_, &_tmp43_, &_tmp44_, &_tmp45_);
	_g_free0 (sout_record);
	sout_record = _tmp43_;
	_g_free0 (serr);
	serr = _tmp44_;
	exit = _tmp45_;
	_g_free0 (_tmp42_);
	_tmp46_ = serr;
	g_assert_cmpstr (_tmp46_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp47_ = umockdev_run_path;
	_tmp48_ = busnum;
	_tmp49_ = devnum;
	_tmp50_ = cmd;
	_tmp51_ = g_strdup_printf ("%s -d gphoto-test.umockdev -i /dev/bus/usb/%s/%s=gphoto-test.ioctl -- " \
"%s", _tmp47_, _tmp48_, _tmp49_, _tmp50_);
	_tmp52_ = _tmp51_;
	spawn (_tmp52_, &_tmp53_, &_tmp54_, &_tmp55_);
	_g_free0 (sout);
	sout = _tmp53_;
	_g_free0 (serr);
	serr = _tmp54_;
	exit = _tmp55_;
	_g_free0 (_tmp52_);
	_tmp56_ = serr;
	g_assert_cmpstr (_tmp56_, ==, "");
	g_assert_cmpint (exit, ==, 0);
	_tmp57_ = sout;
	_tmp58_ = sout_record;
	g_assert_cmpstr (_tmp57_, ==, _tmp58_);
	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_simple_fopen_gtest_func (void)
{
	t_system_script_log_simple_fopen ();
}

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,
            gint 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_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	g_test_init ((gint*) (&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_;
	_tmp17_ = rootdir;
	_tmp18_ = g_build_filename (_tmp17_, "tests", "readbyte", NULL);
	_g_free0 (readbyte_path);
	readbyte_path = _tmp18_;
	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-simple-fopen", _t_system_script_log_simple_fopen_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;
}

