activityfw/activityserviceplugin/tsrc/ctc.pl
author Jaakko Haukipuro (Nokia-MS/Oulu) <Jaakko.Haukipuro@nokia.com>
Thu, 16 Sep 2010 12:11:40 +0100
changeset 117 c63ee96dbe5f
permissions -rw-r--r--
Missing activityfw and taskswitcher components - fix for Bug 3670

#!/usr/bin/perl
#
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
# This component and the accompanying materials are made available
# under the terms of "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
#
# Initial Contributors:
# Nokia Corporation - initial contribution.
#
# Contributors:
#
# Description:
#
 
#USAGE:
#    Usage: 101ctc.pl [-make=command]
#    -make=instrument || run || ctcpost

# import module
use Getopt::Long;
use Cwd;
use Win32::Job;

# read options
my $make = "all";
my $success = GetOptions ("make=s"   => \$make);

if($make) {
	chdir("..");
    
    my @testdirs = ( "tsrc\\unittest_activityclient" , 
                     "tsrc\\unittest_activitydatastorage" , 
                     "tsrc\\unittest_activitymanager" , 
                     "tsrc\\unittest_activityserviceplugin" );

    if (($make eq "instrument") || ($make eq "all")) {
		`for /R . %i IN (mon.*) DO del %i`;
        system("del profile.txt");
		`for /D %f IN (CTC*) DO rmdir /S /Q %f`;

        system("call qmake -spec symbian-sbsv2");
        system("call sbs reallyclean -c winscw_udeb");
        system("call sbs -j 4 -c winscw_udeb");
		
        my $cwd = cwd();
        foreach my $testdir (@testdirs) {
            chdir($testdir);
			system("call qmake -config coverage");
			system("call bldmake bldfiles");
			system("call abld makefile winscw");
			system("call abld reallyclean winscw");
			system("ctcwrap -i fd -C EXCLUDE+moc_*.cpp,*/tsrc/* -C SOURCE_IDENTIFICATION=absolute abld build winscw udeb");        
            chdir($cwd);            
        }
    }
    if (($make eq "run") || ($make eq "all")) {
        foreach my $testdir (@testdirs) {
            my $test = (split m/\\/ , $testdir)[-1];
			print ("Running $test\n");
            if ( run_for("\\epoc32\\release\\winscw\\udeb\\$test.exe", "$test.exe >C:\\testresult_$test.txt", 300) ) {
                warn("$test execution timed out.");
            }
        }        
    }
    if (($make eq "ctcpost") || ($make eq "all")) {
        my $coverageData = "";

        foreach my $testdir (@testdirs) {
            if (-e "$testdir\\MON.dat" && -e "$testdir\\MON.sym") {
                $coverageData .= "$testdir\\MON.dat ";
            }
        }
        if ( $coverageData ne "" ) {
            system("call ctcpost -ff $coverageData -p profile.txt");
            system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
            system("call del profile.txt");
            system("call ctcpost -T 70 -fd $coverageData -p profile.txt");
            system("call ctc2html -t 70 -nsb -i profile.txt -o CTCDECISION");
        } else {
            warn("No coverage data generated.");
        }
    }
}

print "END.\n";

sub run_for {
    my ($cmd, $args, $timeout) = @_;
    my $job = Win32::Job->new() or die "Error creating job: $^E";
    my $pid = $job->spawn($cmd, $args, { stdin => 'NUL', stdout => 'NUL', stderr => 'NUL' } ) or die "Error starting job $cmd: $^E";
    $job->run($timeout);
    my $stat = $job->status();
    exists($stat->{$pid}) or die "No status for $pid ($cmd)";
    return $stat->{$pid}->{exitcode};
}