public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_output = pts_result_file_output::result_file_to_csv($result_file);
     // To save the result:
     $file = pts_core::user_home_directory() . $r[0] . '.csv';
     file_put_contents($file, $result_output);
     echo $result_output;
 }
 public static function run($r)
 {
     $_REQUEST['force_format'] = 'PNG';
     // Force to PNG renderer
     $_REQUEST['svg_dom_gd_no_interlacing'] = true;
     // Otherwise FPDF will fail
     $tdir = pts_client::create_temporary_directory();
     pts_client::generate_result_file_graphs($r[0], $tdir);
     $result_file = new pts_result_file($r[0]);
     $pdf_file = pts_core::user_home_directory() . $r[0] . '.pdf';
     $pdf_output = pts_result_file_output::result_file_to_pdf($result_file, $pdf_file, 'F');
     echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL;
 }
 public function __get($name)
 {
     // This assumes that isset() has been called on $name prior to actually trying to get it...
     if (isset($this->cache[$name])) {
         return PHP_EOL . $this->cache[$name] . PHP_EOL;
     } else {
         if (PTS_IS_CLIENT && isset($this->options[$name])) {
             if (isset($this->options[$name]['type'])) {
                 $tries = array($this->options[$name]);
             } else {
                 $tries = $this->options[$name];
             }
             $contents = null;
             foreach ($tries as &$try) {
                 if ($try['type'] == 'F' && isset($try['F'][4]) && substr($try['F'], 0, 2) == '~/') {
                     // Set the home directory
                     $try['F'] = str_replace('~/', pts_core::user_home_directory(), $try['F']);
                 }
                 if ($try['type'] == 'F' && is_file($try['F'])) {
                     $contents = file_get_contents($try['F']);
                 } else {
                     if ($try['type'] == 'C') {
                         $command = pts_client::executable_in_path(pts_strings::first_in_string($try['C']));
                         if ($command != null) {
                             $descriptor_spec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
                             $proc = proc_open($try['C'], $descriptor_spec, $pipes, null, null);
                             $contents = stream_get_contents($pipes[1]);
                             fclose($pipes[1]);
                             $return_value = proc_close($proc);
                         }
                     }
                 }
                 if (isset($try['remove_timestamps']) && $try['remove_timestamps']) {
                     // remove leading timestamps such as from dmesg and Xorg.0.log
                     $contents = pts_strings::remove_line_timestamps($contents);
                 }
                 if ($contents != null) {
                     if ($try['cacheable']) {
                         $this->cache[$name] = $contents;
                     }
                     return PHP_EOL . $contents . PHP_EOL;
                 }
             }
         }
     }
     return false;
 }
 protected static function setup_test_install_directory(&$test_install_request, $remove_old_files = false)
 {
     $identifier = $test_install_request->test_profile->get_identifier();
     pts_file_io::mkdir($test_install_request->test_profile->get_install_dir());
     if ($remove_old_files) {
         // Remove any (old) files that were installed
         $ignore_files = array('pts-install.xml', 'install-failed.log');
         foreach ($test_install_request->get_download_objects() as $download_object) {
             $ignore_files[] = $download_object->get_filename();
         }
         pts_file_io::delete($test_install_request->test_profile->get_install_dir(), $ignore_files);
     }
     pts_file_io::symlink(pts_core::user_home_directory() . '.Xauthority', $test_install_request->test_profile->get_install_dir() . '.Xauthority');
     pts_file_io::symlink(pts_core::user_home_directory() . '.drirc', $test_install_request->test_profile->get_install_dir() . '.drirc');
 }
 public static function environmental_variables()
 {
     // The PTS environmental variables passed during the testing process, etc
     static $env_variables = null;
     if ($env_variables == null) {
         $env_variables = array('PTS_VERSION' => PTS_VERSION, 'PTS_CODENAME' => PTS_CODENAME, 'PTS_DIR' => PTS_PATH, 'PHP_BIN' => PHP_BIN, 'NUM_CPU_CORES' => phodevi::read_property('cpu', 'core-count'), 'NUM_CPU_NODES' => phodevi::read_property('cpu', 'node-count'), 'NUM_CPU_JOBS' => phodevi::read_property('cpu', 'core-count') * 2, 'SYS_MEMORY' => phodevi::read_property('memory', 'capacity'), 'VIDEO_MEMORY' => phodevi::read_property('gpu', 'memory-capacity'), 'VIDEO_WIDTH' => pts_arrays::first_element(phodevi::read_property('gpu', 'screen-resolution')), 'VIDEO_HEIGHT' => pts_arrays::last_element(phodevi::read_property('gpu', 'screen-resolution')), 'VIDEO_MONITOR_COUNT' => phodevi::read_property('monitor', 'count'), 'VIDEO_MONITOR_LAYOUT' => phodevi::read_property('monitor', 'layout'), 'VIDEO_MONITOR_SIZES' => phodevi::read_property('monitor', 'modes'), 'OPERATING_SYSTEM' => phodevi::read_property('system', 'vendor-identifier'), 'OS_VERSION' => phodevi::read_property('system', 'os-version'), 'OS_ARCH' => phodevi::read_property('system', 'kernel-architecture'), 'OS_TYPE' => phodevi::operating_system(), 'THIS_RUN_TIME' => PTS_INIT_TIME, 'DEBUG_REAL_HOME' => pts_core::user_home_directory());
         if (!pts_client::executable_in_path('cc') && pts_client::executable_in_path('gcc') && getenv('CC') == false) {
             // This helps some test profiles build correctly if they don't do a cc check internally
             $env_variables['CC'] = 'gcc';
         }
     }
     return $env_variables;
 }
function pts_define_directories()
{
    // User's home directory for storing results, module files, test installations, etc.
    pts_define('PTS_CORE_PATH', PTS_PATH . 'pts-core/');
    pts_define('PTS_IS_DAEMONIZED_SERVER_PROCESS', PTS_IS_CLIENT && is_dir('/var/lib/') && is_writable('/') ? true : false);
    if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
        if (!is_dir('/var/cache/phoronix-test-suite/')) {
            mkdir('/var/cache/phoronix-test-suite/');
        }
        pts_define('PTS_USER_PATH', '/var/lib/phoronix-test-suite/');
        pts_define('PTS_CORE_STORAGE', PTS_USER_PATH . 'core.pt2so');
        pts_define('PTS_TEMP_STORAGE', PTS_USER_PATH . 'temp.pt2so');
        pts_define('PTS_MODULE_LOCAL_PATH', PTS_USER_PATH . 'modules/');
        pts_define('PTS_MODULE_DATA_PATH', PTS_USER_PATH . 'modules-data/');
        pts_define('PTS_DOWNLOAD_CACHE_PATH', '/var/cache/phoronix-test-suite/download-cache/');
        pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', '/var/cache/phoronix-test-suite/openbenchmarking.org/');
        pts_define('PTS_TEST_PROFILE_PATH', PTS_USER_PATH . 'test-profiles/');
        pts_define('PTS_TEST_SUITE_PATH', PTS_USER_PATH . 'test-suites/');
    } else {
        if (PTS_IS_CLIENT) {
            pts_define('PTS_USER_PATH', pts_core::user_home_directory() . '.phoronix-test-suite' . DIRECTORY_SEPARATOR);
            pts_define('PTS_CORE_STORAGE', PTS_USER_PATH . 'core.pt2so');
            pts_define('PTS_TEMP_STORAGE', PTS_USER_PATH . 'temp.pt2so');
            pts_define('PTS_MODULE_LOCAL_PATH', PTS_USER_PATH . 'modules/');
            pts_define('PTS_MODULE_DATA_PATH', PTS_USER_PATH . 'modules-data/');
            pts_define('PTS_DOWNLOAD_CACHE_PATH', PTS_USER_PATH . 'download-cache/');
            pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', PTS_USER_PATH . 'openbenchmarking.org/');
            pts_define('PTS_TEST_PROFILE_PATH', PTS_USER_PATH . 'test-profiles/');
            pts_define('PTS_TEST_SUITE_PATH', PTS_USER_PATH . 'test-suites/');
        } else {
            if (defined('PTS_STORAGE_PATH')) {
                pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', PTS_STORAGE_PATH . 'openbenchmarking.org/');
                pts_define('PTS_TEST_PROFILE_PATH', PTS_STORAGE_PATH . 'test-profiles/');
                pts_define('PTS_TEST_SUITE_PATH', PTS_STORAGE_PATH . 'test-suites/');
            } else {
                if (defined('PATH_TO_PHOROMATIC_STORAGE')) {
                    pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', PATH_TO_PHOROMATIC_STORAGE . 'openbenchmarking.org/');
                    pts_define('PTS_TEST_PROFILE_PATH', PATH_TO_PHOROMATIC_STORAGE . 'test-profiles/');
                    pts_define('PTS_TEST_SUITE_PATH', PATH_TO_PHOROMATIC_STORAGE . 'test-suites/');
                }
            }
        }
    }
    // Misc Locations
    pts_define('PTS_MODULE_PATH', PTS_CORE_PATH . 'modules/');
    pts_define('PTS_CORE_STATIC_PATH', PTS_CORE_PATH . 'static/');
    pts_define('PTS_COMMAND_PATH', PTS_CORE_PATH . 'commands/');
    pts_define('PTS_EXDEP_PATH', PTS_CORE_PATH . 'external-test-dependencies/');
    pts_define('PTS_OPENBENCHMARKING_PATH', PTS_CORE_PATH . 'openbenchmarking.org/');
    if (is_dir('/usr/local/share/phoronix-test-suite/')) {
        pts_define('PTS_SHARE_PATH', '/usr/local/share/phoronix-test-suite/');
    } else {
        if (is_dir('/usr/share/')) {
            pts_define('PTS_SHARE_PATH', '/usr/share/phoronix-test-suite/');
            if (is_writable('/usr/share') && !is_dir(PTS_SHARE_PATH)) {
                mkdir(PTS_SHARE_PATH);
            }
        } else {
            pts_define('PTS_SHARE_PATH', false);
        }
    }
}
 public static function parse_for_home_directory($path)
 {
     // Find home directory if needed
     if (strpos($path, '~/') !== false) {
         $path = str_replace('~/', pts_core::user_home_directory(), $path);
     }
     return pts_strings::add_trailing_slash($path);
 }
 public static function run($r)
 {
     $_REQUEST['force_format'] = 'PNG';
     // Force to PNG renderer
     $_REQUEST['svg_dom_gd_no_interlacing'] = true;
     // Otherwise FPDF will fail
     $tdir = pts_client::create_temporary_directory();
     pts_client::generate_result_file_graphs($r[0], $tdir);
     $result_file = new pts_result_file($r[0]);
     $pdf = new pts_pdf_template($result_file->get_title(), null);
     $pdf->AddPage();
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38);
     $pdf->Ln(120);
     $pdf->WriteStatementCenter('www.phoronix-test-suite.com');
     $pdf->Ln(15);
     $pdf->WriteBigHeaderCenter($result_file->get_title());
     $pdf->WriteText($result_file->get_description());
     $pdf->AddPage();
     $pdf->Ln(15);
     $pdf->SetSubject($result_file->get_title() . ' Benchmarks');
     //$pdf->SetKeywords(implode(', ', $identifiers));
     $pdf->WriteHeader('Test Systems:');
     foreach ($result_file->get_systems() as $s) {
         $pdf->WriteMiniHeader($s->get_identifier());
         $pdf->WriteText($s->get_hardware());
         $pdf->WriteText($s->get_software());
         //$pdf->WriteText($notes_r[$i]);
     }
     /*
     if(count($identifiers) > 1 && is_file($tdir . 'result-graphs/overview.jpg'))
     {
     	$pdf->AddPage();
     	$pdf->Ln(100);
     	$pdf->Image($tdir . 'result-graphs/overview.jpg', 15, 40, 180);
     }
     */
     $pdf->AddPage();
     $placement = 1;
     $results = $result_file->get_result_objects();
     for ($i = 1; $i <= count($results); $i++) {
         if (is_file($tdir . 'result-graphs/' . $i . '.png')) {
             $pdf->Ln(100);
             $pdf->Image($tdir . 'result-graphs/' . $i . '.png', 50, 40 + ($placement - 1) * 120, 120);
         }
         if ($placement == 2) {
             $placement = 0;
             if ($i != count($results)) {
                 $pdf->AddPage();
             }
         }
         $placement++;
     }
     // To save:
     /*
     $pdf_file = 'SAVE_TO';
     
     if(substr($pdf_file, -4) != '.pdf')
     {
     	$pdf_file .= '.pdf';
     }
     */
     $pdf_file = pts_core::user_home_directory() . $r[0] . '.pdf';
     $pdf->Output($pdf_file);
     pts_file_io::delete($tdir, null, true);
     echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL;
 }