This file is indexed.

/usr/share/phoronix-test-suite/pts-core/objects/pts_virtual_test_suite.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<?php

/*
	Phoronix Test Suite
	URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
	Copyright (C) 2008 - 2011, Phoronix Media
	Copyright (C) 2008 - 2011, 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 pts_virtual_test_suite
{
	private $identifier;
	private $repo;
	private $virtual;

	private $is_virtual_os_selector = false;
	private $is_virtual_subsystem_selector = false;
	private $is_virtual_software_type = false;
	private $is_virtual_internal_tag = false;
	private $is_virtual_installed = false;

	public function __construct($identifier)
	{
		$this->identifier = $identifier;

		$identifier = explode('/', $identifier);
		$this->repo = $identifier[0];
		$this->virtual = $identifier[1];

		$this->is_virtual_os_selector = self::is_selector_os($identifier[1]);
		$this->is_virtual_subsystem_selector = self::is_selector_subsystem($identifier[1]);
		$this->is_virtual_software_type = self::is_selector_software_type($identifier[1]);
		$this->is_virtual_internal_tag = self::is_selector_internal_tag($this->repo, $this->virtual);
		$this->is_virtual_installed = ($this->virtual == 'installed');
	}
	public function __toString()
	{
		return $this->identifier;
	}
	public static function available_virtual_suites()
	{
		$virtual_suites = array();

		$possible_identifiers = array_merge(
			array('all', 'installed'),
			array_map('strtolower', self::available_operating_systems()),
			array_map('strtolower', pts_types::subsystem_targets()),
			array_map('strtolower', pts_types::test_profile_software_types())
			);

		foreach(pts_openbenchmarking::linked_repositories() as $repo)
		{
			$repo_identifiers = array_merge($possible_identifiers, self::tags_in_repo($repo));

			foreach($repo_identifiers as $id)
			{
				$virt_suite = $repo . '/' . $id;

				if(self::is_virtual_suite($virt_suite))
				{
					$virtual_suite = pts_types::identifier_to_object($virt_suite);

					if($virtual_suite instanceof pts_virtual_test_suite)
					{
						array_push($virtual_suites, $virtual_suite);
					}
				}
			}
		}

		return $virtual_suites;
	}
	public static function is_virtual_suite($identifier)
	{
		$identifier = explode('/', $identifier);
		$is_virtual_suite = false;

		if(count($identifier) == 2)
		{
			// read the repo
			pts_openbenchmarking::refresh_repository_lists(array($identifier[0]));
			$repo_index = pts_openbenchmarking::read_repository_index($identifier[0]);

			if(isset($repo_index['tests']) && is_array($repo_index['tests']))
			{
				// figure out virtual suites
				if($identifier[1] == 'all')
				{
					// virtual suite of all supported tests
					$is_virtual_suite = true;
				}
				else if($identifier[1] == 'installed')
				{
					// virtual suite of all installed tests
					$is_virtual_suite = true;
				}
				else if(self::is_selector_os($identifier[1]))
				{
					// virtual suite of all supported tests by a given operating system
					$is_virtual_suite = true;
				}
				else if(self::is_selector_subsystem($identifier[1]))
				{
					// virtual suite of all supported tests by a given TestType / subsystem
					$is_virtual_suite = true;
				}
				else if(self::is_selector_software_type($identifier[1]))
				{
					// virtual suite of all supported tests by a given SoftwareType
					$is_virtual_suite = true;
				}
				else if(self::is_selector_internal_tag($identifier[0], $identifier[1]))
				{
					// virtual suite of all supported tests by a given SoftwareType
					$is_virtual_suite = true;
				}
			}
		}

		return $is_virtual_suite;
	}
	public function get_identifier()
	{
		return $this->identifier;
	}
	public function get_title()
	{
		if($this->is_virtual_os_selector)
		{
			$title = $this->is_virtual_os_selector . ' Operating System Tests';
		}
		else if($this->is_virtual_subsystem_selector)
		{
			$title = $this->is_virtual_subsystem_selector . ' Subsystem Tests';
		}
		else if($this->is_virtual_software_type)
		{
			$title = $this->is_virtual_software_type . ' Tests';
		}
		else if($this->is_virtual_internal_tag)
		{
			$title = ucwords($this->is_virtual_internal_tag) . ' Tests';
		}
		else if($this->is_virtual_installed)
		{
			$title = 'Installed Tests';
		}
		else if(substr($this->identifier, strrpos($this->identifier, '/') + 1) == 'all')
		{
			$title = 'All ' . strtoupper(substr($this->identifier, 0,  strpos($this->identifier, '/'))) . ' Tests';
		}
		else
		{
			$title = 'Virtual Suite';
		}

		return $title;
	}
	public function get_description()
	{
		if($this->is_virtual_os_selector)
		{
			$description = 'This is a collection of test profiles found within the specified OpenBenchmarking.org repository where the test profile is specified as being compatible with the ' . $this->is_virtual_os_selector . ' Operating System.';
		}
		else if($this->is_virtual_subsystem_selector)
		{
			$description = 'This is a collection of test profiles found within the specified OpenBenchmarking.org repository where the test profile is specified as being a test of the ' . $this->is_virtual_subsystem_selector . ' sub-system.';
		}
		else if($this->is_virtual_software_type)
		{
			$description = 'This is a collection of test profiles found within the specified OpenBenchmarking.org repository where the test profile is specified as being a ' . $this->is_virtual_software_type . ' software test.';
		}
		else if($this->is_virtual_internal_tag)
		{
			$description = 'This is a collection of test profiles found within the specified OpenBenchmarking.org repository where the test profile is specified via an internal tag as testing ' . $this->is_virtual_internal_tag . '.';
		}
		else if($this->is_virtual_installed)
		{
			$description = 'This is a collection of test profiles found within the specified OpenBenchmarking.org repository that are already installed on the system under test.';
		}
		else if(substr($this->identifier, strrpos($this->identifier, '/') + 1) == 'all')
		{
			$description = 'This is a collection of all test profiles found within the specified OpenBenchmarking.org repository.';
		}
		else
		{
			$description = 'Virtual Suite';
		}

		return $description;
	}
	public function is_core_version_supported()
	{
		// It's virtual and created by pts-core so it's always supported
		return true;
	}
	private static function is_selector_os($id)
	{
		$yes = false;

		foreach(self::available_operating_systems() as $name => $os)
		{
			if($os === $id)
			{
				// virtual suite of all supported tests by a given operating system
				$yes = $name;
				break;
			}
		}

		return $yes;
	}
	private static function available_operating_systems()
	{
		$os = array();

		foreach(pts_types::operating_systems() as $os_r)
		{
			$os[$os_r[0]] = strtolower($os_r[0]);
		}

		return $os;
	}
	private static function is_selector_subsystem($id)
	{
		$yes = false;

		foreach(pts_types::subsystem_targets() as $subsystem)
		{
			if(strtolower($subsystem) === $id)
			{
				// virtual suite of all supported tests by a given TestType / subsystem
				$yes = $subsystem;
				break;
			}
		}

		return $yes;
	}
	private static function is_selector_software_type($id)
	{
		$yes = false;

		foreach(pts_types::test_profile_software_types() as $subsystem)
		{
			if(strtolower($subsystem) === $id && $subsystem != 'BaseTestProfile')
			{
				// virtual suite of all supported tests by a given SoftwareType
				$yes = $subsystem;
				break;
			}
		}

		return $yes;
	}
	private static function is_selector_internal_tag($repo, $id)
	{
		$yes = false;

		if(($i = array_search(strtolower($id), self::tags_in_repo($repo))) !== false)
		{
			// virtual suite of all test profiles matching an internal tag
			$tags = self::tags_in_repo($repo);
			$yes = $tags[$i];
		}

		return $yes;
	}
	public static function tags_in_repo($repo)
	{
		$tags = array();

		// read the repo
		$repo_index = pts_openbenchmarking::read_repository_index($repo);

		if(isset($repo_index['tests']) && is_array($repo_index['tests']))
		{
			foreach($repo_index['tests'] as &$test)
			{
				foreach($test['internal_tags'] as $tag)
				{
					$tags[$tag] = strtolower($tag);
				}
			}
		}

		return $tags;
	}
	public function get_contained_test_profiles()
	{
		$contained = array();

		// read the repo
		$repo_index = pts_openbenchmarking::read_repository_index($this->repo);

		if(isset($repo_index['tests']) && is_array($repo_index['tests']))
		{
			foreach($repo_index['tests'] as $test_identifier => &$test)
			{
				if(!in_array(phodevi::operating_system(), $test['supported_platforms']) || empty($test['title']))
				{
					// Initial check to not do unsupported tests
					continue;
				}

				if($this->is_virtual_os_selector && !in_array($this->virtual, array_map('strtolower', $test['supported_platforms'])))
				{
					// Doing a virtual suite of all tests specific to an OS, but this test profile is not supported there
					continue;
				}
				else if($this->is_virtual_subsystem_selector && $this->virtual != strtolower($test['test_type']))
				{
					// Doing a virtual suite of all tests specific to a test_type, but this test profile is not supported there
					continue;
				}
				else if($this->is_virtual_software_type && $this->virtual != strtolower($test['software_type']))
				{
					// Doing a virtual suite of all tests specific to a software_type, but this test profile is not supported there
					continue;
				}
				else if($this->is_virtual_internal_tag && !in_array($this->virtual, array_map('strtolower', $test['internal_tags'])))
				{
					// Doing a virtual suite of all tests matching an internal tag
					continue;
				}

				$test_version = array_shift($test['versions']);
				$test_profile = new pts_test_profile($this->repo . '/' . $test_identifier . '-' . $test_version);

				if($test_profile->get_display_format() != 'BAR_GRAPH' || !in_array($test_profile->get_license(), array('Free', 'Non-Free')))
				{
					// Also ignore these tests
					continue;
				}

				if($this->is_virtual_installed && $test_profile->is_test_installed() == false)
				{
					// Test is not installed
					continue;
				}

				if($test_profile->is_supported(false))
				{
					// All checks passed, add to virtual suite
					array_push($contained, $test_profile);
					continue;
				}
			}
		}

		return $contained;
	}
}

?>