coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interesting use of strace to inject errors for testing


From: Dmitry V. Levin
Subject: Re: interesting use of strace to inject errors for testing
Date: Mon, 12 Jan 2026 11:17:18 +0200

On Sun, Jan 11, 2026 at 06:32:31PM +0000, PƔdraig Brady wrote:
> FYI we've just pushed a new test in the attached that uses
> strace to inject errors for testing, like:
> 
>    $ strace -o /dev/null -P /dev/null -e fault=read:error=EIO \
>      cat /dev/null
>    cat: /dev/null: Input/output error

Since it's not guaranteed that the syscall issued by libc would
necessarily be read (it could be a syscall from readv family instead),
I'd recommend using a wide regexp like /read instead, e.g.

  $ strace -o /dev/null -P /dev/null -e trace=/read -e fault=all:error=EIO \
    cat /dev/null

Also note that since you're not interested in tracing non-read syscalls,
you can explicitly limit the set of syscalls being traced to those you're
going to tamper with, and inject errors into all syscalls being traced,
like in this example, all /read syscalls dealing with /dev/null.


-- 
ldv



reply via email to

[Prev in Thread] Current Thread [Next in Thread]