1 #! /usr/perl5/bin/perl 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 23 # 24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 # ident "@(#)stf_compare.pl 1.5 07/04/12 SMI" 28 # 29 30 ## File: stf_compare 31 ## compare the results from an existing baseline file and 32 ## a new journal file in baseline format. 33 34 $Basekey = '_bAseLinE_STF'; 35 36 if ($#ARGV != 1) { 37 die "usage: $0 basenamefile newbasenamefile\n"; 38 } 39 40 $EXP_BASE = $ARGV[0]; 41 $NEW_BASE = $ARGV[1]; 42 43 open(EXP_BASE, $EXP_BASE) || die "$0: can't open file, $EXP_BASE\n"; 44 open(NEW_BASE, $NEW_BASE) || die "$0: can't open file, $NEW_BASE\n"; 45 46 $check_key = <EXP_BASE>; 47 if ($check_key !~ /^$Basekey/) { 48 die "$0: $EXP_BASE is not in baseline format, use stf_filter before proceeding.\n"; 49 } 50 51 $check_key = <NEW_BASE>; 52 if ($check_key !~ /^$Basekey/) { 53 die "$0: $NEW_BASE, is not in baseline format, use stf_filter before proceeding.\n"; 54 } 55 56 ## load up the associative array of test numbers and results for the new file ## 57 while(<NEW_BASE>) { 58 split; 59 $new_key = shift @_; 60 ## build an array of only the name key without results ## 61 $newnames {$new_key} = 1; 62 ## strip off the total count and use only result name ## 63 foreach $result(@_) { 64 ($resultname, $count)= split(/:/, $result); 65 $newresult {$new_key, $resultname} = 1; 66 } 67 } 68 69 close NEW_BASE; 70 71 ## load up the associative array of test numbers and results for the baseline file ## 72 73 while(<EXP_BASE>) { 74 split; 75 $exp_key = shift @_; 76 ## strip off the total count and use only result name ## 77 foreach $result(@_) { 78 ($resultname, $count)= split(/:/, $result); 79 $expresult{$exp_key, $resultname} = 1; 80 } 81 $match_found = $newnames{$exp_key}; 82 if (!$match_found) { 83 print "< ", $exp_key, "\n"; 84 } 85 } 86 87 close EXP_BASE; 88 89 ## No need to sort the arrays because the baseline format is already sorted ## 90 91 ## Find the differences in the new results array ## 92 grep($tmp_array1{$_}++, %expresult); 93 @diffs = grep(!$tmp_array1{$_}, %newresult); 94 $onetime = 0; 95 96 foreach $diffline (@diffs) { 97 ($id, $resultname) = split(/\034/, $diffline); 98 print "> ", $id, "\t", $resultname, "\n"; 99 } 100