testing/tinderbox-standalone-tests/Tests/LayoutPerformanceTest.pm
author Benjamin Stover <bstover@mozilla.com>
Wed, 30 Jun 2010 16:08:28 -0700
changeset 47125 f9a700607b86514c86ac85387f7d64206d7e23fa
parent 1 9b2a99adc05e53cd4010de512f50118594756650
child 94475 f4157e8c410708d76703f19e4dfb61859bfe32d8
permissions -rw-r--r--
Bug 556400 - Make adding visits asynchronous. r=sdwilsh r=mak sr=bz

sub LayoutPerformanceTest {
    my ($build_dir, $binary) = @_;

    my $layout_test_result;
    my $layout_time_details;
    my $binary_basename = File::Basename::basename($binary);
    my $binary_dir = File::Basename::dirname($binary);
    #my $url = "http://$Settings::pageload_server/page-loader/loader.pl?delay=1000&nocache=0&maxcyc=4&timeout=$Settings::LayoutPerformanceTestPageTimeout&auto=1";
    my $timeout_secs = 4500;
    my $url = 'file:///home/rhelmer/src/mozilla/tools/performance/pageload/cycler.html';
    $args = [$binary, $url];
    
    # Settle OS.
    system('/bin/sh -c "sync; sleep 5"');
    

    my $result = Util::run_cmd($build_dir, $binary_dir, $args, $timeout_secs);

    my $layout_time = Util::extract_token(
                                        $result->{output}, 
                                        "_x_x_mozilla_page_load",
                                        ",");
    
    if($layout_time) {
      chomp($layout_time);
      my @times = split(',', $layout_time);
      $layout_time = $times[0];  # Set layout time to first number. 
      print("Layout time: $layout_time");
    } else {
      Util::print_log("TinderboxPrint:Tp:[CRASH]\n");
    }
    
    # Set test status.
    if($layout_time) {
      $layout_test_result = 'success';
      Util::print_log("LayoutPerformanceTest: test succeeded\n");
    } else {
      $layout_test_result = 'testfailed';
      Util::print_log("LayoutPerformanceTest: test failed\n");
    }
    
    if($layout_test_result eq 'success') {
      my $tp_prefix = "";
      if($Settings::BinaryName eq "TestGtkEmbed") {
        $tp_prefix = "m";
      }
      
      Util::print_log_test_result_ms('pageload',
                               'Avg of the median per url pageload time',
                               $layout_time, 'Tp');
      
      # Pull out detail data from log.
      my $raw_data = Util::extract_token($result->{output}, 
                                         "_x_x_mozilla_page_load_details", 
                                         ",");
      chomp($raw_data);
      
      if($Settings::TestsPhoneHome) {
        Util::send_results_to_server($layout_time, $raw_data, "pageload");
      }
    }

    return $layout_test_result;
}

1;