From 0440749562b0a7aae0055c4441985be4869403c8 Mon Sep 17 00:00:00 2001 From: florian <florian@freepascal.org> Date: Sun, 28 Aug 2022 21:01:09 +0200 Subject: [PATCH] + test for #39873 --- tests/webtbs/tw39873.pp | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/webtbs/tw39873.pp diff --git a/tests/webtbs/tw39873.pp b/tests/webtbs/tw39873.pp new file mode 100644 index 0000000000..4c47cd4325 --- /dev/null +++ b/tests/webtbs/tw39873.pp @@ -0,0 +1,47 @@ +{ %TARGET=darwin } + +{$mode objfpc}{$H+} +{$packrecords c} + +uses + Classes, SysUtils, UnixType; + + +{$IF DEFINED(DARWIN)} +function getfsstat(buf: pstatfs; bufsize: cint; flags: cint): cint; cdecl; external 'c' name 'getfsstat'; +{$ELSE} +function getfsstat(struct_statfs: PStatFS; const buffsize: int64; const int_flags: integer): integer; +{$ENDIF} + +const + MAX_FS = 128; + MNT_WAIT = 1; // synchronously wait for I/O to complete + MNT_NOWAIT = 2; // start all I/O, but do not wait for it + MNT_LAZY = 3; // push data not written by filesystem syncer + MNT_SUSPEND = 4; // suspend file system after sync + +procedure AssertTrue(const s : string;b : boolean); +begin + if not(b) then + begin + writeln(s); + halt(1); + end; +end; + +var + fs: tstatfs; + fsList: array[0..MAX_FS] of tstatfs; + count: integer; + i: integer; +begin + count := getfsstat( @fsList, SizeOf(fsList), MNT_WAIT ); + for i := 0 to count - 1 do + begin + fs := fsList[i]; + AssertTrue( 'tstatfs.fstypename error' , fs.fstypename[0] <> char(0) ); + AssertTrue( 'tstatfs.mountpoint error' , fs.mountpoint[0] <> char(0) ); + AssertTrue( 'tstatfs.mntfromname error' , fs.mntfromname[0] <> char(0) ); + WriteLn( IntToStr(i) + ':' + fs.fstypename + ''#9'' + fs.mountpoint + ''#9'' + fs.mntfromname ); + end; +end.