diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-12-21 12:14:20 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-12-21 12:14:20 +0200 |
commit | 9cc19a5e998d93fbe6d7a7c18fba1e37a36076d5 (patch) | |
tree | 6fb10fa8670dc3197a2effb2fbe71a8550a6afac /tests/site_scons | |
parent | eff9e11150c0bfb6baf5d6bec2351034b72d95ed (diff) |
Modify the alltypes test to check re-encoding through protoc.
This way we can verify that the message is encoded exactly the same way
as the official protobuf implementation would do it.
Diffstat (limited to 'tests/site_scons')
-rw-r--r-- | tests/site_scons/site_init.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/site_scons/site_init.py b/tests/site_scons/site_init.py index 1f811153..38aa1a44 100644 --- a/tests/site_scons/site_init.py +++ b/tests/site_scons/site_init.py @@ -55,7 +55,11 @@ def add_nanopb_builders(env): else: infile = None - pipe = subprocess.Popen(str(source[0]), + args = [str(source[0])] + if env.has_key('ARGS'): + args.extend(env['ARGS']) + + pipe = subprocess.Popen(args, stdin = infile, stdout = open(str(target[0]), 'w'), stderr = sys.stderr) @@ -81,6 +85,17 @@ def add_nanopb_builders(env): suffix = '.decoded') env.Append(BUILDERS = {'Decode': decode_builder}) + # Build command that encodes a message using protoc + def encode_actions(source, target, env, for_signature): + esc = env['ESCAPE'] + dirs = ' '.join(['-I' + esc(env.GetBuildPath(d)) for d in env['PROTOCPATH']]) + return '$PROTOC $PROTOCFLAGS %s --encode=%s %s <%s >%s' % ( + dirs, env['MESSAGE'], esc(str(source[1])), esc(str(source[0])), esc(str(target[0]))) + + encode_builder = Builder(generator = encode_actions, + suffix = '.encoded') + env.Append(BUILDERS = {'Encode': encode_builder}) + # Build command that asserts that two files be equal def compare_files(target, source, env): data1 = open(str(source[0]), 'rb').read() |