Skip to contentSkip to conversation

Fix sbrk02 failure on ia32 architecture

PATCH New charishma 2 participants 2 messages Mar 24, 2017

lore
Share & tools
lore

charishma

author
#0 lore raw

PATCH 1/1 Fix sbrk02 failure on ia32 architecture

sbrk02 is failing on ia32 architecture, where as this test passed in other arch's.

when we check the sbrk02 with below increment value #define INC 16*1024*1024 the error
condition "(void *) -1" met but the errno show the success. below
output will
show fail condition.

value of increment:: 369098752 return value 0xdb63f000

errno:: 0sbrk02 0 TINFO : setup() bailing inc: 385875968, ret:
0xffffffff, sbrk: 0xf063f000:

errno=SUCCESS(0): Success
sbrk_verify:: 385875968
sbrk02 1 TFAIL : sbrk02.c:110: sbrk(385875968) failed unexpectedly;
expected: 12 - Cannot allocate memory: TEST_ERRNO=SUCCESS(0): Success

Solution Details:
Since it was failing when the loop check for return value but error condition doesn't met 0, So added the loop to check the reverse condition ie errno == 0.

Signed-off-by  :  Anup Kumar <[email protected]>
Signed-off-by  :  Charishma M <[email protected]>
---
  testcases/kernel/syscalls/sbrk/sbrk02.c | 12 +++++++++++-
  1 file changed, 11 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/testcases/kernel/syscalls/sbrk/sbrk02.c
index 84744ef..60ade4b 100644

testcases/kernel/syscalls/sbrk/sbrk02.c +11 -1
@@ -21,6 +21,7 @@
 
  #include <errno.h>
  #include <unistd.h>
+#include <sys/types.h>
  #include "test.h"
 
  #define INC 16*1024*1024
@@ -55,13 +56,21 @@ int main(int argc, char *argv[])
 
  static void setup(void)
  {
-    void *ret = NULL;
 
      tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
      TEST_PAUSE;
 
      /* call sbrk until it fails or increment overflows */
+
+#if defined(__i386__)
+
+        for (increment = INC; errno == 0; increment++)
+        sbrk(increment);
+        tst_resm(TINFO | TERRNO, "setup() bailing inc: %ld, sbrk: %p",
+                increment, sbrk(0));
+#else
+    void *ret = NULL;
      while (ret != (void *)-1 && increment > 0) {
          ret = sbrk(increment);
          increment += INC;
@@ -70,6 +79,7 @@ static void setup(void)
          increment, ret, sbrk(0));
 
      errno = 0;
+#endif
  }
 
  static void sbrk_verify(void)
Signature · 5 lines
2.5.5

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20170324/b714d68d/attachment.html>
#1 lore raw

PATCH 1/1 Fix sbrk02 failure on ia32 architecture

Hi!

Quoted 8 lines

sbrk02 is failing on ia32 architecture, where as this test passed in other arch's.

when we check the sbrk02 with below increment value #define INC 16*1024*1024 the error
condition "(void *) -1" met but the errno show the success. below
output will
show fail condition.

This is most likely this glibc bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=18592

Fixed by this patch:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=c13e07830800dd95ca7684b3c473394c77059c97

Signature · 2 lines
Cyril Hrubis
[email protected]