Project

General

Profile

harness_sikuli.diff

Roger Borrello, 11/10/2022 10:35 PM

Download (3.43 KB)

View differences:

/home/rfb/projects/harness/src/com/goldencode/harness/test/BinaryFileComparison.java
81 81
   }
82 82
   
83 83
   /**
84
    * Detect if the actual data file generated during testing matches the
84
    * Worker that detects if the actual data file generated during testing matches the
85 85
    * given baseline file outside of any specified exclusion regions.
86 86
    *
87 87
    * @param    base
88 88
    *           Baseline file data.
89 89
    * @param    other
90 90
    *           Comparison file data.
91
    * @param    excludes
92
    *           A list of portions of the byte stream to be ignored for
93
    *           comparison purposes or <code>null</code> if there are no
94
    *           exclusion regions.
91 95
    *
92 96
    * @return   <code>null</code> if the actual file is the same as the
93 97
    *           baseline file (after ignoring any exclusion regions) or an
94 98
    *           error string on any deviation.
95 99
    */
96
   public String compare(File base, File other)
100
   public static String compareWorker(File base, File other, ExclusionRegion[] excludes)
97 101
   throws Exception
98 102
   {
99 103
      long baseLen  = base.length();
......
122 126
            return String.format(EOF_SPEC, nextBase, nextOther);
123 127
         }
124 128
         
125
         if (exclude(j))
129
         if (excludeWorker(j, excludes))
126 130
         {
127 131
            // ignore the byte
128 132
            continue;
......
144 148
   }
145 149
   
146 150
   /**
151
    * Detect if the actual data file generated during testing matches the
152
    * given baseline file outside of any specified exclusion regions.
153
    *
154
    * @param    base
155
    *           Baseline file data.
156
    * @param    other
157
    *           Comparison file data.
158
    *
159
    * @return   <code>null</code> if the actual file is the same as the
160
    *           baseline file (after ignoring any exclusion regions) or an
161
    *           error string on any deviation.
162
    */
163
   public String compare(File base, File other)
164
   throws Exception
165
   {
166
      return compareWorker(base, other, excludes);
167
   }
168
   
169
   /**
170
    * Worker that reports if the given index position is contained within the list of
171
    * excluded regions.
172
    * 
173
    * @param    num
174
    *           Zero-based index position to check.
175
    * @param    excludes
176
    *           A list of portions of the byte stream to be ignored for
177
    *           comparison purposes or <code>null</code> if there are no
178
    *           exclusion regions.
179
    *
180
    * @return   <code>true</code> if the given index is contained inside any
181
    *           of the excluded regions.
182
    */
183
   private static boolean excludeWorker(long num, ExclusionRegion[] excludes)
184
   {
185
      if (excludes != null)
186
      {
187
         for (int i = 0; i < excludes.length; i++)
188
         {
189
            if (excludes[i].contains(num))
190
            {
191
               return true;
192
            }
193
         }
194
      }
195
      
196
      return false;
197
   }
198

  
199
   /**
147 200
    * Report if the given index position is contained within the list of
148 201
    * excluded regions.
149 202
    * 
......
155 208
    */
156 209
   public boolean exclude(long num)
157 210
   {
158
      if (excludes != null)
159
      {
160
         for (int i = 0; i < excludes.length; i++)
161
         {
162
            if (excludes[i].contains(num))
163
            {
164
               return true;
165
            }
166
         }
167
      }
168
      
169
      return false;
170
   }
211
      return excludeWorker(num, excludes);
212
   }  
171 213
}