An usable unaligned addr various on different platforms, it's better to
generate the addr dynamically instead of using a hard-coded one. This
patch generate this unaligned addr based on first run.

Signed-off-by: Caspar Zhang <[email protected]>
---
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat01.c     |   29 ++++++++++---------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
index e46ae12..54d8aeb 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
@@ -66,16 +66,6 @@ int TST_TOTAL = 3;
 #define CASE0		10		/* values to write into the shared */
 #define CASE1		20		/* memory location.		   */
 
-#if __WORDSIZE == 64
-#if defined(__mips__)
-#define UNALIGNED      0x1000000eee
-#else
-#define UNALIGNED      0x10000000eee
-#endif
-#else
-#define UNALIGNED      0x60000eee
-#endif
-
 static size_t shm_size;
 static int    shm_id_1 = -1;
 static void   *addr;
@@ -92,13 +82,16 @@ struct test_case_t {
 	int  flags;
 } TC[] = {
 	/* a straight forward read/write attach */
-	{ &shm_id_1,	0,			0 },
+	{ &shm_id_1,	0,		0 },
 
-	/* an attach using non aligned memory */
-	{ &shm_id_1,	(void *)UNALIGNED,	SHM_RND },
+	/*
+	 * an attach using non aligned memory
+	 * -1 will be replaced with an unaligned addr
+	 */
+	{ &shm_id_1,	(void *)-1,	SHM_RND },
 
 	/* a read only attach */
-	{ &shm_id_1,	0,			SHM_RDONLY }
+	{ &shm_id_1,	0,		SHM_RDONLY }
 };
 
 static void check_functionality(int i);
@@ -130,6 +123,14 @@ int main(int ac, char **av)
 					tst_resm(TPASS, "shmat call succeeded");
 			}
 
+			/*
+			 * addr in TC[0] will be used to generate an unaligned
+			 * address for TC[1]
+			 */
+			if (i == 0 && addr != (void *)-1)
+				TC[i+1].addr = (void *)((unsigned long)addr/
+					    SHMLBA*SHMLBA) + SHMLBA -1;
+
 			if (shmdt(addr) == -1)
 				tst_brkm(TBROK|TERRNO, cleanup, "shmdt");
 		}
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to