Skip to content

Instantly share code, notes, and snippets.

@cmansley
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmansley/c6fe6424f139025d9dd4 to your computer and use it in GitHub Desktop.
Save cmansley/c6fe6424f139025d9dd4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
#
# Usage:
# Any arguments to this script are passed along to `catkin build`
#
# i.e.:
# ./race.zsh # Run with default number of jobs
# ./race.zsh -p 1 # Run with only one job
#
# Description:
# This script creates a simple catkin workspace with three catkin packages and
# one vanilla cmake package. It then attempts to build this workspace with
# catkin build. After building, it checks to see if all three of the catkin
# packages are listed in the ROS_PACKAGE_PATH. If they are not, this is
# considered a failure, and contributes to the fail rate.
#
# With the current beta version of catkin_tools, this operation fails about 1.5%
# of the time due to some race condition.
#
# ref: https://github.com/catkin/catkin_tools/issues/77
# ref: https://gist.github.com/jbohren/0e57551d1cf51d4e9a13
FAILS=0.0
FAIL_RATE=0.0
mkdir -p cb_race_condition
pushd cb_race_condition
# create test
rm -rf src
mkdir -p src
pushd src
for pkg in a{0..300}; do
catkin_create_pkg ${pkg}
done
popd
for COUNT in {1..200}; do
# clean
source /opt/ros/jade/setup.zsh
rm -rf build devel
# build
catkin build "$@" --no-notify
source devel/setup.zsh
# check
echo $ROS_PACKAGE_PATH
wc devel/.catkin
for pkg in a{0..100}; do
if [[ "${ROS_PACKAGE_PATH#*$pkg}" == "$ROS_PACKAGE_PATH" ]]; then
(( FAILS += 1.0 ))
echo "FAIL"
fi
done
# report
(( FAIL_RATE=FAILS/COUNT ))
echo "====================================="
echo "Attempt: $COUNT"
echo "Fail rate: $FAIL_RATE"
echo "====================================="
done
echo "====================================="
echo "====================================="
echo "====================================="
echo "Fail rate: $FAIL_RATE"
echo "====================================="
echo "====================================="
echo "====================================="
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment