1#!/bin/bash 2# 3# Copyright 2014 The Chromium OS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6# 7# count_labels: Print a summary of how many times a particular label 8# value occurs in the output of an `atest host list` command. 9# 10# To find the sizes of the pools assigned to a board: 11# atest host list -b board:$BOARD | count_labels -p 12# 13# To find how many of each board is assigned to a pool: 14# atest host list -b pool:$POOL | count_labels -b 15 16while getopts 'pbv' flag 17do 18 case $flag in 19 p) LABEL=pool ;; 20 b) LABEL=board ;; 21 v) LABEL=variant ;; 22 esac 23done 24 25sed -e "/$LABEL:/ !d" -e "s=.*$LABEL:\([^,]*\).*=\1=" | sort | uniq -c 26