git: ca0088ae27a5 - main - stress2: Occasionally modify 8 bits
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 22 May 2023 08:08:43 UTC
The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=ca0088ae27a5154f9279b53b2f7493986167d967 commit ca0088ae27a5154f9279b53b2f7493986167d967 Author: Peter Holm <pho@FreeBSD.org> AuthorDate: 2023-05-22 08:05:34 +0000 Commit: Peter Holm <pho@FreeBSD.org> CommitDate: 2023-05-22 08:05:34 +0000 stress2: Occasionally modify 8 bits --- tools/test/stress2/tools/flip.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/test/stress2/tools/flip.c b/tools/test/stress2/tools/flip.c index a298aebf6d43..e1f12e97a79c 100644 --- a/tools/test/stress2/tools/flip.c +++ b/tools/test/stress2/tools/flip.c @@ -70,6 +70,15 @@ flip(void *ap, size_t len) #endif } +static void +trash(char *c) +{ + if (arc4random() % 2 == 1) + *c = 0; + else + arc4random_buf(c, sizeof(c)); +} + int main(int argc, char *argv[]) { @@ -122,7 +131,10 @@ main(int argc, char *argv[]) err(1, "lseek()"); if (read(fd, &c, 1) != 1) err(1, "read()"); - flip(&c, 1); + if (arc4random() % 100 < 80) + flip(&c, 1); + else + trash(&c); if (lseek(fd, pos, SEEK_SET) == -1) err(1, "lseek()"); if (write(fd, &c, 1) != 1)