Displaying 10 results from an estimated 10 matches for "test_nbdkit_parse_size".
2019 Feb 08
2
[PATCH nbdkit v2] server: utils: Make nbdkit_parse_size to reject negative values
...st-utils.c | 28 ++++++++++++++++++++++++----
server/utils.c | 19 ++++++++++++++-----
2 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/server/test-utils.c b/server/test-utils.c
index f51f63a..3965fd3 100644
--- a/server/test-utils.c
+++ b/server/test-utils.c
@@ -62,14 +62,26 @@ test_nbdkit_parse_size (void)
{ "0x0", -1 },
{ "garbage", -1 },
{ "0garbage", -1 },
- { "-1", -1 },
- { "-2", -1 },
- { "9223372036854775808", -1 },
- { "-9223372036854775808", -1 },
{ "8E", -1 },
{ "...
2019 Feb 07
1
[PATCH nbdkit] server: utils: Fix nbdkit_parse_size to correctly handle negative values
...st-utils.c | 28 ++++++++++++++++++++++++----
server/utils.c | 19 ++++++++++++++-----
2 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/server/test-utils.c b/server/test-utils.c
index f51f63a..3965fd3 100644
--- a/server/test-utils.c
+++ b/server/test-utils.c
@@ -62,14 +62,26 @@ test_nbdkit_parse_size (void)
{ "0x0", -1 },
{ "garbage", -1 },
{ "0garbage", -1 },
- { "-1", -1 },
- { "-2", -1 },
- { "9223372036854775808", -1 },
- { "-9223372036854775808", -1 },
{ "8E", -1 },
{ "...
2018 Feb 07
3
[nbdkit PATCH v2 0/2] Improve nbdkit_parse_size
Take two, this time split into two patches. I liked Rich's
suggestion of unit-testing src/ files directly in src/, and
automake is a lot happier with this than with my v1 attempt
that tried to compile .c files across directories.
It's still enough of a change that I'm not pushing it right
away.
Eric Blake (2):
build: Add unit-testing of internal files
utils: Revamp
2018 Feb 02
0
[RFC nbdkit PATCH] utils: Revamp nbdkit_parse_size
...>
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <stdbool.h>
+
+#include <nbdkit-plugin.h>
+
+static bool error_flagged;
+
+/* Stub for linking against minimal source files */
+void
+nbdkit_error (const char *fs, ...)
+{
+ error_flagged = true;
+}
+
+static bool
+test_nbdkit_parse_size (void)
+{
+ bool pass = true;
+ struct pair {
+ const char *str;
+ int64_t res;
+ } pairs[] = {
+ /* Bogus strings */
+ { "", -1 },
+ { "0x0", -1 },
+ { "garbage", -1 },
+ { "0garbage", -1 },
+ { "M", -1 },
+ { "-1...
2018 Feb 07
0
[nbdkit PATCH v2 2/2] utils: Revamp nbdkit_parse_size
...s.c | 20 ++++++------
src/utils.c | 95 ++++++++++++++++++++++++++++++++++++--------------------
2 files changed, 72 insertions(+), 43 deletions(-)
diff --git a/src/test-utils.c b/src/test-utils.c
index e26a6f3..80bef2e 100644
--- a/src/test-utils.c
+++ b/src/test-utils.c
@@ -61,19 +61,19 @@ test_nbdkit_parse_size (void)
{ "", -1 },
{ "0x0", -1 },
{ "garbage", -1 },
- /* { "0garbage", -1 }, */
- /* { "-1", -1 }, */
- /* { "-2", -1 }, */
- /* { "9223372036854775808", -1 }, */
- /* { "-9223372036854775808&q...
2019 Sep 23
0
Re: [PATCH nbdkit v2] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...>
> -#include <inttypes.h>
> +#include <stdlib.h>
> #include <stdbool.h>
> +#include <stdint.h>
> +#include <inttypes.h>
> +#include <limits.h>
> #include <string.h>
> #include <unistd.h>
>
> @@ -153,6 +156,180 @@ test_nbdkit_parse_size (void)
> return pass;
> }
>
> +static bool
> +test_nbdkit_parse_ints (void)
> +{
> + bool pass = true;
> +
> +#define PARSE(...) PARSE_(__VA_ARGS__)
> +#define PARSE_(TYPE, FORMAT, TEST, RET, EXPECTED) \
> + do {...
2019 Sep 23
2
[PATCH nbdkit v2] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...#include <config.h>
#include <stdio.h>
-#include <inttypes.h>
+#include <stdlib.h>
#include <stdbool.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <limits.h>
#include <string.h>
#include <unistd.h>
@@ -153,6 +156,180 @@ test_nbdkit_parse_size (void)
return pass;
}
+static bool
+test_nbdkit_parse_ints (void)
+{
+ bool pass = true;
+
+#define PARSE(...) PARSE_(__VA_ARGS__)
+#define PARSE_(TYPE, FORMAT, TEST, RET, EXPECTED) \
+ do { \
+ error...
2019 Jul 31
13
[nbdkit PATCH 0/8] fd leak safety
There's enough here to need a review; some of it probably needs
backporting to stable-1.12.
This probably breaks tests on Haiku or other platforms that have not
been as on-the-ball about atomic CLOEXEC; feel free to report issues
that arise, and I'll help come up with workarounds (even if we end up
leaving a rare fd leak on less-capable systems).
Meanwhile, I'm still working on my
2019 Sep 23
2
Re: [PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
On Mon, Sep 23, 2019 at 12:05:11PM -0500, Eric Blake wrote:
> > + int nbdkit_parse_long (const char *what, const char *str, long *r);
> > + int nbdkit_parse_unsigned_long (const char *what,
> > + const char *str, unsigned long *r);
>
> Do we really want to encourage the use of parse_long and
> parse_unsigned_long? Those differ between
2019 Sep 21
2
[PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...de <inttypes.h>
+#include <stdlib.h>
#include <stdbool.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <limits.h>
#include <string.h>
#include <unistd.h>
+#include <assert.h>
#include "internal.h"
@@ -153,6 +157,180 @@ test_nbdkit_parse_size (void)
return pass;
}
+static bool
+test_nbdkit_parse_ints (void)
+{
+ bool pass = true;
+ char s[64];
+
+#define PARSE(TYPE, FORMAT, TEST, RET, EXPECTED) \
+ do { \
+ error_flagged = false;...