Skip to content

Commit 751ddf1

Browse files
committed
Verify that tor bootstrapped correctly and tgen streams completed
1 parent ed4c21d commit 751ddf1

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/test/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ endmacro()
4545
## example: add_shadow_tests(BASENAME bind METHODS ptrace preload LOGLEVEL debug ARGS --pin-cpus)
4646
## will create two tests named bind-shadow-ptrace and bind-shadow-preload
4747
macro(add_shadow_tests)
48-
cmake_parse_arguments(SHADOW_TEST "" "BASENAME;LOGLEVEL;SHADOW_CONFIG;CHECK_RETVAL" "METHODS;ARGS;CONFIGURATIONS;PROPERTIES" ${ARGN})
48+
cmake_parse_arguments(SHADOW_TEST "" "BASENAME;LOGLEVEL;SHADOW_CONFIG;CHECK_RETVAL;POST_CMD" "METHODS;ARGS;CONFIGURATIONS;PROPERTIES" ${ARGN})
4949

5050
if(NOT DEFINED SHADOW_TEST_LOGLEVEL)
5151
set(SHADOW_TEST_LOGLEVEL "debug")
@@ -58,6 +58,10 @@ macro(add_shadow_tests)
5858
if(NOT DEFINED SHADOW_TEST_CHECK_RETVAL)
5959
set(SHADOW_TEST_CHECK_RETVAL TRUE)
6060
endif()
61+
62+
if(NOT DEFINED SHADOW_TEST_POST_CMD)
63+
set(SHADOW_TEST_POST_CMD "true")
64+
endif()
6165

6266
string(REPLACE ";" " " SHADOW_TEST_ARGS "${SHADOW_TEST_ARGS}")
6367

@@ -72,6 +76,7 @@ macro(add_shadow_tests)
7276
--log-level=${SHADOW_TEST_LOGLEVEL} \
7377
${SHADOW_TEST_ARGS} \
7478
- \
79+
&& (${SHADOW_TEST_POST_CMD}) \
7580
"
7681
)
7782

src/test/tor/minimal/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_custom_target(tor-minimal-shadow-conf ALL
22
COMMAND ${CMAKE_COMMAND}
33
-E copy_directory
4-
${CMAKE_SOURCE_DIR}/src/test/tor/minimal/conf
4+
${CMAKE_CURRENT_SOURCE_DIR}/conf
55
${CMAKE_CURRENT_BINARY_DIR}/conf
66
# older tor versions don't support the AuthDirTestReachability torrc option,
77
# so comment out those lines if not supported
@@ -14,7 +14,7 @@ add_custom_target(tor-minimal-shadow-conf ALL
1414
add_custom_target(tor-minimal-shadow-data-template ALL
1515
COMMAND ${CMAKE_COMMAND}
1616
-E copy_directory
17-
${CMAKE_SOURCE_DIR}/src/test/tor/minimal/shadow.data.template
17+
${CMAKE_CURRENT_SOURCE_DIR}/shadow.data.template
1818
${CMAKE_CURRENT_BINARY_DIR}/shadow.data.template
1919
COMMAND chmod
2020
0700
@@ -30,6 +30,7 @@ add_shadow_tests(BASENAME tor-minimal
3030
--pin-cpus
3131
--workers 2
3232
--data-template "shadow.data.template"
33+
POST_CMD "${CMAKE_CURRENT_SOURCE_DIR}/verify.sh"
3334
PROPERTIES
3435
TIMEOUT 180
3536
LABELS tor

src/test/tor/minimal/verify.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
bootstrapped_count="$(grep -r --include="*.tor.*.stdout" "Bootstrapped 100" | wc -l)"
4+
echo "Bootstrapped count: ${bootstrapped_count}"
5+
6+
if [ "${bootstrapped_count}" != "9" ]; then
7+
echo "Not all tor processes bootstrapped"
8+
exit 1
9+
fi
10+
11+
stream_count="$(grep -r --include="*.tgen.*.stdout" "stream-success" | wc -l)"
12+
echo "Successful tgen stream count: ${stream_count}"
13+
14+
if [ "${stream_count}" != "80" ]; then
15+
echo "Not all tgen streams were successful"
16+
exit 1
17+
fi

0 commit comments

Comments
 (0)