How to use find_file method of matisk class

Best Phoronix-test-suite code snippet using matisk.find_file

matisk.php

Source:matisk.php Github

copy

Full Screen

...128 echo PHP_EOL . PHP_EOL;129 }130 }131 }132 private static function find_file($file)133 {134 if(is_file($file))135 {136 $file = $file;137 }138 else if(is_file(self::$matisk_config_dir . $file))139 {140 $file = self::$matisk_config_dir . $file;141 }142 else143 {144 $file = false;145 }146 return $file;147 }148 public static function run_matisk($args)149 {150 echo PHP_EOL . 'MATISK For The Phoronix Test Suite' . PHP_EOL;151 if(!isset($args[0]) || !is_file($args[0]))152 {153 echo PHP_EOL . 'You must specify a MATISK INI file to load.' . PHP_EOL . PHP_EOL;154 return false;155 }156 self::$matisk_config_dir = dirname($args[0]) . '/';157 pts_file_io::mkdir(pts_module::save_dir());158 $ini = parse_ini_file($args[0], true);159 foreach(self::$ini_struct as $section => $items)160 {161 foreach($items as $key => $r)162 {163 if(is_array($r) && !isset($ini[$section][$key]))164 {165 $ini[$section][$key] = $r[0];166 }167 }168 }169 // Checks170 if(pts_test_suite::is_suite($ini['workload']['suite']) == false)171 {172 // See if the XML suite-definition was just tossed into the same directory173 if(($xml_file = self::find_file($ini['workload']['suite'] . '.xml')) !== false)174 {175 pts_file_io::mkdir(PTS_TEST_SUITE_PATH . 'local/' . $ini['workload']['suite']);176 copy($xml_file, PTS_TEST_SUITE_PATH . 'local/' . $ini['workload']['suite'] . '/suite-definition.xml');177 }178 if(pts_test_suite::is_suite($ini['workload']['suite']) == false)179 {180 echo PHP_EOL . 'A test suite must be specified to execute. If a suite needs to be constructed, run: ' . PHP_EOL . 'phoronix-test-suite build-suite' . PHP_EOL . PHP_EOL;181 return false;182 }183 }184 if($ini['set_context']['external_contexts'] != null)185 {186 switch($ini['set_context']['external_contexts_delimiter'])187 {188 case 'EOL':189 case '':190 $ini['set_context']['external_contexts_delimiter'] = PHP_EOL;191 break;192 case 'TAB':193 $ini['set_context']['external_contexts_delimiter'] = "\t";194 break;195 }196 if(($ff = self::find_file($ini['set_context']['external_contexts'])))197 {198 if(is_executable($ff))199 {200 $ini['set_context']['context'] = shell_exec($ff . ' 2> /dev/null');201 }202 else203 {204 $ini['set_context']['context'] = file_get_contents($ff);205 }206 }207 else208 {209 // Hopefully it's a command to execute then...210 $ini['set_context']['context'] = shell_exec($ini['set_context']['external_contexts'] . ' 2> /dev/null');211 }212 $ini['set_context']['context'] = explode($ini['set_context']['external_contexts_delimiter'], $ini['set_context']['context']);213 }214 else if($ini['set_context']['context'] != null && !is_array($ini['set_context']['context']))215 {216 $ini['set_context']['context'] = array($ini['set_context']['context']);217 }218 if(is_array($ini['set_context']['context']) && count($ini['set_context']['context']) > 0)219 {220 foreach($ini['set_context']['context'] as $i => $context)221 {222 if($context == null)223 {224 unset($ini['set_context']['context'][$i]);225 }226 }227 // Context testing228 if(count($ini['set_context']['context']) > 0 && $ini['set_context']['pre_run'] == null && $ini['set_context']['pre_install'] == null)229 {230 echo PHP_EOL . 'The pre_run or pre_install set_context fields must be set in order to set the system\'s context.' . PHP_EOL;231 return false;232 }233 if($ini['set_context']['reverse_context_order'])234 {235 $ini['set_context']['context'] = array_reverse($ini['set_context']['context']);236 }237 }238 if(pts_strings::string_bool($ini['workload']['save_results']))239 {240 if($ini['workload']['save_name'] == null)241 {242 echo PHP_EOL . 'The save_name field cannot be left empty when saving the test results.' . PHP_EOL;243 return false;244 }245 /*246 if($ini['workload']['result_identifier'] == null)247 {248 echo PHP_EOL . 'The result_identifier field cannot be left empty when saving the test results.' . PHP_EOL;249 return false;250 }251 */252 }253 if(!empty($ini['environmental_variables']) && is_array($ini['environmental_variables']))254 {255 foreach($ini['environmental_variables'] as $key => $value)256 {257 putenv(trim($key) . '=' . trim($value));258 }259 }260 if(empty($ini['set_context']['context']))261 {262 $ini['set_context']['context'] = array($ini['workload']['result_identifier']);263 }264 if(pts_strings::string_bool($ini['set_context']['log_context_outputs']))265 {266 pts_file_io::mkdir(pts_module::save_dir() . $ini['workload']['save_name']);267 }268 $spent_context_file = pts_module::save_dir() . $ini['workload']['save_name'] . '.spent-contexts';269 if(!is_file($spent_context_file))270 {271 touch($spent_context_file);272 }273 else274 {275 // If recovering from an existing run, don't rerun contexts that were already executed276 $spent_contexts = pts_file_io::file_get_contents($spent_context_file);277 $spent_contexts = explode(PHP_EOL, $spent_contexts);278 foreach($spent_contexts as $sc)279 {280 if(($key = array_search($sc, $ini['set_context']['context'])) !== false)281 {282 unset($ini['set_context']['context'][$key]);283 }284 }285 }286 if($ini['set_context']['reboot_support'] && phodevi::is_linux())287 {288 // In case a set-context involves a reboot, auto-recover289 $xdg_config_home = is_dir('/etc/xdg/autostart') && is_writable('/etc/xdg/autostart') ? '/etc/xdg/autostart' : pts_client::read_env('XDG_CONFIG_HOME');290 if($xdg_config_home == false)291 {292 $xdg_config_home = pts_client::user_home_directory() . '.config';293 }294 if($xdg_config_home != false && is_dir($xdg_config_home))295 {296 $autostart_dir = $xdg_config_home . '/autostart/';297 pts_file_io::mkdir($xdg_config_home . '/autostart/');298 }299 file_put_contents($xdg_config_home . '/autostart/phoronix-test-suite-matisk.desktop', '300[Desktop Entry]301Name=Phoronix Test Suite Matisk Recovery302GenericName=Phoronix Test Suite303Comment=Matisk Auto-Recovery Support304Exec=gnome-terminal -e \'phoronix-test-suite matisk ' . $args[0] . '\'305Icon=phoronix-test-suite306Type=Application307Encoding=UTF-8308Categories=System;Monitor;');309 }310 if($ini['installation']['block_phodevi_caching'])311 {312 // Block Phodevi caching if changing out system components and there is a chance one of the strings of changed contexts might be cached (e.g. OpenGL user-space driver)313 phodevi::$allow_phodevi_caching = false;314 }315 if(phodevi::system_uptime() < 60)316 {317 echo PHP_EOL . 'Sleeping 45 seconds while waiting for the system to settle...' . PHP_EOL;318 sleep(45);319 }320 self::$ini = $ini;321 $total_context_count = count(self::$ini['set_context']['context']);322 while(($context = array_shift(self::$ini['set_context']['context'])) !== null)323 {324 echo PHP_EOL . ($total_context_count - count(self::$ini['set_context']['context'])) . ' of ' . $total_context_count . ' in test execution queue [' . $context . ']' . PHP_EOL . PHP_EOL;325 self::$context = $context;326 if(pts_strings::string_bool(self::$ini['installation']['install_check']) || $ini['set_context']['pre_install'] != null)327 {328 self::process_user_config_external_hook_process('pre_install');329 $force_install = false;330 $no_prompts = true;331 if(pts_strings::string_bool(self::$ini['installation']['force_install']))332 {333 $force_install = true;334 }335 if(self::$ini['installation']['external_download_cache'] != null)336 {337 pts_test_install_manager::add_external_download_cache(self::$ini['installation']['external_download_cache']);338 }339 // Do the actual test installation340 pts_test_installer::standard_install(self::$ini['workload']['suite'], $force_install, $no_prompts);341 self::process_user_config_external_hook_process('post_install');342 }343 $batch_mode = false;344 $auto_mode = true;345 $test_run_manager = new pts_test_run_manager($batch_mode, $auto_mode);346 if($test_run_manager->initial_checks(self::$ini['workload']['suite']) == false)347 {348 return false;349 }350 if(self::$skip_test_set == false)351 {352 self::process_user_config_external_hook_process('pre_run');353 // Load the tests to run354 if($test_run_manager->load_tests_to_run(self::$ini['workload']['suite']) == false)355 {356 return false;357 }358 // Save results?359 $result_identifier = $ini['workload']['result_identifier'];360 if($result_identifier == null)361 {362 $result_identifier = '$MATISK_CONTEXT';363 }364 // Allow $MATIISK_CONTEXT as a valid user variable to pass it...365 $result_identifier = str_replace('$MATISK_CONTEXT', self::$context, $result_identifier);366 $test_run_manager->set_save_name(self::$ini['workload']['save_name']);367 $test_run_manager->set_results_identifier($result_identifier);368 $test_run_manager->set_description(self::$ini['workload']['description']);369 // Don't upload results unless it's the last in queue where the context count is now 0370 $test_run_manager->auto_upload_to_openbenchmarking((count(self::$ini['set_context']['context']) == 0 && self::$ini['general']['upload_to_openbenchmarking']));371 // Run the actual tests372 $test_run_manager->pre_execution_process();373 $test_run_manager->call_test_runs();374 $test_run_manager->post_execution_process();375 }376 self::$skip_test_set = false;377 file_put_contents($spent_context_file, self::$context . PHP_EOL, FILE_APPEND);378 pts_file_io::unlink(pts_module::save_dir() . self::$context . '.last-call');379 self::process_user_config_external_hook_process('post_run');380 }381 unlink($spent_context_file);382 isset($xdg_config_home) && pts_file_io::unlink($xdg_config_home . '/autostart/phoronix-test-suite-matisk.desktop');383 }384 protected static function process_user_config_external_hook_process($process)385 {386 // Check to not run the same process387 $last_call_file = pts_module::save_dir() . self::$context . '.last-call';388 if(is_file($last_call_file))389 {390 $check = pts_file_io::file_get_contents($last_call_file);391 if($process == $check)392 {393 unlink($last_call_file);394 return false;395 }396 }397 $process != 'post_run' && file_put_contents($last_call_file, $process);398 if(self::$ini['set_context'][$process])399 {400 $command = self::find_file(self::$ini['set_context'][$process]) ? self::find_file(self::$ini['set_context'][$process]) : self::$ini['set_context'][$process];401 $descriptor_spec = array(402 0 => array('pipe', 'r'),403 1 => array('pipe', 'w'),404 2 => array('pipe', 'w')405 );406 $env_vars = null;407 pts_client::$display->test_run_instance_error('Running ' . $process . ' set-context script.');408 if(is_executable($command))409 {410 // Pass the context as the first argument to the string411 $command .= ' ' . self::$context;412 }413 else414 {...

Full Screen

Full Screen

find_file

Using AI Code Generation

copy

Full Screen

1include 'matisk.php';2$matisk = new matisk();3$matisk->find_file('test');4class matisk{5 function find_file($file){6 if(file_exists($file)){7 echo 'File is available';8 }else{9 echo 'File is not available';10 }11 }12}

Full Screen

Full Screen

find_file

Using AI Code Generation

copy

Full Screen

1require_once("matisk.php");2$matisk = new matisk();3$matisk->find_file("/home/username","file_name");4require_once("matisk.php");5$matisk = new matisk();6$matisk->find_file("/home/username","file_name");7require_once("matisk.php");8$matisk = new matisk();9$matisk->find_file("/home/username","file_name");10require_once("matisk.php");11$matisk = new matisk();12$matisk->find_file("/home/username","file_name");13require_once("matisk.php");14$matisk = new matisk();15$matisk->find_file("/home/username","file_name");16require_once("matisk.php");17$matisk = new matisk();18$matisk->find_file("/home/username","file_name");19require_once("matisk.php");20$matisk = new matisk();21$matisk->find_file("/home/username","file_name");22require_once("matisk.php");23$matisk = new matisk();24$matisk->find_file("/home/username","file_name");25require_once("matisk.php");26$matisk = new matisk();27$matisk->find_file("/home/username","file_name");28require_once("matisk.php");29$matisk = new matisk();30$matisk->find_file("/home/username","file_name");31require_once("matisk.php");32$matisk = new matisk();33$matisk->find_file("/home/username","file_name");

Full Screen

Full Screen

find_file

Using AI Code Generation

copy

Full Screen

1include_once('class.php');2$matisk = new matisk();3$matisk->find_file('test.txt');4echo $matisk->result;5include_once('class.php');6$matisk = new matisk();7$matisk->find_folder('test');8echo $matisk->result;9include_once('class.php');10$matisk = new matisk();11$matisk->get_file_content('test.txt');12echo $matisk->result;13include_once('class.php');14$matisk = new matisk();15$matisk->get_folder_size('test');16echo $matisk->result;17include_once('class.php');18$matisk = new matisk();19$matisk->get_file_size('test.txt');20echo $matisk->result;21include_once('class.php');22$matisk = new matisk();23$matisk->get_file_ext('test.txt');24echo $matisk->result;25include_once('class.php');26$matisk = new matisk();27$matisk->get_file_name('test.txt');28echo $matisk->result;

Full Screen

Full Screen

find_file

Using AI Code Generation

copy

Full Screen

1include_once('matisk.php');2$matisk = new Matisk();3$matisk->find_file();4The find_file() method of Matisk class is used to find the files in the directory. The function is defined as follows:5public function find_file()6{7foreach($files as $file)8{9if($file != '.' && $file != '..')10{11}12}13}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger find_file code on LambdaTest Cloud Grid

Execute automation tests with find_file on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful