public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/4] lib: Add tst_kernel_bits()
@ 2017-01-12 13:23 Cyril Hrubis
  2017-01-12 13:23 ` [LTP] [PATCH 2/4] vma03: Disable the test on 64bit kernel as well Cyril Hrubis
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Cyril Hrubis @ 2017-01-12 13:23 UTC (permalink / raw)
  To: ltp

This function returns 32 or 64 depending on if we are running on 32bit
or 64bit kernel. This is detected from uname.machine string which seems
to be good enough heuristic and even if that fails we can always add a
special cases to the tst_kernel_bits() function.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/tst_kernel.h | 26 ++++++++++++++++++++++++++
 include/tst_test.h   |  1 +
 lib/tst_kernel.c     | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)
 create mode 100644 include/tst_kernel.h
 create mode 100644 lib/tst_kernel.c

diff --git a/include/tst_kernel.h b/include/tst_kernel.h
new file mode 100644
index 0000000..5d5c04c
--- /dev/null
+++ b/include/tst_kernel.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TST_KERNEL_H__
+#define TST_KERNEL_H__
+
+/*
+ * Returns 32 if we are running on 32bit kernel and 64 if on 64bit kernel.
+ */
+int tst_kernel_bits(void);
+
+#endif	/* TST_KERNEL_H__ */
diff --git a/include/tst_test.h b/include/tst_test.h
index 1492ff5..7ff33b2 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -33,6 +33,7 @@
 #include "tst_atomic.h"
 #include "tst_kvercmp.h"
 #include "tst_clone.h"
+#include "tst_kernel.h"
 
 /*
  * Reports testcase result.
diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
new file mode 100644
index 0000000..7a53002
--- /dev/null
+++ b/lib/tst_kernel.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/utsname.h>
+#include "test.h"
+#include "tst_kernel.h"
+
+int tst_kernel_bits(void)
+{
+	struct utsname buf;
+	int kernel_bits;
+
+	if (uname(&buf))
+		tst_brkm(TBROK | TERRNO, NULL, "uname()");
+
+	kernel_bits = strstr(buf.machine, "64") ? 64 : 32;
+
+	tst_resm(TINFO, "uname.machine=%s kernel is %ibit",
+	         buf.machine, kernel_bits);
+
+	return kernel_bits;
+}
-- 
2.7.3


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

end of thread, other threads:[~2017-01-12 17:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-12 13:23 [LTP] [PATCH 1/4] lib: Add tst_kernel_bits() Cyril Hrubis
2017-01-12 13:23 ` [LTP] [PATCH 2/4] vma03: Disable the test on 64bit kernel as well Cyril Hrubis
2017-01-12 13:23 ` [LTP] [PATCH 3/4] mmapstress03: Small cleanup Cyril Hrubis
2017-01-12 13:23 ` [LTP] [PATCH 4/4] mmapstress03: Fix 32bit test on 64bit kernel Cyril Hrubis
2017-01-12 14:41   ` Jan Stancek
2017-01-12 15:05     ` Cyril Hrubis
2017-01-12 16:41       ` Jan Stancek
2017-01-12 17:00         ` Cyril Hrubis
2017-01-12 17:00         ` Jan Stancek
2017-01-12 14:40 ` [LTP] [PATCH 1/4] lib: Add tst_kernel_bits() Jan Stancek
2017-01-12 14:45   ` Cyril Hrubis

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