Received: by 2002:a05:6a10:e898:0:0:0:0 with SMTP id gl24csp4316813pxb; Mon, 8 Feb 2021 13:21:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzum0ztGx7tBq2YirfPhD/vbY1fJrVhgJ+L2vXhLtMeiFL81jvlvet7MaxW+nNkPfiMS0HP X-Received: by 2002:a17:907:da3:: with SMTP id go35mr10940305ejc.26.1612819311141; Mon, 08 Feb 2021 13:21:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612819311; cv=none; d=google.com; s=arc-20160816; b=gArlfMn8op1ouGstp4Ehd7HIkDyly7QZlcnzI9UQ/Jkw5dnryrGl6vtWwJ9forkkb9 YlBl3913vosLQAEN3+DNK8UygIvDuZlFZmD8HmvIPVKEe6j8iczpFP2NVqag5fQw0s/j 9FDMR7K4KYiCOoWyMTQTuYg4bwnwlJ/OuFzJ/L9xFgtFfHhpXf91RZEyHP9AF2EcWiuk na36TR27yyt0ZhtNqlVxADBkmsfggRY1/NY5S2qK8CLo8LloZZoQBbIY+BWUEuimdCVd ujyVLlFa+aZb93s5/ml1JJo75Ya8ZLctEHlmQwJtwOfBglIlp2Kbvf7NYbAO5jhbrcP+ sVXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bxp7Q1HkO9K8QjjyHTRqRavZCJoynUCzeH2h5n5zhWk=; b=0Z6SkzgG+CaSJ9MdrkSrXItAaNVQ+Mi3DHmi19/l7M2I1k1nbBz20qPqPk3DOkSN3j usQSAEmsCOsrajk5G84hV67bV+P/V+AKs3lRJZE40jAPpEmKpLvv/qUIZ/pfAXLn9nZZ ZcUtuNDhRaLtBzqA6dC1TLNp1p2OEn+RtkOCJRtLllEEYHfb0J1NSF1S8iUTEDfoQ9nE yo1x/7Qaj19xiIZx8qAYbCdPUgTKsPMYxUE7lE+xvCtcmeP3UJ9wnFc5GkAeCvAokIs/ b1uL4BkGbF4A8JnPy87pxyU7zHLsq74wNVk1TwrYcLIBbD6p8ehgU2JmmTTKLt03TtGB Gxkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si11018119eja.521.2021.02.08.13.21.25; Mon, 08 Feb 2021 13:21:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234473AbhBHVSb convert rfc822-to-8bit (ORCPT + 99 others); Mon, 8 Feb 2021 16:18:31 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:44904 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236685AbhBHULB (ORCPT ); Mon, 8 Feb 2021 15:11:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-361-vMC6Ku-JMvC5DKLK6BUsSw-1; Mon, 08 Feb 2021 15:10:03 -0500 X-MC-Unique: vMC6Ku-JMvC5DKLK6BUsSw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 005FA192D788; Mon, 8 Feb 2021 20:10:02 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.194.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0DF419C59; Mon, 8 Feb 2021 20:09:59 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Alexei Budankov Subject: [PATCH 19/24] perf tests: Add daemon list command test Date: Mon, 8 Feb 2021 21:09:03 +0100 Message-Id: <20210208200908.1019149-20-jolsa@kernel.org> In-Reply-To: <20210208200908.1019149-1-jolsa@kernel.org> References: <20210208200908.1019149-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding test for basic perf daemon listing via the CSV output mode (-x option). Checking that configured sessions display expected values. Signed-off-by: Jiri Olsa --- tools/perf/tests/shell/daemon.sh | 184 +++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100755 tools/perf/tests/shell/daemon.sh diff --git a/tools/perf/tests/shell/daemon.sh b/tools/perf/tests/shell/daemon.sh new file mode 100755 index 000000000000..874e1fd77c7e --- /dev/null +++ b/tools/perf/tests/shell/daemon.sh @@ -0,0 +1,184 @@ +#!/bin/sh +# daemon operations +# SPDX-License-Identifier: GPL-2.0 + +check_line_first() +{ + local line=$1 + local name=$2 + local base=$3 + local output=$4 + local lock=$5 + local up=$6 + + local line_name=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $2 }'` + local line_base=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $3 }'` + local line_output=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $4 }'` + local line_lock=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $5 }'` + local line_up=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $6 }'` + + if [ "${name}" != "${line_name}" ]; then + echo "FAILED: wrong name" + error=1 + fi + + if [ "${base}" != "${line_base}" ]; then + echo "FAILED: wrong base" + error=1 + fi + + if [ "${output}" != "${line_output}" ]; then + echo "FAILED: wrong output" + error=1 + fi + + if [ "${lock}" != "${line_lock}" ]; then + echo "FAILED: wrong lock" + error=1 + fi + + if [ "${up}" != "${line_up}" ]; then + echo "FAILED: wrong up" + error=1 + fi +} + +check_line_other() +{ + local line=$1 + local name=$2 + local run=$3 + local base=$4 + local output=$5 + local control=$6 + local ack=$7 + local up=$8 + + local line_name=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $2 }'` + local line_run=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $3 }'` + local line_base=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $4 }'` + local line_output=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $5 }'` + local line_control=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $6 }'` + local line_ack=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $7 }'` + local line_up=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $8 }'` + + if [ "${name}" != "${line_name}" ]; then + echo "FAILED: wrong name" + error=1 + fi + + if [ "${run}" != "${line_run}" ]; then + echo "FAILED: wrong run" + error=1 + fi + + if [ "${base}" != "${line_base}" ]; then + echo "FAILED: wrong base" + error=1 + fi + + if [ "${output}" != "${line_output}" ]; then + echo "FAILED: wrong output" + error=1 + fi + + if [ "${control}" != "${line_control}" ]; then + echo "FAILED: wrong control" + error=1 + fi + + if [ "${ack}" != "${line_ack}" ]; then + echo "FAILED: wrong ack" + error=1 + fi + + if [ "${up}" != "${line_up}" ]; then + echo "FAILED: wrong up" + error=1 + fi +} + +daemon_start() +{ + local config=$1 + local session=$2 + + perf daemon start --config ${config} + + # wait for the session to ping + local state="FAIL" + while [ "${state}" != "OK" ]; do + state=`perf daemon ping --config ${config} --session ${session} | awk '{ print $1 }'` + sleep 0.05 + done +} + +daemon_exit() +{ + local base=$1 + local config=$2 + + local line=`perf daemon --config ${config} -x: | head -1` + local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'` + + # stop daemon + perf daemon stop --config ${config} + + # ... and wait for the pid to go away + tail --pid=${pid} -f /dev/null +} + +test_list() +{ + echo "test daemon list" + + local config=$(mktemp /tmp/perf.daemon.config.XXX) + local base=$(mktemp -d /tmp/perf.daemon.base.XXX) + + cat < ${config} +[daemon] +base=BASE + +[session-size] +run = -e cpu-clock + +[session-time] +run = -e task-clock +EOF + + sed -i -e "s|BASE|${base}|" ${config} + + # start daemon + daemon_start ${config} size + + # check first line + # pid:daemon:base:base/output:base/lock + local line=`perf daemon --config ${config} -x: | head -1` + check_line_first ${line} daemon ${base} ${base}/output ${base}/lock "0" + + # check 1st session + # pid:size:-e cpu-clock:base/size:base/size/output:base/size/control:base/size/ack:0 + local line=`perf daemon --config ${config} -x: | head -2 | tail -1` + check_line_other "${line}" size "-e cpu-clock" ${base}/session-size \ + ${base}/session-size/output ${base}/session-size/control \ + ${base}/session-size/ack "0" + + # check 2nd session + # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0 + local line=`perf daemon --config ${config} -x: | head -3 | tail -1` + check_line_other "${line}" time "-e task-clock" ${base}/session-time \ + ${base}/session-time/output ${base}/session-time/control \ + ${base}/session-time/ack "0" + + # stop daemon + daemon_exit ${base} ${config} + + rm -rf ${base} + rm -f ${config} +} + +error=0 + +test_list + +exit ${error} -- 2.29.2