Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
ac759adb
Commit
ac759adb
authored
20 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Make unit tests work on win32
svn:r3094
parent
c3c68739
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/or/main.c
+1
-1
1 addition, 1 deletion
src/or/main.c
src/or/or.h
+1
-0
1 addition, 0 deletions
src/or/or.h
src/or/test.c
+38
-2
38 additions, 2 deletions
src/or/test.c
with
40 additions
and
3 deletions
src/or/main.c
+
1
−
1
View file @
ac759adb
...
...
@@ -1011,7 +1011,7 @@ static void dumpstats(int severity) {
/** Called before we make any calls to network-related functions.
* (Some operating systems require their network libraries to be
* initialized.) */
static
int
network_init
(
void
)
int
network_init
(
void
)
{
#ifdef MS_WINDOWS
/* This silly exercise is necessary before windows will allow gethostbyname to work.
...
...
This diff is collapsed.
Click to expand it.
src/or/or.h
+
1
−
0
View file @
ac759adb
...
...
@@ -1387,6 +1387,7 @@ int proxy_mode(or_options_t *options);
void
handle_signals
(
int
is_parent
);
void
tor_cleanup
(
void
);
int
network_init
(
void
);
int
tor_main
(
int
argc
,
char
*
argv
[]);
...
...
This diff is collapsed.
Click to expand it.
src/or/test.c
+
38
−
2
View file @
ac759adb
...
...
@@ -4,6 +4,7 @@
/* $Id$ */
const
char
test_c_id
[]
=
"$Id$"
;
#include
"orconfig.h"
#include
<stdio.h>
#ifdef HAVE_FCNTL_H
#include
<fcntl.h>
...
...
@@ -12,8 +13,10 @@ const char test_c_id[] = "$Id$";
#ifdef MS_WINDOWS
/* For mkdir() */
#include
<direct.h>
#e
ndif
#e
lse
#include
<dirent.h>
#endif
#include
"or.h"
#include
"../common/test.h"
#include
"../common/torgzip.h"
...
...
@@ -34,10 +37,12 @@ setup_directory(void)
int
r
;
if
(
is_setup
)
return
;
tor_snprintf
(
temp_dir
,
sizeof
(
temp_dir
),
"/tmp/tor_test_%d"
,
(
int
)
getpid
());
#ifdef MS_WINDOWS
// XXXX
tor_snprintf
(
temp_dir
,
sizeof
(
temp_dir
),
"c:
\\
windows
\\
temp
\\
tor_test_%d"
,
(
int
)
getpid
());
r
=
mkdir
(
temp_dir
);
#else
tor_snprintf
(
temp_dir
,
sizeof
(
temp_dir
),
"/tmp/tor_test_%d"
,
(
int
)
getpid
());
r
=
mkdir
(
temp_dir
,
0700
);
#endif
if
(
r
)
{
...
...
@@ -60,6 +65,35 @@ get_fname(const char *name)
static
void
remove_directory
(
void
)
{
#ifdef MS_WINDOWS
char
*
pattern
;
HANDLE
handle
;
WIN32_FIND_DATA
findData
;
setup_directory
();
pattern
=
tor_malloc
(
strlen
(
temp_dir
)
+
16
);
tor_snprintf
(
pattern
,
strlen
(
temp_dir
)
+
16
,
"%s
\\
*"
,
temp_dir
);
handle
=
FindFirstFile
(
pattern
,
&
findData
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
{
perror
(
"Can't remove"
);
return
;
}
while
(
1
)
{
size_t
dlen
=
strlen
(
findData
.
cFileName
)
+
strlen
(
temp_dir
)
+
16
;
char
*
deleteable
=
tor_malloc
(
dlen
);
tor_snprintf
(
deleteable
,
dlen
,
"%s
\\
%s"
,
temp_dir
,
findData
.
cFileName
);
unlink
(
deleteable
);
tor_free
(
deleteable
);
if
(
!
FindNextFile
(
handle
,
&
findData
))
{
if
(
GetLastError
()
!=
ERROR_NO_MORE_FILES
)
{
perror
(
"error reading dir"
);
}
break
;
}
}
FindClose
(
handle
);
tor_free
(
pattern
);
#else
DIR
*
dirp
;
struct
dirent
*
de
;
setup_directory
();
...
...
@@ -78,6 +112,7 @@ remove_directory(void)
#endif
}
closedir
(
dirp
);
#endif
rmdir
(
temp_dir
);
}
...
...
@@ -1239,6 +1274,7 @@ test_rend_fns(void)
int
main
(
int
c
,
char
**
v
)
{
or_options_t
*
options
=
tor_malloc_zero
(
sizeof
(
or_options_t
));
network_init
();
options_init
(
options
);
set_options
(
options
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment