Use testspeed to test all sample models and all models in mujoco/test.

PiperOrigin-RevId: 465534183
Change-Id: Ic0c398d45ce3a4da5d0a2b7310439f17f0ec4162
This commit is contained in:
Nimrod Gileadi
2022-08-05 04:24:49 -07:00
committed by Copybara-Service
parent fae896c51b
commit 7a0e0ed80c
+31 -7
View File
@@ -13,10 +13,29 @@
# See the License for the specific language governing permissions and
# 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; }
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
die "Expecting environment variable TARGET_BINARY."
fi
@@ -27,12 +46,17 @@ if [ -z "$MUJOCO_DLL_DIR" ]; then
PATH=$PATH:$MUJOCO_DLL_DIR
fi
readonly EXPECTED_STR='Simulation time'
("$TARGET_BINARY" "$MODEL" 10 || die "testspeed failed") | grep "$EXPECTED_STR"
if [ "$?" != 0 ]; then
die "Expected string not found in output ($EXPECTED_STR)."
fi
shopt -s globstar
for model_dir in ${MODEL_DIRS[@]}; do
echo "Looking in $model_dir"
for model in $model_dir/**/*.xml; do
if [[ $(basename $model) == malformed* ]]; then
echo "Skipping $model" >&2
continue
fi
test_model "$model"
done
done
cd $CURRENT_DIR
echo "PASS"