Bugzilla – Attachment 3400 Details for
Bug 3171
Error in time conversion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
fix convtime, add unit test
convtime.patch (text/plain), 1.83 KB, created by
Darren Tucker
on 2020-05-28 20:49:54 AEST
(
hide
)
Description:
fix convtime, add unit test
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2020-05-28 20:49:54 AEST
Size:
1.83 KB
patch
obsolete
>Index: usr.bin/ssh/misc.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/misc.c,v >retrieving revision 1.148 >diff -u -p -r1.148 misc.c >--- usr.bin/ssh/misc.c 26 May 2020 01:06:52 -0000 1.148 >+++ usr.bin/ssh/misc.c 28 May 2020 10:44:59 -0000 >@@ -452,7 +452,7 @@ a2tun(const char *s, int *remote) > long > convtime(const char *s) > { >- long total, secs, multiplier = 1; >+ long total, secs, multiplier; > const char *p; > char *endp; > >@@ -470,6 +470,7 @@ convtime(const char *s) > secs < 0) > return -1; > >+ multiplier = 1; > switch (*endp++) { > case '\0': > endp--; >Index: regress/usr.bin/ssh/unittests/misc/tests.c >=================================================================== >RCS file: /cvs/src/regress/usr.bin/ssh/unittests/misc/tests.c,v >retrieving revision 1.1 >diff -u -p -r1.1 tests.c >--- regress/usr.bin/ssh/unittests/misc/tests.c 28 Apr 2019 22:53:26 -0000 1.1 >+++ regress/usr.bin/ssh/unittests/misc/tests.c 28 May 2020 10:44:59 -0000 >@@ -76,4 +76,23 @@ tests(void) > ASSERT_STRING_EQ(path, "some/path"); > free(user); free(host); free(path); > TEST_DONE(); >+ >+ TEST_START("misc_convtime"); >+ ASSERT_LONG_EQ(convtime("1"), 1); >+ ASSERT_LONG_EQ(convtime("2s"), 2); >+ ASSERT_LONG_EQ(convtime("3m"), 180); >+ ASSERT_LONG_EQ(convtime("1m30"), 90); >+ ASSERT_LONG_EQ(convtime("1m30s"), 90); >+ ASSERT_LONG_EQ(convtime("1h1s"), 3601); >+ ASSERT_LONG_EQ(convtime("1h30m"), 90 * 60); >+ ASSERT_LONG_EQ(convtime("1d"), 24 * 60 * 60); >+ ASSERT_LONG_EQ(convtime("1w"), 7 * 24 * 60 * 60); >+ ASSERT_LONG_EQ(convtime("1w2d3h4m5"), 788645); >+ ASSERT_LONG_EQ(convtime("1w2d3h4m5s"), 788645); >+ /* any negative number or error returns -1 */ >+ ASSERT_LONG_EQ(convtime("-1"), -1); >+ ASSERT_LONG_EQ(convtime(""), -1); >+ ASSERT_LONG_EQ(convtime("trout"), -1); >+ ASSERT_LONG_EQ(convtime("-77"), -1); >+ TEST_DONE(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 3171
: 3400