From patchwork Mon Jul 29 09:24:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 13744641 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 BEAFD13DDC0; Mon, 29 Jul 2024 09:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722245082; cv=none; b=quc7vsnHxdljB1tpIKsSMA44PzK3KzdwhSiaRKD1Y4nqWJT5CDA9+NsMb9Q4XAerelDkkTTsY5PHdEMiU9AJeTmc2ga8cxGnNxvFg7KB0b116uMZx7zPuKMkoRTkSo69j1KEKZidyZqvjOzA9GYzVPqrz0xCQs7dJ5wt9LyduoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722245082; c=relaxed/simple; bh=mqau6BYFCsnrLX9rIGpXbOOrld7xoidDlOUjA0t1Ii4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qCNGY2alNQXiN9hx4p8qUTv9XIFzpCbRsL47LfBQyaX9nZDLum1eMswgdbD72DCyxsEczniuExB8JD/vYj/9S7LahZb7jVYIsGuPpaw/AZ6GhgUvCqPlD5brA9upCeJPNoRRfMmaCuue5DJmk1SzP++TQW9Jj0Nrau+PDaEJRBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FK26g7xM; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FK26g7xM" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1fc66fc35f2so17230305ad.0; Mon, 29 Jul 2024 02:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722245080; x=1722849880; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q8u/O4Ht4iTO9/a3lv5vZK9Oe8/7dFCMI+nDwx91aig=; b=FK26g7xM+81OXxuZqO3u5GtlurkM0ZAi8XyiISmQmUt3r9+o5zIfc6tRzsVyuGZ4J9 45x6jU5sTUeHhmljWWH8zSd3NaijZtRjvDH9y46xn4n2Ki+U/dTIIEmUtKzIeYnmoz+j T+Ln1aMpTZai0FjrqB9g8Y2stJA0dPt/ID32iVcoX7wJtDINWoaVnW0QqsjWOSOuyP6F 60PrnDikIk9/WkhDUsUFkKm/BIKCGQ4+3VQsxuNVWT23Ra5rnNXi5KRhIanQfhM7IYwQ IGudlJ2HNALKCybwQHAOQvITfrYnsnHXePuUtvhRM0eB3yj0ISWBPPrZ+JZqHm+g2iXc CFTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722245080; x=1722849880; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q8u/O4Ht4iTO9/a3lv5vZK9Oe8/7dFCMI+nDwx91aig=; b=A6fgWmrbLy3ZxPogJyz4UhoLM7A32wQrCgcXjL/api0wgdSgLwwRQv751pDJVzX0Nt 9ehXvD3KHDSb1rrOrqWvTeMiMpA2ZBXNYFlUPF5EQlp7E5oVo4BtYHqzVuvePM+vRiB/ cKkb7zsiyj85xiHafB4JJaSMRTTrfuLnuKpKFMkwXMIEaifUTct05KW6Ya6YalQ7aMBU 8EGFZtudwfjiIjHQ0y+uW5bv3v2dTyS5synwAy3ZdwTAB4E5faTlmqbcotGLPMez4SxS +vzI9nSjhjy4ACOrQBkUwXy0i1fs2hHMrhhppFIQW/NJKN9+q1rUDwN3O8dQKXi+Gatm KB6w== X-Forwarded-Encrypted: i=1; AJvYcCXgIx7HrTwtB3RV0DKuVyGEvmDcc8txesKz7qIaz3AxDsg4azyBf3mXvq1C4hhdPKcqnEhe8Ak2cvTEG0OWvE4vxfwvPpKoPbw9J7FtfObcrDXJCSbVFU25k/FlhYL6OeTGiVkoPkLG X-Gm-Message-State: AOJu0Yx3HJ+7w+C4loOBLKKFwM9Yc/4tOuRnntni4JkooeKIgKZUTMY6 kQc3bcf+drghDknfnsGKvnbCwEY4fZdA0+qQyFHV9HBnziKC5/rVlrEXjzql X-Google-Smtp-Source: AGHT+IElBtnb9CIfRmzOh33uMoXdwdd5Cp0grdAW8W2Yt+zJ9cicqpZdnsTVmNNCgcFzUHdGv03QRg== X-Received: by 2002:a17:903:40cb:b0:1fd:8f7b:1e88 with SMTP id d9443c01a7336-1ff04a4f98cmr95439365ad.12.1722245079478; Mon, 29 Jul 2024 02:24:39 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7c8c19dsm78119145ad.54.2024.07.29.02.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 02:24:39 -0700 (PDT) From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v2 1/8] selftests/bpf: Use portable POSIX basename() Date: Mon, 29 Jul 2024 02:24:17 -0700 Message-Id: <0fd3c9f3c605e6cba33504213c9df287817ade04.1722244708.git.tony.ambardar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the POSIX version of basename() to allow compilation against non-gnu libc (e.g. musl). Include ahead of to enable using functions from the latter while preferring POSIX over GNU basename(). In veristat.c, rely on strdupa() to avoid basename() altering the passed "const char" argument. This is not needed in xskxceiver.c since the arg is mutable and the program exits immediately after usage. Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/veristat.c | 8 +++++--- tools/testing/selftests/bpf/xskxceiver.c | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c index b2854238d4a0..11ec1190d582 100644 --- a/tools/testing/selftests/bpf/veristat.c +++ b/tools/testing/selftests/bpf/veristat.c @@ -2,6 +2,7 @@ /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ #define _GNU_SOURCE #include +#include #include #include #include @@ -988,8 +989,8 @@ static void fixup_obj(struct bpf_object *obj, struct bpf_program *prog, const ch static int process_prog(const char *filename, struct bpf_object *obj, struct bpf_program *prog) { + const char *base_filename = basename(strdupa(filename)); const char *prog_name = bpf_program__name(prog); - const char *base_filename = basename(filename); char *buf; int buf_sz, log_level; struct verif_stats *stats; @@ -1056,13 +1057,14 @@ static int process_prog(const char *filename, struct bpf_object *obj, struct bpf static int process_obj(const char *filename) { + const char *base_filename = basename(strdupa(filename)); struct bpf_object *obj = NULL, *tobj; struct bpf_program *prog, *tprog, *lprog; libbpf_print_fn_t old_libbpf_print_fn; LIBBPF_OPTS(bpf_object_open_opts, opts); int err = 0, prog_cnt = 0; - if (!should_process_file_prog(basename(filename), NULL)) { + if (!should_process_file_prog(base_filename, NULL)) { if (env.verbose) printf("Skipping '%s' due to filters...\n", filename); env.files_skipped++; @@ -1076,7 +1078,7 @@ static int process_obj(const char *filename) } if (!env.quiet && env.out_fmt == RESFMT_TABLE) - printf("Processing '%s'...\n", basename(filename)); + printf("Processing '%s'...\n", base_filename); old_libbpf_print_fn = libbpf_set_print(libbpf_print_fn); obj = bpf_object__open_file(filename, &opts); diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 8144fd145237..92af633faea8 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -90,6 +90,7 @@ #include #include #include +#include #include #include #include