1''' 2Examines log generated by new_log_flds.test.py, returns 0 if valid, 1 if not. 3''' 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, software 15# distributed under the License is distributed on an "AS IS" BASIS, 16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17# See the License for the specific language governing permissions and 18# limitations under the License. 19 20import sys 21import csv 22 23ccid = [] 24ctid = [] 25 26# Read in log fields from each line of the generated report. 27# 28ln_num = 0 29for ln in csv.reader(sys.stdin, delimiter=' '): 30 ln_num += 1 31 if len(ln) != 3: 32 exit(code=1) 33 i = int(ln[0]) 34 if i < 0: 35 exit(code=1) 36 ccid.append(i) 37 i = int(ln[1]) 38 if i < 0: 39 exit(code=1) 40 ctid.append(i) 41 if ln_num == 7: 42 if ln[2] != "reallyreallyreallyreallylong.com": 43 exit(code=1) 44 else: 45 if ln[2] != "-": 46 exit(code=1) 47 48# Validate contents of report. 49# 50if (ccid[0] != ccid[1] and 51 ccid[1] != ccid[2] and 52 ccid[2] == ccid[3] and 53 ctid[2] != ctid[3] and 54 ccid[3] != ccid[4] and 55 ccid[4] == ccid[5] and 56 ctid[4] != ctid[5] and 57 ccid[5] != ccid[6]): 58 exit(code=0) 59 60# Failure exit if report was not valid. 61# 62exit(code=1) 63