#!/bin/bash
# Test CoreMark-PRO benchmark Docker image

IMAGE_NAME="coremark_pro_rdk_arm"
IMAGE_TAG="${1:-latest}"

echo "Testing CoreMark-PRO benchmark image..."
echo "Image: ${IMAGE_NAME}:${IMAGE_TAG}"
echo ""

# Create test output directory
mkdir -p "$(pwd)/example_fs/output"

# Run the benchmark
docker run --rm \
  --name coremark_pro_rdk_arm_test \
  --privileged \
  -v "$(pwd)/example_fs/output":/workspace/output \
  ${IMAGE_NAME}:${IMAGE_TAG}

EXIT_CODE=$?

echo ""
if [ $EXIT_CODE -eq 0 ]; then
    echo "Test passed!"
    echo "Results available at: $(pwd)/example_fs/output/result.json"
else
    echo "Test failed with exit code: $EXIT_CODE"
fi

exit $EXIT_CODE
