From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8215A3033E9 for ; Sun, 31 May 2026 05:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780205294; cv=none; b=NhQMXlmW4D2oEulrNVpe425l3MJHFnwNaXtPeHbu/+qE//HG+kFnDgNn+R1KPU7LC2qezp/knrwwz6tHMUUkz4rt9geouuq5NBGoeMJZHD1TIboAhb8CK1PNoRYCPxpocspykjt7mLJ8yguv64aY9a4/9PCrvJKYp+nXfrsLjW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780205294; c=relaxed/simple; bh=o9S1W3Wj0PsfPl6uVprUkU7SxJX/Cs5+m2/NbSFzAE4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Q9A6xLEw/04f6mMl5Hr+nH+nNOu9xz+en4f+l2LeSZxkj0G64JM69B94X7sGw6u61jmz1xon3WkJG60eNPGfS9mLCfWQPc6FjeDw863wG1Zoda0ORr+e67brqWJv99W7tuX2kC53EBd7bxVd29MeDJaBaA5rX3+i+v5wBuwFMas= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fT0LaJ4b; arc=none smtp.client-ip=74.125.82.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fT0LaJ4b" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-304e7fbfaf5so3150001eec.1 for ; Sat, 30 May 2026 22:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780205285; x=1780810085; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=fS0VKuH2a4WRNjAkM6oVJSakxkg1EpritKWTCB2wi2A=; b=fT0LaJ4bhadq3MSOv1NUUS6PsqfcEfVUuo7fKsVvmQWR5KucTKiNYcVwPTAPM1uYGJ +WnZVuCFgwDVz6xQukWsY/Zb1erg2T3GLE7G4MQM9E2djTy1imcM2Yz91RBxP2C2jh0a fbDcg1jjiMTto/FzQPUjsNKF+iwdbOt0GOt7wtVez+YVoQ/hvDqpktF3HMp4XJqMDXIF g8mYyh2Z6KPzlAeaj8MagrIy9vfyBPjXpFJjNI9ThaRSgPyi+PrQPXTSWxetL2a8dSDc B38w4tEDvx4OtBOgDfOHJJyUV+9/M4wFvRC6vNEvpTv3xfdTMkQKSNVluvIDCrmparjN 6NqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780205285; x=1780810085; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fS0VKuH2a4WRNjAkM6oVJSakxkg1EpritKWTCB2wi2A=; b=dxqE8UOP7bN8vPK/KjpERX+usLzdXUHf/FuXEV+Dv1xTYRazFjVkN0XwFZvsiSTTNW LdwgwX5NnzfqHsahjvCDALmPOBEppgP/cSa6NmYGvan/7uF4FHB6xyPDlLmCPvojdWhg 4sBoYjmE3CVR8QZx8sijLAyIYkCyTPQcXUKiFijGN3Yyn3Q83zbZJE519hmIXLFfNElK I2kPNXnO1h7y+gWLTS85HOCvD8JvCjSD33eaRm587d9tchmS6sJ7+fVSg8sKRR/qBx+p OehLfFuWUiPHYOV/2usp06hbJaAfEhwOBnqkqhC/Z18pa9Hb6Jci8lRSBugY1wXU+IZw FCcw== X-Forwarded-Encrypted: i=1; AFNElJ9tuKfrbJRDNKHgSx6k/ce6nfKZPP2mp9l8Zt47iTVWzBSDHIlCj0kDR/xYmO7jUp/j9/o4uwgU1pFLc+M=@vger.kernel.org X-Gm-Message-State: AOJu0YwF6sCvDvEXlg3kQYJ3BfIODuXXP/VdiPB+BRlRVjm/dLjgSZEH PkmYjLHpjiS1x2kdPCAuJ6ZDFihEJQnLZ2gcoFmIZ/PmwEOUZ3NFK5FfvuUK/JiSuzsoWMlyhlB htxA0Viiy5w== X-Received: from dybrp19.prod.google.com ([2002:a05:7301:4613:b0:304:eb73:cff1]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:641c:b0:2c5:b23e:48a6 with SMTP id 5a478bee46e88-304fa6197dfmr2866920eec.23.1780205284259; Sat, 30 May 2026 22:28:04 -0700 (PDT) Date: Sat, 30 May 2026 22:27:36 -0700 In-Reply-To: <20260531052740.796087-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260513230450.529380-1-irogers@google.com> <20260531052740.796087-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260531052740.796087-11-irogers@google.com> Subject: [PATCH v2 10/14] perf test: Skip shebang and SPDX comments in shell test descriptions From: Ian Rogers To: irogers@google.com, acme@kernel.org, adrian.hunter@intel.com, namhyung@kernel.org Cc: alexander.shishkin@linux.intel.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org Content-Type: text/plain; charset="UTF-8" When extracting shell test descriptions in tests-scripts.c, the parser skipped the first line assuming it was the shebang (#!/bin/sh) and then read the first comment line on line 2 as the test description. However, checkpatch.pl expects shell scripts to declare their SPDX license identifier on line 2 (# SPDX-License-Identifier: ...). This caused the test harness to extract the SPDX license string as the test description. Refactor shell_test__description to use io__getline, skipping both shebang and SPDX comment lines. This allows shell tests to include standard SPDX headers without breaking test suite description extraction. Assisted-by: Gemini-CLI:Google Gemini 3 Signed-off-by: Ian Rogers --- tools/perf/tests/tests-scripts.c | 64 +++++++++++++++++--------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/tools/perf/tests/tests-scripts.c b/tools/perf/tests/tests-scripts.c index f18c4cd337c8..48a2624da643 100644 --- a/tools/perf/tests/tests-scripts.c +++ b/tools/perf/tests/tests-scripts.c @@ -78,43 +78,49 @@ static int shell_tests__dir_fd(void) static char *shell_test__description(int dir_fd, const char *name) { struct io io; - char buf[128], desc[256]; - int ch, pos = 0; + char buf[128], *line = NULL; + size_t line_len = 0; + ssize_t len; + char *desc = NULL; io__init(&io, openat(dir_fd, name, O_RDONLY), buf, sizeof(buf)); if (io.fd < 0) return NULL; - /* Skip first line - should be #!/bin/bash Shebang */ - if (io__get_char(&io) != '#') - goto err_out; - if (io__get_char(&io) != '!') - goto err_out; - do { - ch = io__get_char(&io); - if (ch < 0) - goto err_out; - } while (ch != '\n'); - - do { - ch = io__get_char(&io); - if (ch < 0) - goto err_out; - } while (ch == '#' || isspace(ch)); - while (ch > 0 && ch != '\n') { - desc[pos++] = ch; - if (pos >= (int)sizeof(desc) - 1) + while ((len = io__getline(&io, &line, &line_len)) > 0) { + char *p = line; + + /* Skip leading whitespace */ + while (*p && isspace(*p)) + p++; + + /* Must be a comment */ + if (*p != '#') + continue; + p++; + + /* Skip shebang or SPDX lines */ + if (*p == '!' || strstr(p, "SPDX-License-Identifier:")) + continue; + + /* Skip whitespace after # */ + while (*p && isspace(*p)) + p++; + + /* If we found non-empty text, this is the description! */ + if (*p && *p != '\n') { + char *end = p + strlen(p); + + while (end > p && isspace(end[-1])) + end--; + *end = '\0'; + desc = strdup(p); break; - ch = io__get_char(&io); + } } - while (pos > 0 && isspace(desc[--pos])) - ; - desc[++pos] = '\0'; - close(io.fd); - return strdup(desc); -err_out: + free(line); close(io.fd); - return NULL; + return desc; } /* Is this full file path a shell script */ -- 2.54.0.823.g6e5bcc1fc9-goog