lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFr9PX=W6QNzma0aewFLFj_y4wo=C8nb-G2FxhT8mjOTRzVofg@mail.gmail.com>
Date: Sun, 4 Jan 2026 20:12:11 +0900
From: Daniel Palmer <daniel@...ngy.jp>
To: Thomas Weißschuh <linux@...ssschuh.net>
Cc: w@....eu, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 0/2] nolibc: Add fread() and fseek()

Hi Thomas,

On Sun, 4 Jan 2026 at 18:11, Thomas Weißschuh <linux@...ssschuh.net> wrote:
> Please also do add some tests.

Would a single function test that exercises the new functions be
enough? Something like this:

--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -877,6 +877,45 @@ int test_file_stream(void)
       return 0;
}

+int test_file_stream_wsr(void)
+{
+       const char dataout[] = "foo";
+       const size_t datasz = sizeof(dataout);
+       char datain[datasz];
+       FILE *f;
+       int r;
+
+       f = fopen("/tmp/file_stream_test", "w+");
+       if (!f)
+               return -1;
+
+       r = fwrite(dataout, 1, datasz, f);
+       if (r != datasz)
+               goto fail;
+
+       r = fseek(f, 0, SEEK_SET);
+       if (r)
+               goto fail;
+
+       r = fread(datain, 1, datasz, f);
+       if (r != datasz)
+               goto fail;
+
+       if (memcmp(datain, dataout, datasz) != 0)
+               goto fail;
+
+       r = fclose(f);
+       if (r == EOF)
+               return -1;
+
+       return 0;
+
+fail:
+       fclose(f);
+       return -1;
+}
+

Cheers,

Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ