Use testspeed to test all sample models and all models in mujoco/test.
PiperOrigin-RevId: 465534183 Change-Id: Ic0c398d45ce3a4da5d0a2b7310439f17f0ec4162
This commit is contained in:
committed by
Copybara-Service
parent
fae896c51b
commit
7a0e0ed80c
@@ -13,10 +13,29 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
MODEL="${CMAKE_SOURCE_DIR}/model/humanoid100/humanoid100.xml"
|
MODEL_DIRS=(
|
||||||
|
"${CMAKE_SOURCE_DIR}/model"
|
||||||
|
"${CMAKE_SOURCE_DIR}/test"
|
||||||
|
)
|
||||||
|
|
||||||
die() { echo "$*" 1>&2 ; exit 1; }
|
die() { echo "$*" 1>&2 ; exit 1; }
|
||||||
|
|
||||||
|
test_model() {
|
||||||
|
local EXPECTED_STR='Simulation time'
|
||||||
|
local model="$1"
|
||||||
|
echo "Testing $model" >&2
|
||||||
|
|
||||||
|
# run testspeed, writing its output to stderr.
|
||||||
|
# die if testspeed returns a failure code, or if it doesn't have the string
|
||||||
|
# "Simulation time" in the output.
|
||||||
|
("$TARGET_BINARY" "$model" 10 || die "testspeed failed") \
|
||||||
|
| tee >(cat 1>&2) | grep -q "$EXPECTED_STR"
|
||||||
|
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
die "Expected string not found in output ($EXPECTED_STR)."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ -z "$TARGET_BINARY" ]; then
|
if [ -z "$TARGET_BINARY" ]; then
|
||||||
die "Expecting environment variable TARGET_BINARY."
|
die "Expecting environment variable TARGET_BINARY."
|
||||||
fi
|
fi
|
||||||
@@ -27,12 +46,17 @@ if [ -z "$MUJOCO_DLL_DIR" ]; then
|
|||||||
PATH=$PATH:$MUJOCO_DLL_DIR
|
PATH=$PATH:$MUJOCO_DLL_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly EXPECTED_STR='Simulation time'
|
shopt -s globstar
|
||||||
("$TARGET_BINARY" "$MODEL" 10 || die "testspeed failed") | grep "$EXPECTED_STR"
|
for model_dir in ${MODEL_DIRS[@]}; do
|
||||||
|
echo "Looking in $model_dir"
|
||||||
if [ "$?" != 0 ]; then
|
for model in $model_dir/**/*.xml; do
|
||||||
die "Expected string not found in output ($EXPECTED_STR)."
|
if [[ $(basename $model) == malformed* ]]; then
|
||||||
fi
|
echo "Skipping $model" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
test_model "$model"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
cd $CURRENT_DIR
|
cd $CURRENT_DIR
|
||||||
echo "PASS"
|
echo "PASS"
|
||||||
|
|||||||
Reference in New Issue
Block a user