Changeset 27480 for gs2-extensions/parallel-building
- Timestamp:
- 2013-05-27T12:22:03+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/parallel-building/trunk/src/bin/script/test_fileutils.pl
r27436 r27480 7 7 # Configure 8 8 my $user = 'jmt12'; 9 my $hadoop_path = '/mnt/sdb1/jmt12/gsdl2-svn/ext/parallel-building/packages/hadoop-1.1.0';10 9 my $redirect_errors = 0; 11 10 my $display_errors = 0; 12 11 13 my $test_localfs = 0;12 my $test_localfs = 1; 14 13 my $test_hdthriftfs = 1; 15 my $test_hdfsshell = 0;14 my $test_hdfsshell = 1; 16 15 17 16 # Globals … … 49 48 } 50 49 } 50 51 # Manually installed CPAN package in GEXT*INSTALL 52 # - parse up version number 53 my ($major, $minor, $revision) = $] =~ /(\d+)\.(\d\d\d)(\d\d\d)/; 54 # - get rid of leading zeros by making them integers 55 $major += 0; 56 $minor += 0; 57 $revision += 0; 58 # - and add to Perl's path 59 unshift (@INC, $ENV{'GEXTPARALLELBUILDING_INSTALLED'} . '/lib/perl/' . $major . '.' . $minor . '.' . $revision); 51 60 } 52 61 53 62 use Cwd; 54 use DateTime;55 63 use Devel::Peek; 56 64 … … 58 66 59 67 # populate globals 60 $base_path = getcwd();68 $base_path = $ENV{'GEXTPARALLELBUILDING'}; 61 69 62 70 print "\n"; … … 255 263 my ($dir, $base_dir) = @_; 256 264 # setup 257 my $local_image_path = $base_path . '/ ../../resources/aurora_australus.jpg';265 my $local_image_path = $base_path . '/resources/aurora_australus.jpg'; 258 266 my $thrift_copy_path = $dir . '/test_binary_transfer.jpg'; 259 267 my $local_copy_path = '/tmp/test_binary_transfer.jpg'; … … 464 472 { 465 473 my ($dir) = @_; 474 # setup 466 475 my $patha = $dir . '/alpha.txt'; 467 my $exact_modification_time = time(); 468 #rint STDERR "Exact Modification Time: $exact_modification_time\n"; 476 my $modification_time = time(); 469 477 &FileUtils::filePutContents($patha, 'Hello World'); 470 478 my $file_modification_time = &FileUtils::modificationTime($patha); 471 #rint STDERR "File Modification Time: $file_modification_time\n"; 472 # Try to find an exact match first 473 if ($exact_modification_time == $file_modification_time) 474 { 475 $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (exact)', 1, 1); 476 } 477 # Failing that, we can try a rounded match (for file systems that 478 # don't store modification times down to the second i.e. HDFSShell) 479 else 480 { 481 $skip_count += &skipAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (exact)'); 482 my ($mod_second, $mod_minute, $mod_hour, $mod_day, $mod_month, $mod_year) = localtime($exact_modification_time); 483 $mod_year += 1900; # initially years since 1900, silly computer scientists 484 $mod_month += 1; # in the range [0..11], silly computer scientists 485 my $mod_datetime = DateTime->new(year => $mod_year, 486 month => $mod_month, 487 day => $mod_day, 488 hour => $mod_hour, 489 minute => $mod_minute, 490 second => 0, 491 time_zone => 'local'); 492 my $start_modification_time = $mod_datetime->epoch(); 493 #rint STDERR "Start Modification Time: $start_modification_time\n"; 494 if ($start_modification_time == $file_modification_time) 495 { 496 $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (rounded)', 1, 1); 497 } 498 # And finally we just accept any time that lies within the same minute 499 else 500 { 501 $skip_count += &skipAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (rounded)'); 502 $mod_datetime->add( minutes => 1 ); 503 my $end_modification_time = $mod_datetime->epoch(); 504 #rint STDERR "End Modification Time: $end_modification_time\n"; 505 $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (approximate)', 1, ($start_modification_time <= $file_modification_time && $file_modification_time <= $end_modification_time ? 1 : 0)); 506 } 507 } 479 # test 480 $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc', $modification_time, $file_modification_time); 508 481 # cleanup 509 482 &FileUtils::removeFiles($patha);
Note:
See TracChangeset
for help on using the changeset viewer.