From patchwork Wed Jun 5 16:06:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 165910 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7548115ili; Wed, 5 Jun 2019 09:06:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4amSOIF/lHHkZw65PTQsTKg1nih6jCzagxNlZb+NSBCXbUXBFy8zi+OOblPdmtURTHnJY X-Received: by 2002:a17:902:e301:: with SMTP id cg1mr25680302plb.184.1559750798281; Wed, 05 Jun 2019 09:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559750798; cv=none; d=google.com; s=arc-20160816; b=MgdztFqSG6+Sw6qztiSdSopp4uP23vVKRf2pZaRlemu/VPYHdqw9IgWq/dHiistzTp IFrUYKWDkAKzGOo4BdOBbK07FEZQZ35NJ58SVaBFAbRRZPOBvzK312pOCqDD6cUCKTWG KDW9u5VeKiTqtAShCuaLoN6NGwTlXASc/PPJ34A614VfqFh8vzcbT8lifgIwZlZeIcq+ H+fuBwf0eNIe1khpzVgydHy0Iou7QeRw5WlBHtfLE6sM6rW1znouTiXuNzPodtH3y/wN 8igKnsuMLElqHEIjWh3+OQVeO3vS9UoBDEuyoXgHlKLFU0aHQxEngBEmNpXEjLIXUsyr fM9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=O2AsXPacOPq2MlOCLv9ucstIt/wgBhaf6HM7ekPRgDk=; b=RExv+xLigi7plA/+x5ww0ItXGVSeDOZ4kS54DrRdrndXtuOxvgZNQ/PqADby3WOqIJ +sH0BQgqvhXrcSFIku2NJtWxi5ttiw28ul+w5iwM1MSjMPFAlYFxpm5Kpygbiqdns3xB 4ZejNIGToyStzJG7K99Qa8rtCoUfOGivihjN5am1ncx3ImvulgkWJ1AGigDlIcPh5R/D RcPe7IfeoW3sCOJXQ7wjJEX3HEm0KTug21znWxOOGNzjEnW7NwXZdFq6Lx2Gfz8HDNIH pkZMXlFPy+NvH0f4giVKZk5hRqnb8g1Vh3WJ4B+xAz31MSgZfCf5o2K2wtJjIhTnboAR h1Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-rt-users-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-rt-users-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=monom.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si27364257pgm.101.2019.06.05.09.06.38; Wed, 05 Jun 2019 09:06:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-rt-users-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-rt-users-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-rt-users-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=monom.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728633AbfFEQGh (ORCPT + 3 others); Wed, 5 Jun 2019 12:06:37 -0400 Received: from mail.monom.org ([188.138.9.77]:35608 "EHLO mail.monom.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728523AbfFEQGg (ORCPT ); Wed, 5 Jun 2019 12:06:36 -0400 Received: from mail.monom.org (localhost [127.0.0.1]) by filter.mynetwork.local (Postfix) with ESMTP id 65DFF50093C; Wed, 5 Jun 2019 18:06:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.monom.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (ppp-93-104-174-142.dynamic.mnet-online.de [93.104.174.142]) by mail.monom.org (Postfix) with ESMTPSA id 276675004BB; Wed, 5 Jun 2019 18:06:33 +0200 (CEST) From: Daniel Wagner To: John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH v2 06/12] pmqtest: Add duration command line argument Date: Wed, 5 Jun 2019 18:06:11 +0200 Message-Id: <20190605160617.22987-7-wagi@monom.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605160617.22987-1-wagi@monom.org> References: <20190605160617.22987-1-wagi@monom.org> MIME-Version: 1.0 Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000? To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand. For example run the test for 10 minutes and timeout at 11 minutes: # timeout 11m pmqtest -D 10m Signed-off-by: Daniel Wagner --- src/pmqtest/pmqtest.8 | 5 +++++ src/pmqtest/pmqtest.c | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) -- 2.20.1 Signed-off-by: John Kacur diff --git a/src/pmqtest/pmqtest.8 b/src/pmqtest/pmqtest.8 index 05421e01e70b..9108a939b9f7 100644 --- a/src/pmqtest/pmqtest.8 +++ b/src/pmqtest/pmqtest.8 @@ -21,6 +21,11 @@ It is useful to track down unexpected large latencies of a system. .B \-d, \-\-distance=DIST Set the distance of thread intervals in microseconds (default is 500 us). When pmqtest is called with the -t option and more than one thread is created, then this distance value is added to the interval of the threads: Interval(thread N) = Interval(thread N-1) + DIST .TP +.B \-D, \-\-duration=TIME +Specify a length for the test run. +.br +Append 'm', 'h', or 'd' to specify minutes, hours or days. +.TP .B \-f, \-\-forcetimeout=TO Set an artificial delay of the send function to force timeout of the receiver, requires the -T option .TP diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c index 75d5ee8185a0..054768d161a7 100644 --- a/src/pmqtest/pmqtest.c +++ b/src/pmqtest/pmqtest.c @@ -252,6 +252,8 @@ static void display_help(void) "-f TO --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n" "-i INTV --interval=INTV base interval of thread in us default=1000\n" "-l LOOPS --loops=LOOPS number of loops: default=0(endless)\n" + "-D --duration=TIME specify a length for the test run.\n" + " Append 'm', 'h', or 'd' to specify minutes, hours or days.\n" "-p PRIO --prio=PRIO priority\n" "-S --smp SMP testing: options -a -t and same priority\n" " of all threads\n" @@ -271,6 +273,7 @@ static int tracelimit; static int priority; static int num_threads = 1; static int max_cycles; +static int duration; static int interval = 1000; static int distance = 500; static int smp; @@ -293,6 +296,7 @@ static void process_options (int argc, char *argv[]) {"forcetimeout", required_argument, NULL, 'f'}, {"interval", required_argument, NULL, 'i'}, {"loops", required_argument, NULL, 'l'}, + {"duration", required_argument, NULL, 'D'}, {"priority", required_argument, NULL, 'p'}, {"smp", no_argument, NULL, 'S'}, {"threads", optional_argument, NULL, 't'}, @@ -300,7 +304,7 @@ static void process_options (int argc, char *argv[]) {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; - int c = getopt_long (argc, argv, "a::b:d:f:i:l:p:St::T:", + int c = getopt_long (argc, argv, "a::b:d:f:i:l:D:p:St::T:", long_options, &option_index); if (c == -1) break; @@ -325,6 +329,7 @@ static void process_options (int argc, char *argv[]) case 'f': forcetimeout = atoi(optarg); break; case 'i': interval = atoi(optarg); break; case 'l': max_cycles = atoi(optarg); break; + case 'D': duration = parse_time_string(optarg); break; case 'p': priority = atoi(optarg); break; case 'S': smp = 1; @@ -369,7 +374,10 @@ static void process_options (int argc, char *argv[]) if (forcetimeout && !timeout) error = 1; - + + if (duration < 0) + error = 1; + if (priority && smp) sameprio = 1; @@ -418,10 +426,15 @@ int main(int argc, char *argv[]) sigemptyset(&sigset); sigaddset(&sigset, SIGTERM); sigaddset(&sigset, SIGINT); + sigaddset(&sigset, SIGALRM); pthread_sigmask(SIG_SETMASK, &sigset, NULL); signal(SIGINT, sighand); signal(SIGTERM, sighand); + signal(SIGALRM, sighand); + + if (duration) + alarm(duration); receiver = calloc(num_threads, sizeof(struct params)); sender = calloc(num_threads, sizeof(struct params));