From: Benjamin Gray <bgray@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Gray <bgray@linux.ibm.com>, ajd@linux.ibm.com
Subject: [PATCH v2 0/7] Expand selftest utils
Date: Wed, 23 Nov 2022 10:10:56 +1100 [thread overview]
Message-ID: <20221122231103.15829-1-bgray@linux.ibm.com> (raw)
(No changes to contents from v1, added signed-off-by's and fixed up commit messages)
Started this when writing tests for a feature I'm working on, needing a way to
read/write numbers to system files. After writing some utils to safely handle
file IO and parsing, I realised I'd made the ~6th file read/write implementation
and only(?) number parser that checks all the failure modes when expecting to
parse a single number from a file.
So these utils ended up becoming this series. I also modified some other test
utils I came across while doing so. My understanding is selftests are not expected
to be backported, so I wasn't concerned about only introducing new utils and leaving
the existing implementations be.
Changes:
- Use the mtfspr/mfspr macros where possible over inline asm
- Fix potential non-null terminated buffer in ptrace tests
- Add read_file / write_file to read and write raw bytes given appropriate
path and buffers. Replace hand rolled read/write with this where easy.
- Make read/write_debugfs_file work on byte buffers and introduce
read/write_debugfs_int for int specific contents. This more naturally aligns
with the read/write_file functions, and allows for future *_long, *_ulong
variants when required.
- Add an error checking number parser. It's an ugly function generating macro.
The issue is the result param type can't be made generic, so there needs to
be a separate definition per type (or at least for signed/unsigned). Also
can't seem to use generics with the variable type declaration, so the max
sized type for the input sign has to be specified manually.
It's at least grep-able and language servers recognise it as defining
parse_int, etc., though.
- Add the read_long, write_long, etc., utils that combine file IO and parsing.
These are the utils I really wanted, useful for system files that are just
numbers.
- Add an allocating file read for when the buffer is potentially too big to
preallocate on the stack or needs to live especially long.
Benjamin Gray (7):
selftests/powerpc: Use mfspr/mtspr macros
selftests/powerpc: Add ptrace setup_core_pattern() null-terminator
selftests/powerpc: Add generic read/write file util
selftests/powerpc: Add read/write debugfs file, int
selftests/powerpc: Parse long/unsigned long value safely
selftests/powerpc: Add {read,write}_{long,ulong}
selftests/powerpc: Add automatically allocating read_file
tools/testing/selftests/powerpc/dscr/dscr.h | 56 +---
.../selftests/powerpc/dscr/dscr_sysfs_test.c | 23 +-
.../testing/selftests/powerpc/include/utils.h | 18 +-
.../selftests/powerpc/nx-gzip/gzfht_test.c | 52 +--
tools/testing/selftests/powerpc/pmu/lib.c | 35 +-
.../selftests/powerpc/ptrace/core-pkey.c | 28 +-
.../selftests/powerpc/ptrace/ptrace-hwbreak.c | 6 +-
.../testing/selftests/powerpc/ptrace/ptrace.h | 5 +-
.../selftests/powerpc/security/entry_flush.c | 12 +-
.../selftests/powerpc/security/flush_utils.c | 3 +-
.../selftests/powerpc/security/rfi_flush.c | 12 +-
.../powerpc/security/uaccess_flush.c | 18 +-
.../selftests/powerpc/syscalls/Makefile | 2 +-
.../selftests/powerpc/syscalls/rtas_filter.c | 80 +----
tools/testing/selftests/powerpc/utils.c | 314 ++++++++++++++----
15 files changed, 341 insertions(+), 323 deletions(-)
base-commit: 247f34f7b80357943234f93f247a1ae6b6c3a740
--
2.38.1
next reply other threads:[~2022-11-22 23:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 23:10 Benjamin Gray [this message]
2022-11-22 23:10 ` [PATCH v2 1/7] selftests/powerpc: Use mfspr/mtspr macros Benjamin Gray
2022-11-25 1:12 ` Andrew Donnellan
2022-11-22 23:10 ` [PATCH v2 2/7] selftests/powerpc: Add ptrace setup_core_pattern() null-terminator Benjamin Gray
2022-11-22 23:10 ` [PATCH v2 3/7] selftests/powerpc: Add generic read/write file util Benjamin Gray
2022-11-22 23:11 ` [PATCH v2 4/7] selftests/powerpc: Add read/write debugfs file, int Benjamin Gray
2022-11-22 23:11 ` [PATCH v2 5/7] selftests/powerpc: Parse long/unsigned long value safely Benjamin Gray
2022-11-22 23:11 ` [PATCH v2 6/7] selftests/powerpc: Add {read,write}_{long,ulong} Benjamin Gray
2022-11-22 23:11 ` [PATCH v2 7/7] selftests/powerpc: Add automatically allocating read_file Benjamin Gray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221122231103.15829-1-bgray@linux.ibm.com \
--to=bgray@linux.ibm.com \
--cc=ajd@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).