Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/stdlib Fix testing of returned entptr, and fi...



details:   https://anonhg.NetBSD.org/src/rev/38786880781c
branches:  trunk
changeset: 345552:38786880781c
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Jun 01 01:12:02 2016 +0000

description:
Fix testing of returned entptr, and fix three affected tests.

>From kamil@ via PR lib/49632

diffstat:

 tests/lib/libc/stdlib/t_strtol.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r 0c90b67383d8 -r 38786880781c tests/lib/libc/stdlib/t_strtol.c
--- a/tests/lib/libc/stdlib/t_strtol.c  Wed Jun 01 00:54:20 2016 +0000
+++ b/tests/lib/libc/stdlib/t_strtol.c  Wed Jun 01 01:12:02 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp $ */
+/*     $NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp $");
+__RCSID("$NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $");
 
 #include <atf-c.h>
 #include <errno.h>
@@ -59,7 +59,8 @@
                atf_tc_fail_nonfatal("strtoll(%s, NULL, %d) failed "
                    "(rv = %lld)", t->str, t->base, lli);
 
-       if (t->end != NULL && strcmp(t->end, end) != 0)
+       if ((t->end != NULL && strcmp(t->end, end) != 0) ||
+           (t->end == NULL && *end != '\0'))
                atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
                    "strtol(%s, &end, %d)", end, t->str, t->base);
 }
@@ -89,8 +90,8 @@
                { "12579781",                    123456789, 14, NULL    },
                { "AC89BC9",                     123456789, 15, NULL    },
                { "75BCD15",                     123456789, 16, NULL    },
-               { "123456789",                      342391,  8, NULL    },
-               { "0123456789",                     342391,  0, NULL    },
+               { "1234567",                        342391,  8, NULL    },
+               { "01234567",                       342391,  0, NULL    },
                { "0123456789",                  123456789, 10, NULL    },
                { "0x75bcd15",                   123456789,  0, NULL    },
        };
@@ -121,7 +122,7 @@
                { "abcd",       0xabcd, 16, NULL        },
                { "     dcba",  0xdcba, 16, NULL        },
                { "abcd dcba",  0xabcd, 16, " dcba"     },
-               { "abc0x123",   0xabc0, 16, NULL        },
+               { "abc0x123",   0xabc0, 16, "x123"      },
                { "abcd\0x123", 0xabcd, 16, "\0x123"    },
                { "ABCD",       0xabcd, 16, NULL        },
                { "aBcD",       0xabcd, 16, NULL        },



Home | Main Index | Thread Index | Old Index