pts-core: Just mention PHP 5.3 as the new base requirement. Code still should largely...
[phoronix-test-suite.git] / pts-core / phoronix-test-suite.php
blobdb2cf407e46532b4429d8299e50d2923af5a0b40
1 <?php
3 /*
4 Phoronix Test Suite
5 URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
6 Copyright (C) 2008 - 2015, Phoronix Media
7 Copyright (C) 2008 - 2015, Michael Larabel
8 phoronix-test-suite.php: The main code for initalizing the Phoronix Test Suite
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 setlocale(LC_NUMERIC, 'C');
25 define('PTS_PATH', dirname(dirname(__FILE__)) . '/');
27 // PTS_MODE types
28 // CLIENT = Standard Phoronix Test Suite Client
29 // LIB = Only load select PTS files
30 // SILENT = Load all normal pts-core files, but don't run client code
31 if(!defined('PTS_MODE'))
33 define('PTS_MODE', in_array(($m = getenv('PTS_MODE')), array('CLIENT', 'LIB', 'WEB_CLIENT', 'SILENT')) ? $m : 'CLIENT');
36 // Any PHP default memory limit should be fine for PTS, until you run image quality comparison tests that begins to consume memory
37 if(stripos(phpversion(), 'hhvm') === false)
39 ini_set('memory_limit', '256M');
42 if(getenv('PTS_MODE') == 'CLIENT' && ini_get('open_basedir') != false)
44 $passes = true;
45 $open_basedir = ini_get('open_basedir');
47 if($open_basedir != false)
49 $is_in_allowed_dir = false;
50 foreach(explode(':', $open_basedir) as $allowed_dir)
52 if(strpos(PTS_PATH, $allowed_dir) === 0)
54 $is_in_allowed_dir = true;
55 break;
59 if($is_in_allowed_dir == false)
61 $passes = false;
66 if($passes == false)
68 echo PHP_EOL . 'ERROR: The php.ini configuration open_basedir directive is preventing ' . PTS_PATH . ' from loading.' . PHP_EOL;
69 return false;
71 else
73 echo PHP_EOL . 'NOTICE: The php.ini configuration is using the "open_basedir" directive, which may prevent some parts of the Phoronix Test Suite from working. See the Phoronix Test Suite documentation for more details and to disable this setting.' . PHP_EOL;
77 require(PTS_PATH . 'pts-core/pts-core.php');
79 if(!PTS_IS_CLIENT)
81 // pts-core is acting as a library, return now since no need to run client code
82 return;
85 // Default to C locale
86 setlocale(LC_ALL, 'C');
88 // Needed for shutdown functions
89 // declare(ticks = 1);
91 $sent_command = strtolower(str_replace('-', '_', (isset($argv[1]) ? $argv[1] : null)));
92 $quick_start_options = array('dump_possible_options');
93 pts_define('QUICK_START', in_array($sent_command, $quick_start_options));
95 if(QUICK_START == false)
97 pts_client::program_requirement_checks(true);
99 pts_client::init(); // Initalize the Phoronix Test Suite (pts-core) client
100 $pass_args = array();
102 if(is_file(PTS_PATH . 'pts-core/commands/' . $sent_command . '.php') == false)
104 $replaced = false;
106 if(pts_module::valid_run_command($sent_command))
108 $replaced = true;
110 else if(isset($argv[1]) && strpos($argv[1], '.openbenchmarking') !== false && is_readable($argv[1]))
112 $sent_command = 'openbenchmarking_launcher';
113 $argv[2] = $argv[1];
114 $argc = 3;
115 $replaced = true;
117 else
119 $aliases = pts_storage_object::read_from_file(PTS_TEMP_STORAGE, 'command_alias_list');
120 if($aliases == null)
122 $aliases = pts_documentation::client_commands_aliases();
125 if(isset($aliases[$sent_command]))
127 $sent_command = $aliases[$sent_command];
128 $replaced = true;
132 if($replaced == false)
134 // Show help command, since there are no valid commands
135 $sent_command = 'help';
140 pts_define('PTS_USER_LOCK', function_exists('posix_getpid') ? PTS_USER_PATH . 'run-lock-' . posix_getpid() : tempnam(PTS_USER_PATH, 'run-lock-'));
142 if(QUICK_START == false)
144 if(pts_client::create_lock(PTS_USER_LOCK) == false)
146 //trigger_error('It appears that the Phoronix Test Suite is already running.' . PHP_EOL . 'For proper results, only run one instance at a time.', E_USER_WARNING);
149 register_shutdown_function(array('pts_client', 'process_shutdown_tasks'));
150 //pcntl_signal(SIGTERM, array('pts_client', 'exit_client'));
152 if(pts_client::read_env('PTS_IGNORE_MODULES') == false)
154 pts_client::module_framework_init(); // Initialize the PTS module system
158 // Read passed arguments
159 for($i = 2; $i < $argc && isset($argv[$i]); $i++)
161 array_push($pass_args, $argv[$i]);
164 if(QUICK_START == false)
166 pts_client::user_agreement_check($sent_command);
168 // OpenBenchmarking.org
169 pts_openbenchmarking::refresh_repository_lists();
172 pts_client::execute_command($sent_command, $pass_args); // Run command
174 if(QUICK_START == false)
176 pts_client::release_lock(PTS_USER_LOCK);