rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # Copyright Statement: |
| 4 | # -------------------- |
| 5 | # This software is protected by Copyright and the information contained |
| 6 | # herein is confidential. The software may not be copied and the information |
| 7 | # contained herein may not be used or disclosed except with the written |
| 8 | # permission of MediaTek Inc. (C) 2005 |
| 9 | # |
| 10 | # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 11 | # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 12 | # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 13 | # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 16 | # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 17 | # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 18 | # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 19 | # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 20 | # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 21 | # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 22 | # |
| 23 | # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 24 | # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 25 | # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 26 | # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 27 | # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 28 | # |
| 29 | # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 30 | # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 31 | # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 32 | # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 33 | # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 34 | # |
| 35 | # |
| 36 | #***************************************************************************** |
| 37 | #***************************************************************************** |
| 38 | ##* |
| 39 | ##* Filename: |
| 40 | ##* --------- |
| 41 | ##* chk_sysdrv_log.pl |
| 42 | ##* |
| 43 | ##* Project: |
| 44 | ##* -------- |
| 45 | ##* MOLY |
| 46 | ##* |
| 47 | ##* Description: |
| 48 | ##* ------------ |
| 49 | ##* This script parse the chksysdrv.log and check it's error or not |
| 50 | ## |
| 51 | ##* Author: |
| 52 | ##* ------- |
| 53 | ##* kk Lin-Wang (mtk04222) |
| 54 | ##* |
| 55 | ##*============================================================================ |
| 56 | use strict; |
| 57 | use warnings; |
| 58 | use File::Path; |
| 59 | |
| 60 | my $log_path = $ARGV[0]; # log file path |
| 61 | my $bin_path = $ARGV[1]; # bin file path |
| 62 | ($#ARGV < 1) && &Usage; |
| 63 | |
| 64 | open (FLOG, "<$log_path") or &error_handler("$log_path : file error!", __FILE__, __LINE__); |
| 65 | my $backup = $/; |
| 66 | undef $/; |
| 67 | my $reading = <FLOG>; |
| 68 | close(FLOG); |
| 69 | |
| 70 | if ($reading =~ /Shortage/i) { |
| 71 | print "Error: cksysdrv has errors. Delete the binary file.\n"; |
| 72 | if (-f $bin_path){ |
| 73 | unlink("$bin_path") or &error_handler("$bin_path : file error!", __FILE__, __LINE__); |
| 74 | } |
| 75 | elsif (-d $bin_path) { |
| 76 | rmtree($bin_path) or &error_handler("$bin_path : file error!", __FILE__, __LINE__); |
| 77 | } |
| 78 | exit 1; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | |
| 83 | #**************************************************************************** |
| 84 | # subroutine: error_handler |
| 85 | # input: $error_msg: error message |
| 86 | #**************************************************************************** |
| 87 | sub error_handler |
| 88 | { |
| 89 | my ($error_msg, $file, $line_no) = @_; |
| 90 | |
| 91 | my $final_error_msg = "ERROR: $error_msg at $file line $line_no\n"; |
| 92 | print $final_error_msg; |
| 93 | die $final_error_msg; |
| 94 | } |
| 95 | |
| 96 | #****************************************************************************** |
| 97 | ## FUNCTION |
| 98 | ## Usage |
| 99 | ## DESCRIPTION |
| 100 | ## Display the manipulation of this script |
| 101 | ##****************************************************************************** |
| 102 | sub Usage |
| 103 | { |
| 104 | warn <<"_END_OF_USAGE"; |
| 105 | Usage: |
| 106 | chk_sysdrv_log.pl [Path of ckSysDrv.log] [Path of bin file] |
| 107 | Description: |
| 108 | check whether if there is existing error in cksysdrv.log or not. |
| 109 | _END_OF_USAGE |
| 110 | exit 1; |
| 111 | } |
| 112 | |