This file is indexed.

/usr/share/phoronix-test-suite/pts-core/commands/interactive.php is in phoronix-test-suite 4.8.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php

/*
	Phoronix Test Suite
	URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
	Copyright (C) 2011 - 2013, Phoronix Media
	Copyright (C) 2011 - 2013, Michael Larabel

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program 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 General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

class interactive implements pts_option_interface
{
	const doc_section = 'System';
	const doc_description = 'A simple text-driven interactive interface to the Phoronix Test Suite.';

	public static function run($r)
	{
		$is_moscow = pts_flags::os_identifier_hash() == 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc';

		if($is_moscow)
		{
			// Auto mount?
			$drives = pts_file_io::glob('/dev/sda*');
			sort($drives);

			if(false && count($drives) > 0 && !is_dir('/media/pts-auto-mount') && is_writable('/media/'))
			{
				$last_drive = array_pop($drives);
				echo PHP_EOL . 'Attempting to auto-mount drive: ' . $last_drive . PHP_EOL;
				mkdir('/media/pts-auto-mount');
				exec('mount ' . $last_drive . ' /media/pts-auto-mount');
				putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/');
			}

			// Auto save results
			$test_results_name = phodevi::read_property('motherboard', 'serial-number');

			if($test_results_name == null)
			{
				$test_results_name = phodevi::read_name('motherboard');
			}
			if($test_results_name == null)
			{
				$test_results_name = phodevi::read_property('system', 'vendor-identifier');
			}

			putenv('TEST_RESULTS_NAME=' . str_replace(' ', null, $test_results_name));
			putenv('TEST_RESULTS_IDENTIFIER=' . $test_results_name);
			putenv('TEST_RESULTS_DESCRIPTION=Tests using ' . phodevi::read_property('system', 'operating-system') . ' on ' . date('d F Y') . ' of ' . $test_results_name . '.');
			self::select_drive_mount();
		}

		pts_openbenchmarking::refresh_repository_lists();
		pts_client::$display->generic_heading('Interactive Benchmarking');
		echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL;
		$reboot_on_exit = pts_flags::is_live_cd() && pts_client::user_home_directory() == '/root/';

		do
		{
			$options = array(
				'RUN_TEST' => 'Run A Test',
				'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]',
				'RUN_SYSTEM_TEST' => 'Run Complex System Test',
				'SHOW_INFO' => 'Show System Hardware / Software Information',
				'SHOW_SENSORS' => 'Show Auto-Detected System Sensors',
				'SET_RUN_COUNT' => 'Set Test Run Repetition'
				);

			if($is_moscow)
			{
				unset($options['RUN_SUITE']);
			//	$options['SELECT_DRIVE_MOUNT'] = 'Select Disk Drive To Use For Testing';
			}

			if(count(pts_client::saved_test_results()) > 0)
			{
				$options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage';
			}

			$options['EXIT'] = ($reboot_on_exit ? 'Exit & Reboot' : 'Exit');
			$response = pts_user_io::prompt_text_menu('Select Task', $options, false, true);

			switch($response)
			{
				case 'RUN_TEST':
					$supported_tests = pts_openbenchmarking::available_tests();
					$supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true);
					$longest_title_length = 0;

					foreach($supported_tests as $i => &$test_profile)
					{
						if($test_profile->get_title() == null || pts_test_run_manager::test_profile_system_compatibility_check($test_profile) == false)
						{
							unset($supported_tests[$i]);
							continue;
						}
						if($is_moscow && pts_test_install_request::test_files_available_locally($test_profile) == false)
						{
							// Don't show tests where files need to be downloaded
							unset($supported_tests[$i]);
							continue;
						}

						$longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
					}

					$t = array();
					foreach($supported_tests as $i => &$test_profile)
					{
						if($test_profile instanceof pts_test_profile)
						{
							$t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
						}
					}
					$supported_tests = $t;
					asort($supported_tests);

					$tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
					$tests_to_run = explode(',', $tests_to_run);
					pts_test_installer::standard_install($tests_to_run);
					$run_manager = pts_test_run_manager::standard_run($tests_to_run, (pts_c::defaults_mode | pts_c::auto_mode));
					if($run_manager != false)
					{
						pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
					}
					break;
				case 'RUN_SUITE':
					$possible_suites = pts_openbenchmarking::available_suites();

					foreach(array_map('strtolower', pts_types::subsystem_targets()) as $subsystem)
					{
						array_push($possible_suites, 'pts/' . $subsystem);
					}

					$suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
					foreach(explode(',', $suites_to_run) as $suite_to_run)
					{
						pts_test_installer::standard_install($suite_to_run);
						pts_test_run_manager::standard_run($suite_to_run, (pts_c::defaults_mode | pts_c::auto_mode));
					}
					break;
				case 'SELECT_DRIVE_MOUNT':
					self::select_drive_mount();
					break;
				case 'RUN_SYSTEM_TEST':
					pts_client::$display->generic_heading('System Test');
					$system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
					pts_test_installer::standard_install($system_tests);
					$run_manager = pts_test_run_manager::standard_run($system_tests, (pts_c::defaults_mode | pts_c::auto_mode));
					if($run_manager != false)
					{
						pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
					}
					break;
				case 'SHOW_INFO':
					pts_client::$display->generic_heading('System Software / Hardware Information');
					echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL;
					echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL;
					break;
				case 'SHOW_SENSORS':
					pts_client::$display->generic_heading('Detected System Sensors');
					foreach(phodevi::supported_sensors() as $sensor)
					{
						echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
					}
					break;
				case 'SET_RUN_COUNT':
					$run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
					putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
					break;
				case 'BACKUP_RESULTS_TO_USB':
					pts_client::$display->generic_heading('Backing Up Test Results');

					if($is_moscow)
					{
						$drives = pts_file_io::glob('/dev/sd*');
						sort($drives);

						if(count($drives) > 0 && is_writable('/media/'))
						{
							$select_drive = pts_user_io::prompt_text_menu('Select Drive / Partition To Save Results', $drives);
							echo PHP_EOL . 'Attempting to mount: ' . $select_drive . PHP_EOL;
							mkdir('/media/00-results-backup');
							exec('mount ' . $select_drive . ' /media/00-results-backup');
						}
					}

					foreach(pts_file_io::glob('/media/*') as $media_dir)
					{
						if(!is_writable($media_dir))
						{
							echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
							continue;
						}

						echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
						pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
						break;
					}

					if($is_moscow && is_dir('/media/00-results-backup'))
					{
						exec('umount /media/00-results-backup');
						rmdir('/media/00-results-backup');
					}
					break;
			}
			echo PHP_EOL . PHP_EOL;
		}
		while($response != 'EXIT');

		if($reboot_on_exit)
		{
			if(is_dir('/media/pts-auto-mount'))
			{
				pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
				exec('umount /media/pts-auto-mount 2>&1');
			}

			exec('reboot');
		}
	}
	private static function select_drive_mount()
	{
		$drives = pts_file_io::glob('/dev/sd*');

		if(count($drives) == 0)
		{
			echo PHP_EOL . 'No Disk Drives Found' . PHP_EOL . PHP_EOL;
		}
		else
		{
			array_push($drives, 'No HDD');
			$to_mount = pts_user_io::prompt_text_menu('Select Drive / Partition To Mount', $drives);

			if($to_mount != 'No HDD')
			{
				echo PHP_EOL . 'Attempting to mount: ' . $to_mount . PHP_EOL;
				exec('umount /media/pts-auto-mount 2>&1');
				pts_file_io::delete('/media/pts-auto-mount', null, true);
				pts_file_io::mkdir('/media/pts-auto-mount');
				echo exec('mount ' . $to_mount . ' /media/pts-auto-mount');
				putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/');
			}
			else
			{
				if(is_dir('/media/pts-auto-mount'))
				{
					exec('umount /media/pts-auto-mount');
					@rmdir('/media/pts-auto-mount');
				}

				putenv('PTS_TEST_INSTALL_ROOT_PATH=');
			}
		}
	}
}

?>