public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
@ 2019-07-15 15:16 Xiao Yang
  2019-07-15 16:00 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2019-07-15 15:16 UTC (permalink / raw)
  To: ltp

Don't use hardcoded threshold(default 4%) to check free space
because it can be changed by writing "/proc/sys/kernel/acct"
or using sysctl.

Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
---
 testcases/kernel/syscalls/acct/acct02.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index c2c2066..9e2f934 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -150,18 +150,21 @@ static void run(void)
 static void setup(void)
 {
 	struct statfs buf;
+	float limit;
 
 	clock_ticks = SAFE_SYSCONF(_SC_CLK_TCK);
 
 	SAFE_STATFS(".", &buf);
 
 	float avail = (100.00 * buf.f_bavail) / buf.f_blocks;
+	SAFE_FILE_SCANF("/proc/sys/kernel/acct", "%f %*i %*i", &limit);
+	limit += 0.1;
 
 	/* The accounting data are silently discarded on nearly FS */
-	if (avail < 4.1) {
+	if (avail < limit) {
 		tst_brk(TCONF,
-			"Less than 4.1%% (%.2f) of free space on filesystem",
-			avail);
+			"Less than (%.2f)%% (%.2f) of free space on filesystem",
+			limit, avail);
 	}
 
 	TEST(acct(NULL));
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-16 15:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-15 15:16 [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct Xiao Yang
2019-07-15 16:00 ` Cyril Hrubis
2019-07-16 14:04   ` Xiao Yang
2019-07-16 14:17     ` Cyril Hrubis
2019-07-16 15:37       ` Xiao Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox