Linux Test Project
 help / color / mirror / Atom feed
From: Shirisha G <shirisha@linux.ibm.com>
To: ltp@lists.linux.it
Cc: Shirisha G <shirisha@linux.ibm.com>, geetika@linux.ibm.com
Subject: [LTP] [PATCH v2] Migrating the libhugetlbfs/testcases/truncate.c test
Date: Fri,  8 Sep 2023 16:09:21 +0530	[thread overview]
Message-ID: <20230908103921.511595-1-shirisha@linux.ibm.com> (raw)

Test Description:
Test is used to verify the correct functionality and
compatibility of the library with the "truncate" system
call when operating on files residing in a mounted
huge page filesystem.

Signed-off-by: Shirisha G <shirisha@linux.ibm.com>
---
v2:
 -Corrected typo
---
 runtest/hugetlb                               |  1 +
 testcases/kernel/mem/.gitignore               |  1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap33.c  | 72 +++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c

diff --git a/runtest/hugetlb b/runtest/hugetlb
index 299c07ac9..1300e80fb 100644
--- a/runtest/hugetlb
+++ b/runtest/hugetlb
@@ -35,6 +35,7 @@ hugemmap29 hugemmap29
 hugemmap30 hugemmap30
 hugemmap31 hugemmap31
 hugemmap32 hugemmap32
+hugemmap33 hugemmap33
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
diff --git a/testcases/kernel/mem/.gitignore b/testcases/kernel/mem/.gitignore
index 7258489ed..d130d4dcd 100644
--- a/testcases/kernel/mem/.gitignore
+++ b/testcases/kernel/mem/.gitignore
@@ -34,6 +34,7 @@
 /hugetlb/hugemmap/hugemmap30
 /hugetlb/hugemmap/hugemmap31
 /hugetlb/hugemmap/hugemmap32
+/hugetlb/hugemmap/hugemmap33
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c
new file mode 100644
index 000000000..a4a071b53
--- /dev/null
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2005-2006 IBM Corporation.
+ * Author: David Gibson & Adam Litke
+ */
+
+/*\
+ * [Description]
+ *
+ * Test Name: truncate
+ *
+ * Test case is used to verify the correct functionality
+ * and compatibility of the library with the "truncate" system call when
+ * operating on files residing in a mounted huge page filesystem.
+ */
+
+#include "hugetlb.h"
+
+#define RANDOM_CONSTANT	0x1234ABCD
+#define MNTPOINT "hugetlbfs/"
+long hpage_size;
+int fd;
+
+
+
+static void sigbus_handler(int signum LTP_ATTRIBUTE_UNUSED)
+{
+	tst_res(TPASS, "Test Passed");
+	exit(0);
+}
+
+static void run_test(void)
+{
+	void *p;
+	volatile unsigned int *q;
+	struct sigaction my_sigaction;
+	my_sigaction.sa_handler = sigbus_handler;
+	p = SAFE_MMAP(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_SHARED,
+			fd, 0);
+	if (p == MAP_FAILED)
+		tst_res(TFAIL, "mmap failed..!!");
+	q = p;
+	*q = 0;
+	SAFE_SIGACTION(SIGBUS, &my_sigaction, NULL);
+	SAFE_FTRUNCATE(fd, 0);
+	*q;
+        tst_res(TFAIL, "Didn't SIGBUS");
+}
+
+
+void setup(void)
+{
+	hpage_size = tst_get_hugepage_size();
+    	fd = tst_creat_unlinked(MNTPOINT, 0);
+}
+
+void cleanup(void)
+{
+    	if (fd > 0)
+	    SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.mntpoint = MNTPOINT,
+	.needs_hugetlbfs = 1,
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run_test,
+	.hugepages = {1, TST_NEEDS},
+};
-- 
2.39.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2023-09-08 11:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 10:39 Shirisha G [this message]
2023-09-08 12:15 ` [LTP] [PATCH v2] Migrating the libhugetlbfs/testcases/truncate.c test Cyril Hrubis
2023-09-29  8:50   ` Shirisha ganta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230908103921.511595-1-shirisha@linux.ibm.com \
    --to=shirisha@linux.ibm.com \
    --cc=geetika@linux.ibm.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox