1#!/usr/bin/env python3 2# 3# Copyright (C) 2024 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17''' 18Print the latest Ravenwood test execution summary 19 20Usage: /ravenwood-test-summary 21 22Example output: 23Module Passed Failed Skipped 24android.test.mock.ravenwood.tests 2 0 0 25CarLibHostUnitTest 565 0 7 26CarServiceHostUnitTest 364 0 0 27CtsAccountManagerTestCasesRavenwood 4 0 0 28CtsAppTestCasesRavenwood 21 0 0 29 30Description: 31This script finds all the test execution result from /tmp/Ravenwood-stats*, 32and shows per-module summary. 33''' 34 35import csv 36import glob 37import sys 38 39# Find the latest stats files. 40stats_files = glob.glob('/tmp/Ravenwood-stats_*_latest.csv') 41 42if len(stats_files) == 0: 43 print("No log files found.", file=sys.stderr) 44 exit(1) 45 46 47def parse_stats(file, result): 48 module = '(unknwon)' 49 passed = 0 50 failed = 0 51 skipped = 0 52 with open(file) as csvfile: 53 reader = csv.reader(csvfile, delimiter=',') 54 55 56 for i, row in enumerate(reader): 57 if i == 0: continue # Skip header line 58 module = row[0] 59 passed += int(row[3]) 60 failed += int(row[4]) 61 skipped += int(row[5]) 62 63 result[module] = (passed, failed, skipped) 64 65 66result = {} 67 68for file in stats_files: 69 parse_stats(file, result) 70 71print('%-60s %8s %8s %8s' % ("Module", "Passed", "Failed", "Skipped")) 72 73for module in sorted(result.keys(), key=str.casefold): 74 r = result[module] 75 print('%-60s %8d %8d %8d' % (module, r[0], r[1], r[2])) 76