From d395768c8d3e63125c15950434fa255fb8c57717 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Wed, 11 Sep 2013 13:42:56 +0300 Subject: [PATCH] Windows build fixes --- tests/alltypes/decode_alltypes.c | 11 ++++++++--- tests/alltypes/encode_alltypes.c | 2 ++ tests/callbacks/decode_callbacks.c | 2 +- tests/extensions/SConscript | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/alltypes/decode_alltypes.c b/tests/alltypes/decode_alltypes.c index 55d025c..ee2e115 100644 --- a/tests/alltypes/decode_alltypes.c +++ b/tests/alltypes/decode_alltypes.c @@ -8,6 +8,7 @@ #include #include #include "alltypes.pb.h" +#include "test_helpers.h" #define TEST(x) if (!(x)) { \ printf("Test " #x " failed.\n"); \ @@ -176,15 +177,19 @@ bool check_alltypes(pb_istream_t *stream, int mode) int main(int argc, char **argv) { + uint8_t buffer[1024]; + size_t count; + pb_istream_t stream; + /* Whether to expect the optional values or the default values. */ int mode = (argc > 1) ? atoi(argv[1]) : 0; /* Read the data into buffer */ - uint8_t buffer[1024]; - size_t count = fread(buffer, 1, sizeof(buffer), stdin); + SET_BINARY_MODE(stdin); + count = fread(buffer, 1, sizeof(buffer), stdin); /* Construct a pb_istream_t for reading from the buffer */ - pb_istream_t stream = pb_istream_from_buffer(buffer, count); + stream = pb_istream_from_buffer(buffer, count); /* Decode and print out the stuff */ if (!check_alltypes(&stream, mode)) diff --git a/tests/alltypes/encode_alltypes.c b/tests/alltypes/encode_alltypes.c index 802e157..88fc10f 100644 --- a/tests/alltypes/encode_alltypes.c +++ b/tests/alltypes/encode_alltypes.c @@ -6,6 +6,7 @@ #include #include #include "alltypes.pb.h" +#include "test_helpers.h" int main(int argc, char **argv) { @@ -120,6 +121,7 @@ int main(int argc, char **argv) /* Now encode it and check if we succeeded. */ if (pb_encode(&stream, AllTypes_fields, &alltypes)) { + SET_BINARY_MODE(stdout); fwrite(buffer, 1, stream.bytes_written, stdout); return 0; /* Success */ } diff --git a/tests/callbacks/decode_callbacks.c b/tests/callbacks/decode_callbacks.c index c8daed2..45724d0 100644 --- a/tests/callbacks/decode_callbacks.c +++ b/tests/callbacks/decode_callbacks.c @@ -86,7 +86,7 @@ int main() testmessage.fixed32value.funcs.decode = &print_fixed32; testmessage.fixed32value.arg = "fixed32value: %ld\n"; testmessage.fixed64value.funcs.decode = &print_fixed64; - testmessage.fixed64value.arg = "fixed64value: %lld\n"; + testmessage.fixed64value.arg = "fixed64value: %ld\n"; testmessage.repeatedstring.funcs.decode = &print_string; testmessage.repeatedstring.arg = "repeatedstring: \"%s\"\n"; diff --git a/tests/extensions/SConscript b/tests/extensions/SConscript index b48d6a6..f632a9a 100644 --- a/tests/extensions/SConscript +++ b/tests/extensions/SConscript @@ -8,8 +8,8 @@ incpath.Append(PROTOCPATH = '#alltypes') incpath.Append(CPPPATH = '#alltypes') incpath.NanopbProto("extensions") -enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb.o", "#common/pb_encode.o"]) -dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb.o", "#common/pb_decode.o"]) +enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_encode.o"]) +dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_decode.o"]) env.RunTest(enc) env.RunTest([dec, "encode_extensions.output"]) -- 2.16.6