summaryrefslogtreecommitdiff
path: root/tests/test_vs_proto2.cc
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-08-30 21:12:17 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-08-30 21:12:17 -0700
commit46fac0f58d169555cd0d53f8acb7fbe83a45a191 (patch)
tree08bad325af3d5c9975b26c87d96fa10153dd43d7 /tests/test_vs_proto2.cc
parentd05eac2890195e0d929263b4a1b28b813bd09e85 (diff)
Tests use valgrind, chdir in test.
Diffstat (limited to 'tests/test_vs_proto2.cc')
-rw-r--r--tests/test_vs_proto2.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_vs_proto2.cc b/tests/test_vs_proto2.cc
index e284100..f1966ef 100644
--- a/tests/test_vs_proto2.cc
+++ b/tests/test_vs_proto2.cc
@@ -172,8 +172,22 @@ void parse_and_compare(MESSAGE_CIDENT *proto2_msg, struct upb_msg *upb_msg,
compare(*proto2_msg, upb_msg);
}
-int main()
+int main(int argc, char *argv[])
{
+ // Change cwd to where the binary is.
+ (void)argc;
+ char *lastslash = strrchr(argv[0], '/');
+ char *progname = argv[0];
+ if(lastslash) {
+ *lastslash = '\0';
+ if(chdir(argv[0]) < 0) {
+ fprintf(stderr, "Error changing directory to %s.\n", argv[0]);
+ return 1;
+ }
+ *lastslash = '/';
+ progname = lastslash + 3; /* "/b_" */
+ }
+
// Initialize upb state, parse descriptor.
struct upb_context *c = upb_context_new();
struct upb_string *fds = upb_strreadfile(MESSAGE_DESCRIPTOR_FILE);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback