How to use recursively_search_text_files_in_dir method of ob_test_profile_analyze class

Best Phoronix-test-suite code snippet using ob_test_profile_analyze.recursively_search_text_files_in_dir

ob_test_profile_analyze.php

Source:ob_test_profile_analyze.php Github

copy

Full Screen

...44 }45 $test_binary = self::locate_test_profile_lead_binary($test_profile);46 // search for intrinsics47 $intrinsics = array();48 //self::recursively_search_text_files_in_dir($test_profile->get_test_executable_dir(), $intrics_search, $intrinsics);49 $honors_cflags = false;50 $shared_library_dependencies = array();51 $instruction_usage = array();52 if(is_executable($test_binary))53 {54 $ldd = trim(shell_exec('ldd ' . $test_binary));55 foreach(explode(PHP_EOL, $ldd) as $line)56 {57 $line = explode(' => ', $line);58 if(count($line) == 2)59 {60 $shared_library_dependencies[] = trim(basename($line[0]));61 }62 }63 $libraries_found_in_test_dir = array();64 foreach($shared_library_dependencies as $look_for_so)65 {66 $looked_so = self::recursively_find_file($test_profile->get_test_executable_dir(), $look_for_so, false);67 if($looked_so)68 {69 $libraries_found_in_test_dir[] = $looked_so;70 }71 }72 //echo PHP_EOL . 'SHARED LIBRARY DEPENDENCIES: ' . PHP_EOL;73 //print_r($shared_library_dependencies);74 $external_dependencies = $test_profile->get_external_dependencies();75 foreach(array('default', 'sandybridge', 'skylake', 'tigerlake', 'cascadelake -mprefer-vector-width=512', 'sapphirerapids -mprefer-vector-width=512', 'alderlake', 'znver2', 'znver3') as $march)76 {77 // So for any compiling tasks they will try to use the most aggressive instructions possible78 if($march != 'default')79 {80 if(!in_array('build-utilities', $external_dependencies))81 {82 continue;83 }84 putenv('CFLAGS= -march=' . $march . ' -O3 ');85 putenv('CXXFLAGS= -march=' . $march . ' -O3 ');86 }87 else88 {89 putenv('CFLAGS');90 putenv('CXXFLAGS');91 }92 if(($x = strpos($march, ' ')) !== false)93 {94 $march = substr($march, 0, $x);95 }96 pts_test_installer::standard_install($qualified_identifier, true);97 if($test_profile->is_test_installed())98 {99 $iu = array();100 self::analyze_binary_instruction_usage($test_binary, $iu);101 foreach($libraries_found_in_test_dir as $lib_check)102 {103 if(is_file($lib_check))104 {105 // Scan locally built libs too106 self::analyze_binary_instruction_usage($lib_check, $iu);107 }108 }109 if($iu != null)110 {111 if($march != 'default' && $honors_cflags == false && !empty($iu) && isset($instruction_usage['default']) && $iu != $instruction_usage['default'])112 {113 $honors_cflags = true;114 }115 $instruction_usage[$march] = $iu;116 }117 }118 }119 120 echo PHP_EOL . pts_client::cli_just_bold('SHARED LIBRARIES: ') . implode(' ', $shared_library_dependencies);121 echo PHP_EOL . pts_client::cli_just_bold('INSTRUCTION USE: ') . PHP_EOL;122 $table = array();123 foreach($instruction_usage as $target => $values)124 {125 $table[] = array_merge(array(' ' . pts_client::cli_just_bold($target . ': ')), array_keys($values));126 }127 echo pts_user_io::display_text_table($table);128 echo PHP_EOL . pts_client::cli_just_bold('HONORS FLAGS: ') . ($honors_cflags ? 'YES' : 'NO') . PHP_EOL;129 if(pts_openbenchmarking_client::user_name() != false)130 {131 $server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_meta', array(132 'i' => $test_profile->get_identifier(),133 'ldd_libraries' => implode(',', $shared_library_dependencies),134 'instruction_set_usage' => base64_encode(json_encode($instruction_usage)),135 'honors_cflags' => ($honors_cflags ? 1 : 0)136 ));137 //var_dump($server_response);138 $json = json_decode($server_response, true);139 }140 }141 else142 {143 echo PHP_EOL . $test_binary;144 echo PHP_EOL . 'Test binary could not be found.' . PHP_EOL;145 // return false;146 }147 }148 }149 public static function locate_test_profile_lead_binary(&$test_profile)150 {151 $test_profile_launcher = $test_profile->get_test_executable_dir() . $test_profile->get_test_executable();152 if(!is_file($test_profile_launcher))153 {154 echo PHP_EOL . $test_profile_launcher . ' not found.' . PHP_EOL;155 return false;156 }157 $original_launcher_contents = file_get_contents($test_profile_launcher);158 $test_binary = false;159 if(($s = strpos($original_launcher_contents, '$LOG_FILE')))160 {161 $launcher_contents = substr($original_launcher_contents, 0, $s);162 $tline = trim(str_replace(array(' ', ' ', 'mpirun', 'mpiexec', './'), '', substr($launcher_contents, strrpos($launcher_contents, PHP_EOL) + 1)));163 $test_binary = pts_strings::first_in_string($tline);164 if(strpos($test_binary, '=') !== false)165 {166 // Likely an env var being set first, so go to 2nd word167 $test_binary = pts_strings::first_in_string(trim(str_replace($test_binary, '', $tline)));168 }169 170 if($test_binary && substr($test_binary, 0, 1) == '-')171 {172 $tline = substr($launcher_contents, strrpos($launcher_contents, PHP_EOL) + 1);173 if(strpos($tline, 'mpirun') !== false || strpos($tline, 'mpiexec') !== false)174 {175 $tline = trim(str_replace(array(' ', ' ', 'mpirun', 'mpiexec', './'), '', $tline));176 foreach(explode(' ', $tline) as $possible_cmd)177 {178 if(substr($possible_cmd, 0, 1) == '-')179 {180 continue;181 }182 if(is_executable(($cmd = $test_profile->get_test_executable_dir() . $test_binary)) || ($cmd = pts_client::executable_in_path($possible_cmd)) || ($cmd = self::recursively_find_file($test_profile->get_test_executable_dir(), $possible_cmd)))183 {184 $test_binary = $cmd;185 break;186 }187 else if(($cmd = self::recursively_find_file($test_profile->get_test_executable_dir(), basename($possible_cmd))))188 {189 $test_binary = $cmd;190 break;191 }192 }193 }194 }195 }196 else if($s = strpos($original_launcher_contents, './'))197 {198 $launcher_contents = $original_launcher_contents;199 $test_binary = substr($original_launcher_contents, ($s + 2));200 $test_binary = substr($test_binary, 0, strpos($test_binary, ' '));201 }202 203 if($test_binary == 'echo' && ($s = strpos($original_launcher_contents, '$LOG_FILE')))204 {205 $launcher_contents = substr($original_launcher_contents, 0, $s);206 $exec_line = trim(str_replace(array(' ', ' ', 'mpirun', 'mpiexec', './'), '', substr($launcher_contents, strrpos($launcher_contents, PHP_EOL) + 1)));207 if(($x = strpos($exec_line, '| ')) !== false)208 {209 $exec_line = substr($exec_line, ($x + 2));210 }211 $test_binary = pts_strings::first_in_string($exec_line);212 }213 if(strpos($test_binary, '.app') && strpos($original_launcher_contents, '$LOG_FILE') != ($s = strrpos($original_launcher_contents, '$LOG_FILE')))214 {215 $launcher_contents = substr($original_launcher_contents, 0, $s);216 $test_binary = pts_strings::first_in_string(trim(str_replace(array(' ', ' ', 'mpirun', 'mpiexec', './'), '', substr($launcher_contents, strrpos($launcher_contents, PHP_EOL) + 1))));217 }218 if($test_binary)219 {220 if(is_executable($test_profile->get_test_executable_dir() . $test_binary) && $test_profile->get_test_executable_dir() . $test_binary != $test_profile_launcher)221 {222 $test_binary = $test_profile->get_test_executable_dir() . $test_binary;223 }224 else if(($s = strpos($launcher_contents, PHP_EOL . 'cd ')))225 {226 $cd = (substr($launcher_contents, ($s + 4)));227 $cd = substr($cd, 0, strpos($cd, PHP_EOL));228 if(is_executable($test_profile->get_test_executable_dir() . '/' . $cd . '/' . $test_binary))229 {230 $test_binary = $test_profile->get_test_executable_dir() . '/' . $cd . '/' . $test_binary;231 }232 }233 else if(($e = pts_client::executable_in_path($test_binary)))234 {235 $test_binary = $e;236 }237 if($test_binary != null && !is_executable($test_binary))238 {239 // Helping qe and others that use ../ relative path handling not handled by above code, just scan directory for matching binary name...240 $basename_binary = basename($test_binary);241 $search_binary = self::recursively_find_file($test_profile->get_test_executable_dir(), $basename_binary);242 if($search_binary)243 {244 $test_binary = $search_binary;245 }246 }247 248 //var_dump($test_binary);249 }250 return $test_binary;251 }252 public static function recursively_search_text_files_in_dir($object, &$search_for, &$hits)253 {254 if(is_dir($object))255 {256 $object = pts_strings::add_trailing_slash($object);257 }258 foreach(pts_file_io::glob($object . '*') as $to_read)259 {260 if(pts_file_io::is_text_file($to_read))261 {262 $to_read_contents = file_get_contents($to_read);263 foreach($search_for as $search => $report)264 {265 if(strpos($to_read_contents, $search) !== false)266 {267 if(!isset($hits[$to_read]))268 {269 $hits[$to_read][] = $report;270 }271 }272 }273 274 }275 else if(is_dir($to_read))276 {277 self::recursively_search_text_files_in_dir($to_read, $search_for, $hits);278 }279 }280 }281 public static function recursively_find_file($search_in, $search_for, $executable_check = true)282 {283 foreach(pts_file_io::glob($search_in . '*') as $to_read)284 {285 if(is_file($to_read) && (!$executable_check || is_executable($to_read)) && basename($to_read) == $search_for)286 {287 return $to_read;288 289 }290 else if(is_dir($to_read))291 {...

Full Screen

Full Screen

recursively_search_text_files_in_dir

Using AI Code Generation

copy

Full Screen

1require_once 'ob_test_profile_analyze.php';2$ob_test_profile_analyze = new ob_test_profile_analyze();3$ob_test_profile_analyze->recursively_search_text_files_in_dir('/path/to/directory');4{5 public function recursively_search_text_files_in_dir($dir)6 {7 $files = array();8 if (is_dir($dir)) {9 $files = scandir($dir);10 foreach ($files as $file) {11 if ($file != '.' && $file != '..') {12 $this->recursively_search_text_files_in_dir($dir . '/' . $file);13 }14 }15 } else if (is_file($dir)) {16 if (preg_match('/\.txt$/', $dir)) {17 $this->analyze_text_file($dir);18 }19 }20 }21 public function analyze_text_file($file)22 {23 $fh = fopen($file, 'r');24 while (!feof($fh)) {25 $line = fgets($fh);26 $this->analyze_line($line);27 }28 fclose($fh);29 }30 public function analyze_line($line)31 {32 }33}

Full Screen

Full Screen

recursively_search_text_files_in_dir

Using AI Code Generation

copy

Full Screen

1require_once("ob_test_profile_analyze.php");2$ob_test_profile_analyze=new ob_test_profile_analyze();3$ob_test_profile_analyze->recursively_search_text_files_in_dir("C:/xampp/htdocs/ob_test_profile_analyze/");4require_once("ob_test_profile_analyze.php");5$ob_test_profile_analyze=new ob_test_profile_analyze();6echo $ob_test_profile_analyze->get_time_taken_by_method("recursively_search_text_files_in_dir","C:/xampp/htdocs/ob_test_profile_analyze/");7require_once("ob_test_profile_analyze.php");8$ob_test_profile_analyze=new ob_test_profile_analyze();9echo $ob_test_profile_analyze->get_time_taken_by_method("recursively_search_text_files_in_dir","C:/xampp/htdocs/ob_test_profile_analyze/");10require_once("ob_test_profile_analyze.php");11$ob_test_profile_analyze=new ob_test_profile_analyze();12echo $ob_test_profile_analyze->get_time_taken_by_method("recursively_search_text_files_in_dir","C:/xampp/htdocs/ob_test_profile_analyze/");13require_once("ob_test_profile_analyze.php");

Full Screen

Full Screen

recursively_search_text_files_in_dir

Using AI Code Generation

copy

Full Screen

1include_once('ob_test_profile_analyze.php');2$ob_test_profile_analyze = new ob_test_profile_analyze();3$ob_test_profile_analyze->recursively_search_text_files_in_dir('hello','/var/www/html/');4{5 public function recursively_search_text_files_in_dir($search_text,$dir)6 {7 if(is_dir($dir))8 {9 if($dh = opendir($dir))10 {11 while(($file = readdir($dh)) !== false)12 {13 $file_path = $dir . '/' . $file;14 if(is_dir($file_path))15 {16 if($file != '.' && $file != '..')17 {18 $this->recursively_search_text_files_in_dir($search_text,$file_path);19 }20 }21 elseif(is_file($file_path))22 {23 if(pathinfo($file_path,PATHINFO_EXTENSION) == 'txt')24 {25 $file_handle = fopen($file_path,'r');26 $file_content = fread($file_handle,filesize($file_path));27 fclose($file_handle);28 if(strpos($file_content,$search_text) !== false)29 {30';31 }32 }33 }34 }35 closedir($dh);36 }37 }38 }39}

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 recursively_search_text_files_in_dir code on LambdaTest Cloud Grid

Execute automation tests with recursively_search_text_files_in_dir 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