usbmgmt/usbmgrtest/automation/runcmd.pl
changeset 0 c9bc50fca66e
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 # Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # runcmd log expected-result command
       
    15 # 
       
    16 #
       
    17 
       
    18 use File::Basename;
       
    19 use File::Path;
       
    20 
       
    21 ($#ARGV >= 3) or die "Usage: runcmd log expected-result command";
       
    22 
       
    23 ($log, $expected, @command) = @ARGV;
       
    24 
       
    25 $cmd = "";
       
    26 for my $c (@command) {$cmd = $cmd.$c." "};
       
    27 
       
    28 print "Executing: ".$cmd."\n";
       
    29 $ret = system($cmd) >> 8;
       
    30 
       
    31 mkpath(dirname($log));
       
    32 open LOG, ">>".$log;
       
    33 print LOG "$cmd\n";
       
    34 if ($ret == $expected) {
       
    35 	print LOG "PASS\n";
       
    36 }
       
    37 else {
       
    38 	print LOG "FAIL\n";
       
    39 }
       
    40 close LOG;