#!/usr/local/bin/php
<?php

/*
     This script will chroot via the builder system to test
     the local php setup.  If we can perform a series of
     small tests to ensure the php environment is sane.
*/

require_once('util.inc');
require_once('xmlparse.inc');
require_once('config.lib.inc');

$config = parse_config();

$passed_tests = true;

// Test config.inc
if ($config['system']['hostname'] == '') {
	$passed_tests = false;
}

// Test for php-fcgi
$php_cgi = trim(`php-cgi -v | grep cgi-fcgi`);
if (stristr($php_cgi, 'cgi-fcgi')) {
	echo 'FCGI-PASSED ';
} else {
	echo 'FCGI-FAILED ';
	exit(1);
}

if ($passed_tests) {
	echo 'PASSED';
	exit(0);
}

echo 'FAILED';
exit(1);
