[or-cvs] Fix unit tests (now that platform code works differently)

Nick Mathewson nickm at seul.org
Thu Apr 8 20:22:03 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv18557

Modified Files:
	router.c test.c 
Log Message:
Fix unit tests (now that platform code works differently)

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- router.c	7 Apr 2004 21:36:03 -0000	1.25
+++ router.c	8 Apr 2004 20:22:01 -0000	1.26
@@ -6,7 +6,7 @@
 
 extern or_options_t options; /* command-line and config-file options */
 
-static void get_platform_str(char *platform, int len);
+/* exposed for test.c */ void get_platform_str(char *platform, int len);
 
 /************************************************************/
 
@@ -388,7 +388,7 @@
   return 0;
 }
 
-static void get_platform_str(char *platform, int len)
+void get_platform_str(char *platform, int len)
 {
   snprintf(platform, len-1, "Tor %s on %s", VERSION, get_uname());
   platform[len-1] = '\0';

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- test.c	7 Apr 2004 19:57:39 -0000	1.77
+++ test.c	8 Apr 2004 20:22:01 -0000	1.78
@@ -23,6 +23,7 @@
 int router_get_routerlist_from_directory_impl(
         const char *s, routerlist_t **dest, crypto_pk_env_t *pkey);
 void add_fingerprint_to_dir(const char *nickname, const char *fp);
+void get_platform_str(char *platform, int len);
 
 void
 dump_hex(char *s, int len)
@@ -669,6 +670,7 @@
 test_dir_format()
 {
   char buf[8192], buf2[8192];
+  char platform[256];
   char *pk1_str = NULL, *pk2_str = NULL, *pk3_str = NULL, *cp;
   int pk1_str_len, pk2_str_len, pk3_str_len;
   routerinfo_t r1, r2;
@@ -684,6 +686,8 @@
   test_assert(! crypto_pk_generate_key(pk2));
   test_assert(! crypto_pk_generate_key(pk3));
 
+  get_platform_str(platform, sizeof(platform));
+
   r1.address = "testaddr1.foo.bar";
   r1.addr = 0xc0a80001u; /* 192.168.0.1 */
   r1.published_on = 0;
@@ -696,6 +700,7 @@
   r1.bandwidthrate = r1.bandwidthburst = 1000;
   r1.exit_policy = NULL;
   r1.nickname = "Magri";
+  r1.platform = tor_strdup(platform);
 
   ex1.policy_type = EXIT_POLICY_ACCEPT;
   ex1.string = NULL;



More information about the tor-commits mailing list