From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AED9EC61DC6 for ; Thu, 27 Aug 2026 11:25:56 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 331EE3D2269 for ; Thu, 27 Aug 2026 13:25:55 +0200 (CEST) Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id A95E33D753B for ; Thu, 27 Aug 2026 13:22:18 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 325C6140015F for ; Thu, 27 Aug 2026 13:22:18 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8F2562195D for ; Thu, 27 Aug 2026 11:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1787829733; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0e7r6T19cprtfs9x4C3iYY6Lx7E9MT6YIddv3W7nU/o=; b=COJYwgl6rTF0sVXVcbRrWgFVb2vEwGdQeG/XwN6s63GCRAh/yGZmXdvriqXVEQQezDUMGf S0mGORxkU+gL4R9J9QzuXG6T0vxGyjnyz1/90KJzXMAK+H2F4+8zorV5w3OEnP2k1w2DRJ IZAm2cdmqXHvrEnNUAKIGoNAa3Q9RwM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1787829733; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0e7r6T19cprtfs9x4C3iYY6Lx7E9MT6YIddv3W7nU/o=; b=6zavOd4C1vWgkxJlzzMILvWKBfovND3sAroSeZ8/TyCSxLqisC8AgD95vBpRHz+pv2w9L9 2EhwG9lKM7NSXMCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1787829729; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0e7r6T19cprtfs9x4C3iYY6Lx7E9MT6YIddv3W7nU/o=; b=ZYk2w3KrAkMy+m6Cg6E3QEA3Mx6PwRaFOt4WCXHBqbnvwrF/5Cgyc43MYuvwaRbfaBryfa N4C46KhUaWJ5sAaC9qi3FyeonFukPXOPGKmGG2icxfviRAnw9BFkTvOGBik5qkphqqzu+R 9RNUkANyaakrVqVeE1UPZ2KqTJLTyqw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1787829729; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0e7r6T19cprtfs9x4C3iYY6Lx7E9MT6YIddv3W7nU/o=; b=DTsSZj3hwSHHKInJghcgCSnoG4Zxx/H6vZLLWvxE8I1crW5dpoxsQ7bg2/cBpEOT53RrUe qgbeBalfhYd7m5Bg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4BDAB1361C for ; Thu, 27 Aug 2026 11:22:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id LC6HEeEdkGppawAAD6G6ig (envelope-from ) for ; Thu, 27 Aug 2026 11:22:09 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 27 Aug 2026 13:21:38 +0200 Message-ID: <20260827112157.1748734-13-chrubis@suse.cz> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260827112157.1748734-1-chrubis@suse.cz> References: <20260827112157.1748734-1-chrubis@suse.cz> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.997]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.cz:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_ALL(0.00)[] X-Virus-Scanned: clamav-milter 1.0.9 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v4 12/31] testcases: sysfs: Add sys_ata01 X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" A test for /sys/class/ata_device/*/* files. Signed-off-by: Cyril Hrubis --- include/tst_path_defs.h | 3 + runtest/sysfs | 1 + testcases/kernel/sysfs/class/Makefile | 7 ++ .../kernel/sysfs/class/ata_device/.gitignore | 1 + .../kernel/sysfs/class/ata_device/Makefile | 7 ++ .../kernel/sysfs/class/ata_device/sys_ata01.c | 100 ++++++++++++++++++ 6 files changed, 119 insertions(+) create mode 100644 testcases/kernel/sysfs/class/Makefile create mode 100644 testcases/kernel/sysfs/class/ata_device/.gitignore create mode 100644 testcases/kernel/sysfs/class/ata_device/Makefile create mode 100644 testcases/kernel/sysfs/class/ata_device/sys_ata01.c diff --git a/include/tst_path_defs.h b/include/tst_path_defs.h index 4c25c796a..94c4a65bc 100644 --- a/include/tst_path_defs.h +++ b/include/tst_path_defs.h @@ -92,6 +92,9 @@ #define MEMINFO_HPAGE_SURP "HugePages_Surp:" #define MEMINFO_HPAGE_SIZE "Hugepagesize:" +/* SYSFS CLASS */ +#define PATH_CLASS_ATA_DEVICE "/sys/class/ata_device" + /* SYSFS DEVICES */ #define PATH_SYS_CLOCKEVENTS "/sys/devices/system/clockevents" #define PATH_SYS_CLOCKSOURCE "/sys/devices/system/clocksource" diff --git a/runtest/sysfs b/runtest/sysfs index 3015c03f5..b5e644237 100644 --- a/runtest/sysfs +++ b/runtest/sysfs @@ -8,3 +8,4 @@ sys_cpu_vulnerabilities01 sys_cpu_vulnerabilities01 sys_cpu_smt01 sys_cpu_smt01 sys_cpu_cache01 sys_cpu_cache01 sys_clockevents01 sys_clockevents01 +sys_ata01 sys_ata01 diff --git a/testcases/kernel/sysfs/class/Makefile b/testcases/kernel/sysfs/class/Makefile new file mode 100644 index 000000000..5c8e7a249 --- /dev/null +++ b/testcases/kernel/sysfs/class/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2026 Cyril Hrubis + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/env_pre.mk +include $(top_srcdir)/include/mk/generic_trunk_target.mk diff --git a/testcases/kernel/sysfs/class/ata_device/.gitignore b/testcases/kernel/sysfs/class/ata_device/.gitignore new file mode 100644 index 000000000..b5b1f8f4a --- /dev/null +++ b/testcases/kernel/sysfs/class/ata_device/.gitignore @@ -0,0 +1 @@ +/sys_ata01 diff --git a/testcases/kernel/sysfs/class/ata_device/Makefile b/testcases/kernel/sysfs/class/ata_device/Makefile new file mode 100644 index 000000000..034038061 --- /dev/null +++ b/testcases/kernel/sysfs/class/ata_device/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2026 Cyril Hrubis + +top_srcdir ?= ../../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/sysfs/class/ata_device/sys_ata01.c b/testcases/kernel/sysfs/class/ata_device/sys_ata01.c new file mode 100644 index 000000000..21e58105c --- /dev/null +++ b/testcases/kernel/sysfs/class/ata_device/sys_ata01.c @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2026 Cyril Hrubis + */ + +/*\ + * Sanity checks for the ATA device attributes exported under + * /sys/class/ata_device//. + * + * For every ATA device the test verifies that: + * + * - class is one of the known libata device classes (ata, atapi, pmp, semb, + * unknown, zac, none). none is a legitimate value here, not just a range + * extension for safety: ata_tdev_add() in drivers/ata/libata-transport.c + * creates a transport device object for every possible device slot on a + * link (e.g. both the master/slave slots on a PATA link), regardless of + * whether a physical device is actually attached to it, so an empty slot + * reports class = none rather than not existing at all. + * - dma_mode, pio_mode and xfer_mode, when non-empty, start with the + * ``XFER_`` prefix used by all libata transfer mode names + * - spdn_cnt (speed-down count) is non-negative + * + * dma_mode is legitimately empty for devices that only support PIO, so it is + * only checked when present. + * + * The test skips with TCONF when no ATA device is present. + */ + +#include +#include +#include "tst_test.h" +#include "tst_sysfs_assert.h" +#include "tst_path_defs.h" + +static const char *const class_allowed[] = { + "ata", "atapi", "pmp", "semb", "unknown", "zac", "none", NULL +}; + +static void check_mode(const char *dev, const char *attr) +{ + char mode[32]; + + if (!TST_SYSFS_READ_STR(mode, sizeof(mode), + PATH_CLASS_ATA_DEVICE "/%s/%s", dev, attr)) { + tst_res(TCONF, "%s/%s does not exist", dev, attr); + return; + } + + if (mode[0] == '\0') { + tst_res(TCONF, "%s/%s is empty", dev, attr); + return; + } + + if (!strncmp(mode, "XFER_", 5)) + tst_res(TPASS, "%s/%s = '%s'", dev, attr, mode); + else + tst_res(TFAIL, "%s/%s = '%s' has no XFER_ prefix", + dev, attr, mode); +} + +static void check_device(const char *dev) +{ + tst_res(TINFO, "Checking ata device '%s'", dev); + + TST_SYSFS_ASSERT_ONEOF(class_allowed, PATH_CLASS_ATA_DEVICE "/%s/class", dev); + check_mode(dev, "dma_mode"); + check_mode(dev, "pio_mode"); + check_mode(dev, "xfer_mode"); + + TST_SYSFS_ASSERT_RANGELL(0, LONG_MAX, PATH_CLASS_ATA_DEVICE "/%s/spdn_cnt", dev); +} + +static void do_test(void) +{ + DIR *d; + struct dirent *ent; + int found = 0; + + if (!tst_sysfs_exists(PATH_CLASS_ATA_DEVICE)) + tst_brk(TCONF, PATH_CLASS_ATA_DEVICE ": not present"); + + d = SAFE_OPENDIR(PATH_CLASS_ATA_DEVICE); + + while ((ent = SAFE_READDIR(d))) { + if (ent->d_name[0] == '.') + continue; + + found = 1; + check_device(ent->d_name); + } + + SAFE_CLOSEDIR(d); + + if (!found) + tst_res(TCONF, "No ATA device found"); +} + +static struct tst_test test = { + .test_all = do_test, +}; -- 2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp