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

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

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include <glib/gstdio.h>
#include <signal.h>
#include <sys/types.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 _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);


extern gchar* rootdir;
gchar* rootdir = NULL;

#define umockdev_run_command "env LC_ALL=C umockdev-run "
gboolean have_program (const gchar* program);
gboolean get_program_out (const gchar* program, const gchar* command, gchar** sout, gchar** serr, gint* exit);
void check_program_out (const gchar* program, const gchar* run_command, const gchar* expected_out);
void check_program_error (const gchar* program, const gchar* run_command, const gchar* expected_err);
void t_gphoto_detect (void);
void t_run_invalid_args (void);
void t_run_invalid_ioctl (void);
void t_gphoto_folderlist (void);
void t_gphoto_filelist (void);
void t_input_touchpad (void);
gint _vala_main (gchar** args, int args_length1);
static void _t_run_invalid_args_gcallback (void);
static void _t_run_invalid_ioctl_gcallback (void);
static void _t_gphoto_detect_gcallback (void);
static void _t_gphoto_folderlist_gcallback (void);
static void _t_gphoto_filelist_gcallback (void);
static void _t_input_touchpad_gcallback (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);


gboolean have_program (const gchar* program) {
	gboolean result = FALSE;
	gchar* sout = NULL;
	gint exit = 0;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (program != NULL, FALSE);
	{
		const gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_ = NULL;
		gint _tmp4_ = 0;
		_tmp0_ = program;
		_tmp1_ = g_strconcat ("which ", _tmp0_, NULL);
		_tmp2_ = _tmp1_;
		g_spawn_command_line_sync (_tmp2_, &_tmp3_, NULL, &_tmp4_, &_inner_error_);
		_g_free0 (sout);
		sout = _tmp3_;
		exit = _tmp4_;
		_g_free0 (_tmp2_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_SPAWN_ERROR) {
				goto __catch0_g_spawn_error;
			}
			_g_free0 (sout);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
	}
	goto __finally0;
	__catch0_g_spawn_error:
	{
		GError* e = NULL;
		FILE* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp5_ = stderr;
		_tmp6_ = program;
		_tmp7_ = e->message;
		fprintf (_tmp5_, "cannot call which %s: %s\n", _tmp6_, _tmp7_);
		abort ();
		_g_error_free0 (e);
	}
	__finally0:
	if (_inner_error_ != NULL) {
		_g_free0 (sout);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return FALSE;
	}
	result = exit == 0;
	_g_free0 (sout);
	return result;
}


gboolean get_program_out (const gchar* program, const gchar* command, gchar** sout, gchar** serr, gint* exit) {
	gchar* _vala_sout = NULL;
	gchar* _vala_serr = NULL;
	gint _vala_exit = 0;
	gboolean result = FALSE;
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (program != NULL, FALSE);
	g_return_val_if_fail (command != NULL, FALSE);
	_tmp0_ = program;
	_tmp1_ = have_program (_tmp0_);
	if (!_tmp1_) {
		FILE* _tmp2_;
		const gchar* _tmp3_;
		_tmp2_ = stderr;
		_tmp3_ = program;
		fprintf (_tmp2_, "[SKIP: %s not installed] ", _tmp3_);
		result = FALSE;
		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;
		}
		return result;
	}
	{
		const gchar* _tmp4_;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		gint _tmp7_ = 0;
		_tmp4_ = command;
		g_spawn_command_line_sync (_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_, &_inner_error_);
		_g_free0 (_vala_sout);
		_vala_sout = _tmp5_;
		_g_free0 (_vala_serr);
		_vala_serr = _tmp6_;
		_vala_exit = _tmp7_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_SPAWN_ERROR) {
				goto __catch1_g_spawn_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
	}
	goto __finally1;
	__catch1_g_spawn_error:
	{
		GError* e = NULL;
		FILE* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp8_ = stderr;
		_tmp9_ = command;
		_tmp10_ = e->message;
		fprintf (_tmp8_, "cannot call %s: %s\n", _tmp9_, _tmp10_);
		abort ();
		_g_error_free0 (e);
	}
	__finally1:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return FALSE;
	}
	result = TRUE;
	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;
	}
	return result;
}


void check_program_out (const gchar* program, const gchar* run_command, const gchar* expected_out) {
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gint _tmp6_ = 0;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gint _tmp12_;
	g_return_if_fail (program != NULL);
	g_return_if_fail (run_command != NULL);
	g_return_if_fail (expected_out != NULL);
	_tmp0_ = program;
	_tmp1_ = run_command;
	_tmp2_ = g_strconcat (umockdev_run_command, _tmp1_, NULL);
	_tmp3_ = _tmp2_;
	_tmp7_ = get_program_out (_tmp0_, _tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	_g_free0 (sout);
	sout = _tmp4_;
	_g_free0 (serr);
	serr = _tmp5_;
	exit = _tmp6_;
	_tmp8_ = !_tmp7_;
	_g_free0 (_tmp3_);
	if (_tmp8_) {
		_g_free0 (serr);
		_g_free0 (sout);
		return;
	}
	_tmp9_ = sout;
	_tmp10_ = expected_out;
	g_assert_cmpstr (_tmp9_, ==, _tmp10_);
	_tmp11_ = serr;
	g_assert_cmpstr (_tmp11_, ==, "");
	_tmp12_ = exit;
	g_assert_cmpint (_tmp12_, ==, 0);
	_g_free0 (serr);
	_g_free0 (sout);
}


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


void check_program_error (const gchar* program, const gchar* run_command, const gchar* expected_err) {
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gint _tmp6_ = 0;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gboolean _tmp11_ = FALSE;
	gint _tmp15_;
	gint _tmp16_;
	gboolean _tmp17_ = FALSE;
	const gchar* _tmp18_;
	g_return_if_fail (program != NULL);
	g_return_if_fail (run_command != NULL);
	g_return_if_fail (expected_err != NULL);
	_tmp0_ = program;
	_tmp1_ = run_command;
	_tmp2_ = g_strconcat (umockdev_run_command, _tmp1_, NULL);
	_tmp3_ = _tmp2_;
	_tmp7_ = get_program_out (_tmp0_, _tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	_g_free0 (sout);
	sout = _tmp4_;
	_g_free0 (serr);
	serr = _tmp5_;
	exit = _tmp6_;
	_tmp8_ = !_tmp7_;
	_g_free0 (_tmp3_);
	if (_tmp8_) {
		_g_free0 (serr);
		_g_free0 (sout);
		return;
	}
	_tmp9_ = serr;
	_tmp10_ = expected_err;
	_tmp11_ = string_contains (_tmp9_, _tmp10_);
	if (!_tmp11_) {
		FILE* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		_tmp12_ = stderr;
		_tmp13_ = expected_err;
		_tmp14_ = serr;
		fprintf (_tmp12_, "Error message does not contain expected '%s':\n------\n%s\n----\n", _tmp13_, _tmp14_);
		abort ();
	}
	_tmp15_ = exit;
	g_assert_cmpint (_tmp15_, !=, 0);
	_tmp16_ = exit;
	_tmp17_ = WIFEXITED (_tmp16_);
	_vala_assert (_tmp17_, "Process.if_exited (exit)");
	_tmp18_ = sout;
	g_assert_cmpstr (_tmp18_, ==, "");
	_g_free0 (serr);
	_g_free0 (sout);
}


void t_gphoto_detect (void) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	_tmp0_ = rootdir;
	_tmp1_ = g_strconcat ("-l ", _tmp0_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "/devices/cameras/canon-powershot-sx200.umockdev -i /dev/bus/usb/001/01" \
"1=", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = rootdir;
	_tmp6_ = g_strconcat (_tmp4_, _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, "/devices/cameras/canon-powershot-sx200.ioctl -- gphoto2 --auto-detect", NULL);
	_tmp9_ = _tmp8_;
	check_program_out ("gphoto2", _tmp9_, "Model                          Port            \n" \
"----------------------------------------------------------\n" \
"Canon PowerShot SX200 IS       usb:001,011     \n");
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
}


void t_run_invalid_args (void) {
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	check_program_error ("true", "", "--help");
	_g_free0 (serr);
	_g_free0 (sout);
}


void t_run_invalid_ioctl (void) {
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	_tmp0_ = rootdir;
	_tmp1_ = g_strconcat ("-l ", _tmp0_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "/devices/cameras/canon-powershot-sx200.umockdev -i ", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strconcat (_tmp4_, "/dev/bus/usb/001/011=/non/existing.ioctl -- gphoto2 -l", NULL);
	_tmp6_ = _tmp5_;
	check_program_error ("gphoto2", _tmp6_, "/non/existing.ioctl");
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp7_ = rootdir;
	_tmp8_ = g_strconcat ("-l ", _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat (_tmp9_, "/devices/cameras/canon-powershot-sx200.umockdev -i ", NULL);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strconcat (_tmp11_, "/dev/bus/usb/001/011=/dev/null -- gphoto2 -l", NULL);
	_tmp13_ = _tmp12_;
	check_program_error ("gphoto2", _tmp13_, "001/011");
	_g_free0 (_tmp13_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	_tmp14_ = rootdir;
	_tmp15_ = g_strconcat ("-l ", _tmp14_, NULL);
	_tmp16_ = _tmp15_;
	_tmp17_ = g_strconcat (_tmp16_, "/devices/cameras/canon-powershot-sx200.umockdev -i ", NULL);
	_tmp18_ = _tmp17_;
	_tmp19_ = g_strconcat (_tmp18_, "/dev/bus/usb/001/011=", NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = rootdir;
	_tmp22_ = g_strconcat (_tmp20_, _tmp21_, NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strconcat (_tmp23_, "/NEWS -- gphoto2 -l", NULL);
	_tmp25_ = _tmp24_;
	check_program_error ("gphoto2", _tmp25_, "001/011");
	_g_free0 (_tmp25_);
	_g_free0 (_tmp23_);
	_g_free0 (_tmp20_);
	_g_free0 (_tmp18_);
	_g_free0 (_tmp16_);
	_g_free0 (serr);
	_g_free0 (sout);
}


void t_gphoto_folderlist (void) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	_tmp0_ = rootdir;
	_tmp1_ = g_strconcat ("-l ", _tmp0_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "/devices/cameras/canon-powershot-sx200.umockdev -i /dev/bus/usb/001/01" \
"1=", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = rootdir;
	_tmp6_ = g_strconcat (_tmp4_, _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, "/devices/cameras/canon-powershot-sx200.ioctl -- gphoto2 -l", NULL);
	_tmp9_ = _tmp8_;
	check_program_out ("gphoto2", _tmp9_, "There is 1 folder in folder '/'.\n" \
" - store_00010001\n" \
"There is 1 folder in folder '/store_00010001'.\n" \
" - DCIM\n" \
"There is 1 folder in folder '/store_00010001/DCIM'.\n" \
" - 100CANON\n" \
"There are 0 folders in folder '/store_00010001/DCIM/100CANON'.\n");
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
}


void t_gphoto_filelist (void) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	_tmp0_ = rootdir;
	_tmp1_ = g_strconcat ("-l ", _tmp0_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "/devices/cameras/canon-powershot-sx200.umockdev -i /dev/bus/usb/001/01" \
"1=", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = rootdir;
	_tmp6_ = g_strconcat (_tmp4_, _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, "/devices/cameras/canon-powershot-sx200.ioctl -- gphoto2 -L", NULL);
	_tmp9_ = _tmp8_;
	check_program_out ("gphoto2", _tmp9_, "There is no file in folder '/'.\n" \
"There is no file in folder '/store_00010001'.\n" \
"There is no file in folder '/store_00010001/DCIM'.\n" \
"There are 9 files in folder '/store_00010001/DCIM/100CANON'.\n" \
"#1     IMG_0095.JPG               rd  1640 KB 3264x2448 image/jpeg\n" \
"#2     IMG_0096.JPG               rd  1669 KB 3264x2448 image/jpeg\n" \
"#3     IMG_0097.JPG               rd  1741 KB 3264x2448 image/jpeg\n" \
"#4     IMG_0098.JPG               rd  1328 KB 3264x2448 image/jpeg\n" \
"#5     IMG_0099.JPG               rd  1290 KB 3264x2448 image/jpeg\n" \
"#6     IMG_0100.JPG               rd  2340 KB 3264x2448 image/jpeg\n" \
"#7     IMG_0101.JPG               rd  1916 KB 3264x2448 image/jpeg\n" \
"#8     IMG_0102.JPG               rd  2026 KB 3264x2448 image/jpeg\n" \
"#9     IMG_0103.JPG               rd  1810 KB 3264x2448 image/jpeg\n");
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
}


void t_input_touchpad (void) {
	gboolean _tmp0_ = FALSE;
	GPid xorg_pid = 0;
	gint timeout;
	gint _tmp27_;
	gchar* sout = NULL;
	gchar* serr = NULL;
	gint exit = 0;
	gchar* _tmp29_ = NULL;
	gchar* _tmp30_ = NULL;
	gint _tmp31_ = 0;
	gboolean _tmp32_ = FALSE;
	const gchar* _tmp33_;
	gint _tmp34_;
	const gchar* _tmp35_;
	gboolean _tmp36_ = FALSE;
	gchar* _tmp37_ = NULL;
	gchar* _tmp38_ = NULL;
	gint _tmp39_ = 0;
	gboolean _tmp40_ = FALSE;
	const gchar* _tmp41_;
	gint _tmp42_;
	const gchar* _tmp43_;
	gboolean _tmp44_ = FALSE;
	const gchar* _tmp45_;
	gboolean _tmp46_ = FALSE;
	GPid _tmp47_;
	gint status = 0;
	GPid _tmp48_;
	gint _tmp49_ = 0;
	GPid _tmp50_;
	GError * _inner_error_ = NULL;
	_tmp0_ = have_program ("Xorg");
	if (!_tmp0_) {
		FILE* _tmp1_;
		_tmp1_ = stderr;
		fprintf (_tmp1_, "[SKIP: Xorg not installed] ");
		return;
	}
	{
		gchar* _tmp2_;
		gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		const gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar** _tmp19_ = NULL;
		gchar** _tmp20_;
		gint _tmp20__length1;
		GPid _tmp21_ = 0;
		_tmp2_ = g_strdup ("umockdev-run");
		_tmp3_ = g_strdup ("-l");
		_tmp4_ = rootdir;
		_tmp5_ = g_strconcat (_tmp4_, "/devices/input/synaptics-touchpad.umockdev", NULL);
		_tmp6_ = g_strdup ("-i");
		_tmp7_ = rootdir;
		_tmp8_ = g_strconcat ("/dev/input/event12=", _tmp7_, NULL);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_strconcat (_tmp9_, "/devices/input/synaptics-touchpad.ioctl", NULL);
		_tmp11_ = g_strdup ("--");
		_tmp12_ = g_strdup ("Xorg");
		_tmp13_ = g_strdup ("-config");
		_tmp14_ = rootdir;
		_tmp15_ = g_strconcat (_tmp14_, "/tests/xorg-dummy.conf", NULL);
		_tmp16_ = g_strdup ("-logfile");
		_tmp17_ = g_strdup ("/dev/null");
		_tmp18_ = g_strdup (":5");
		_tmp19_ = g_new0 (gchar*, 12 + 1);
		_tmp19_[0] = _tmp2_;
		_tmp19_[1] = _tmp3_;
		_tmp19_[2] = _tmp5_;
		_tmp19_[3] = _tmp6_;
		_tmp19_[4] = _tmp10_;
		_tmp19_[5] = _tmp11_;
		_tmp19_[6] = _tmp12_;
		_tmp19_[7] = _tmp13_;
		_tmp19_[8] = _tmp15_;
		_tmp19_[9] = _tmp16_;
		_tmp19_[10] = _tmp17_;
		_tmp19_[11] = _tmp18_;
		_tmp20_ = _tmp19_;
		_tmp20__length1 = 12;
		g_spawn_async (NULL, _tmp20_, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &_tmp21_, &_inner_error_);
		xorg_pid = _tmp21_;
		_tmp20_ = (_vala_array_free (_tmp20_, _tmp20__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp9_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_SPAWN_ERROR) {
				goto __catch2_g_spawn_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally2;
	__catch2_g_spawn_error:
	{
		GError* e = NULL;
		FILE* _tmp22_;
		const gchar* _tmp23_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp22_ = stderr;
		_tmp23_ = e->message;
		fprintf (_tmp22_, "cannot call Xorg: %s\n", _tmp23_);
		abort ();
		_g_error_free0 (e);
	}
	__finally2:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	timeout = 50;
	while (TRUE) {
		gint _tmp24_;
		gint _tmp25_;
		gboolean _tmp26_ = FALSE;
		_tmp24_ = timeout;
		if (!(_tmp24_ > 0)) {
			break;
		}
		_tmp25_ = timeout;
		timeout = _tmp25_ - 1;
		usleep ((guint) 100000);
		_tmp26_ = g_file_test ("/tmp/.X11-unix/X5", G_FILE_TEST_EXISTS);
		if (_tmp26_) {
			break;
		}
	}
	_tmp27_ = timeout;
	if (_tmp27_ <= 0) {
		FILE* _tmp28_;
		_tmp28_ = stderr;
		fprintf (_tmp28_, "Xorg failed to start up\n");
		abort ();
	}
	_tmp32_ = get_program_out ("xinput", "env DISPLAY=:5 xinput", &_tmp29_, &_tmp30_, &_tmp31_);
	_g_free0 (sout);
	sout = _tmp29_;
	_g_free0 (serr);
	serr = _tmp30_;
	exit = _tmp31_;
	_vala_assert (_tmp32_, "get_program_out (\"xinput\", \"env DISPLAY=:5 xinput\", out sout, out serr, out exit)");
	_tmp33_ = serr;
	g_assert_cmpstr (_tmp33_, ==, "");
	_tmp34_ = exit;
	g_assert_cmpint (_tmp34_, ==, 0);
	_tmp35_ = sout;
	_tmp36_ = string_contains (_tmp35_, "SynPS/2 Synaptics TouchPad");
	_vala_assert (_tmp36_, "sout.contains (\"SynPS/2 Synaptics TouchPad\")");
	_tmp40_ = get_program_out ("xinput", "env DISPLAY=:5 xinput --list-props 'SynPS/2 Synaptics TouchPad'", &_tmp37_, &_tmp38_, &_tmp39_);
	_g_free0 (sout);
	sout = _tmp37_;
	_g_free0 (serr);
	serr = _tmp38_;
	exit = _tmp39_;
	_vala_assert (_tmp40_, "get_program_out (\"xinput\", \"env DISPLAY=:5 xinput --list-props 'SynPS/2 Synaptics TouchPad'\",             out sout, out serr, out exit)");
	_tmp41_ = serr;
	g_assert_cmpstr (_tmp41_, ==, "");
	_tmp42_ = exit;
	g_assert_cmpint (_tmp42_, ==, 0);
	_tmp43_ = sout;
	_tmp44_ = string_contains (_tmp43_, "Synaptics Two-Finger Scrolling");
	_vala_assert (_tmp44_, "sout.contains (\"Synaptics Two-Finger Scrolling\")");
	_tmp45_ = sout;
	_tmp46_ = string_contains (_tmp45_, "/dev/input/event12");
	_vala_assert (_tmp46_, "sout.contains (\"/dev/input/event12\")");
	_tmp47_ = xorg_pid;
	kill ((pid_t) _tmp47_, SIGTERM);
	_tmp48_ = xorg_pid;
	waitpid ((pid_t) _tmp48_, &_tmp49_, 0);
	status = _tmp49_;
	_tmp50_ = xorg_pid;
	g_spawn_close_pid (_tmp50_);
	_g_free0 (serr);
	_g_free0 (sout);
}


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


static void _t_run_invalid_ioctl_gcallback (void) {
	t_run_invalid_ioctl ();
}


static void _t_gphoto_detect_gcallback (void) {
	t_gphoto_detect ();
}


static void _t_gphoto_folderlist_gcallback (void) {
	t_gphoto_folderlist ();
}


static void _t_gphoto_filelist_gcallback (void) {
	t_gphoto_filelist ();
}


static void _t_input_touchpad_gcallback (void) {
	t_input_touchpad ();
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* top_srcdir;
	const gchar* _tmp2_;
	gint _tmp6_ = 0;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_getenv ("TOP_SRCDIR");
	_tmp1_ = g_strdup (_tmp0_);
	top_srcdir = _tmp1_;
	_tmp2_ = top_srcdir;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = top_srcdir;
		_tmp4_ = g_strdup (_tmp3_);
		_g_free0 (rootdir);
		rootdir = _tmp4_;
	} else {
		gchar* _tmp5_;
		_tmp5_ = g_strdup (".");
		_g_free0 (rootdir);
		rootdir = _tmp5_;
	}
	g_test_add_func ("/umockdev-run/invalid-args", _t_run_invalid_args_gcallback);
	g_test_add_func ("/umockdev-run/invalid-ioctl", _t_run_invalid_ioctl_gcallback);
	g_test_add_func ("/umockdev-run/integration/gphoto-detect", _t_gphoto_detect_gcallback);
	g_test_add_func ("/umockdev-run/integration/gphoto-folderlist", _t_gphoto_folderlist_gcallback);
	g_test_add_func ("/umockdev-run/integration/gphoto-filelist", _t_gphoto_filelist_gcallback);
	g_test_add_func ("/umockdev-run/integration/input-touchpad", _t_input_touchpad_gcallback);
	_tmp6_ = g_test_run ();
	result = _tmp6_;
	_g_free0 (top_srcdir);
	return result;
}


int main (int argc, char ** argv) {
	g_type_init ();
	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);
}



